2013-03-23 15:02:41 +01:00
|
|
|
# ex:ts=4:sw=4:sts=4:et
|
|
|
|
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
2016-04-30 13:54:26 +02:00
|
|
|
from __future__ import absolute_import, unicode_literals
|
|
|
|
|
2013-03-23 15:02:41 +01:00
|
|
|
import sys
|
|
|
|
import logging
|
|
|
|
|
|
|
|
from svtplay_dl.log import log
|
2018-01-30 21:43:19 +01:00
|
|
|
from svtplay_dl.utils.parser import parser, mergeparseroption, Options
|
2018-01-14 00:49:26 +01:00
|
|
|
from svtplay_dl.utils.getmedia import get_all_episodes, get_media, get_multiple_media, get_one_media
|
2018-01-30 21:43:19 +01:00
|
|
|
|
2017-09-16 23:45:29 +02:00
|
|
|
from svtplay_dl.service.cmore import Cmore
|
2015-01-28 18:26:50 +01:00
|
|
|
|
2018-03-11 23:40:02 +01:00
|
|
|
__version__ = "1.9.11"
|
2013-03-23 15:02:41 +01:00
|
|
|
|
2018-01-30 21:43:19 +01:00
|
|
|
log = logging.getLogger('svtplay_dl')
|
2013-03-23 15:02:41 +01:00
|
|
|
|
2018-01-30 20:11:37 +01:00
|
|
|
|
2014-01-05 16:30:45 +01:00
|
|
|
def setup_log(silent, verbose=False):
|
2016-05-04 14:16:59 +02:00
|
|
|
logging.addLevelName(25, "INFO")
|
2014-02-09 15:38:51 +01:00
|
|
|
fmt = logging.Formatter('%(levelname)s: %(message)s')
|
2013-03-23 15:02:41 +01:00
|
|
|
if silent:
|
|
|
|
stream = sys.stderr
|
2016-05-04 14:16:59 +02:00
|
|
|
level = 25
|
2014-01-05 16:30:45 +01:00
|
|
|
elif verbose:
|
|
|
|
stream = sys.stderr
|
|
|
|
level = logging.DEBUG
|
2014-10-12 23:41:44 +02:00
|
|
|
fmt = logging.Formatter('%(levelname)s [%(created)s] %(pathname)s/%(funcName)s: %(message)s')
|
2013-03-23 15:02:41 +01:00
|
|
|
else:
|
|
|
|
stream = sys.stdout
|
|
|
|
level = logging.INFO
|
|
|
|
|
|
|
|
hdlr = logging.StreamHandler(stream)
|
|
|
|
hdlr.setFormatter(fmt)
|
|
|
|
|
|
|
|
log.addHandler(hdlr)
|
|
|
|
log.setLevel(level)
|
|
|
|
|
2015-09-15 20:10:32 +02:00
|
|
|
|
2013-03-23 15:02:41 +01:00
|
|
|
def main():
|
|
|
|
""" Main program """
|
2018-01-14 00:39:16 +01:00
|
|
|
parse, options = parser(__version__)
|
2018-01-14 00:35:28 +01:00
|
|
|
|
2018-01-13 20:53:02 +01:00
|
|
|
if len(options.urls) == 0:
|
2018-01-14 00:39:16 +01:00
|
|
|
parse.print_help()
|
2013-07-25 21:01:57 +02:00
|
|
|
sys.exit(0)
|
2018-01-13 20:53:02 +01:00
|
|
|
urls = options.urls
|
|
|
|
if len(urls) < 1:
|
2018-01-14 00:39:16 +01:00
|
|
|
parse.error("Incorrect number of arguments")
|
2014-12-22 17:41:40 +01:00
|
|
|
if options.exclude:
|
|
|
|
options.exclude = options.exclude.split(",")
|
2015-09-18 21:47:07 +02:00
|
|
|
if options.require_subtitle:
|
2016-06-20 18:33:42 +02:00
|
|
|
if options.merge_subtitle:
|
|
|
|
options.merge_subtitle = True
|
|
|
|
else:
|
|
|
|
options.subtitle = True
|
2016-06-24 05:49:34 +02:00
|
|
|
if options.merge_subtitle:
|
|
|
|
options.remux = True
|
2018-01-14 00:31:00 +01:00
|
|
|
options = mergeparseroption(Options(), options)
|
2016-05-04 14:16:59 +02:00
|
|
|
if options.silent_semi:
|
|
|
|
options.silent = True
|
2014-01-05 16:30:45 +01:00
|
|
|
setup_log(options.silent, options.verbose)
|
2013-03-23 15:02:41 +01:00
|
|
|
|
2017-09-19 00:30:11 +02:00
|
|
|
if options.cmoreoperatorlist:
|
2018-01-13 20:53:02 +01:00
|
|
|
c = Cmore(options, urls)
|
2017-09-19 00:30:11 +02:00
|
|
|
c.operatorlist()
|
|
|
|
sys.exit(0)
|
|
|
|
|
2017-11-22 00:36:50 +01:00
|
|
|
if options.proxy:
|
|
|
|
options.proxy = options.proxy.replace("socks5", "socks5h", 1)
|
|
|
|
options.proxy = dict(http=options.proxy,
|
|
|
|
https=options.proxy)
|
|
|
|
|
2013-03-23 18:26:48 +01:00
|
|
|
if options.flexibleq and not options.quality:
|
|
|
|
log.error("flexible-quality requires a quality")
|
|
|
|
sys.exit(4)
|
|
|
|
|
2014-04-02 19:32:35 +02:00
|
|
|
try:
|
2017-01-04 04:20:50 +01:00
|
|
|
if len(urls) == 1:
|
2018-01-14 00:49:26 +01:00
|
|
|
get_media(urls[0], options, __version__)
|
2017-01-04 04:20:50 +01:00
|
|
|
else:
|
|
|
|
get_multiple_media(urls, options)
|
2014-04-02 19:32:35 +02:00
|
|
|
except KeyboardInterrupt:
|
2014-05-02 12:06:53 +02:00
|
|
|
print("")
|
2014-08-11 21:00:19 +02:00
|
|
|
|
2015-09-15 20:10:32 +02:00
|
|
|
|