File: api_testing.py

package info (click to toggle)
ccextractor 0.88%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 11,912 kB
  • sloc: ansic: 201,481; makefile: 782; sh: 669; python: 319
file content (38 lines) | stat: -rw-r--r-- 822 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from __future__ import print_function
###
#MANDATORY UPDATES IN EVERY PYTHON SCRIPT
###
import sys

import ccextractor as cc


def callback(line, encoding):
    print(line)


def init_ccextractor(callback):
    """
    :param callback: The callback which we use to handle
                     the extracted subtitle info
    :return return the initialized options
    """
    optionos = cc.api_init_options()
    cc.check_configuration_file(optionos)
    for arg in sys.argv[1:]:
        cc.api_add_param(optionos, arg)
    compile_ret = cc.compile_params(optionos, len(sys.argv[1:]))

    # use my_pythonapi to add callback in C source code
    cc.my_pythonapi(optionos, callback)

    return optionos


def main():
    options = init_ccextractor(callback)
    cc.api_start(options)


if __name__=="__main__":
    main()