forked from BenjV/autosub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAutoSub.py
76 lines (67 loc) · 2.94 KB
/
AutoSub.py
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#################################################################################################################
# History: #
# First developed by zyronix to work with the website "Bierdopje" #
# After the ending of Bierdopje collincab took over and change it to use subtitleseeker instead of Bierdopje. #
# Donny stepped in a added the bootstrap user interface an the support for mobil devices and notifications. #
# Later collincab added support for the website Addic7ed #
# First collingcab and later Donny abbanded the project and Benj took over the support. #
# He added support for the Opensubtitles API, the TVDB API v2 and numerous other options #
#################################################################################################################
import sys,os
# Root path
base_path = os.path.dirname(os.path.abspath(__file__))
# Insert local directories into path
sys.path.insert(0, os.path.join(base_path, 'library'))
from getopt import getopt
from time import sleep
import locale,json
import platform
import autosub
from autosub.AutoSub import start
import cherrypy
help_message = '''
Usage:
-h (--help) Prints this message
-c (--config=) Forces AutoSub.py to use a configfile other than ./config.properties, the database will be put in the same folder
-d (--daemon) Run AutoSub in the background
-l (--nolaunch) Stop AutoSub from launching a webbrowser
Example:
python AutoSub.py
python AutoSub.py -d
python AutoSub.py -d -l
python AutoSub.py -c/home/user/config.properties
python AutoSub.py -c/home/user
python AutoSub.py --config=/home/user/config.properties
python AutoSub.py --config=/home/user/config.properties --daemon
'''
class Usage(Exception):
def __init__(self, msg):
self.msg = msg
def main(argv=None):
Update = False
if argv is None:
argv = sys.argv
try:
opts, args= getopt(argv[1:], "hc:dlu", ["help","config=","daemon","nolaunch","updated="])
except Exception as error:
print error
os._exit(1)
# option processing
for option, value in opts:
if option in ("-h", "--help"):
raise Usage(help_message)
if option in ("-c", "--config"):
autosub.CONFIGFILE = value
if option in ("-l", "--nolaunch"):
autosub.LAUNCHBROWSER = False
if option in ("-d", "--daemon"):
if sys.platform == "win32":
print "ERROR: No support for daemon mode in Windows"
# TODO: Service support for Windows
else:
autosub.DAEMON = True
if option in ("-u"):
autosub.UPDATED = True
autosub.AutoSub.start()
if __name__ == "__main__":
sys.exit(main())