1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-27 21:54:17 +01:00

Move Options to parser?

This commit is contained in:
Johan Andersson 2018-01-30 21:43:19 +01:00
parent 03c8b68bb6
commit d496955cb4
2 changed files with 64 additions and 60 deletions

View File

@ -6,71 +6,14 @@ import sys
import logging
from svtplay_dl.log import log
from svtplay_dl.utils.parser import parser, mergeparseroption
from svtplay_dl.utils.parser import parser, mergeparseroption, Options
from svtplay_dl.utils.getmedia import get_all_episodes, get_media, get_multiple_media, get_one_media
from svtplay_dl.service.cmore import Cmore
__version__ = "1.9.11"
class Options(object):
"""
Options used when invoking the script from another Python script.
Simple container class used when calling get_media() from another Python
script. The variables corresponds to the command line parameters parsed
in main() when the script is called directly.
When called from a script there are a few more things to consider:
* Logging is done to 'log'. main() calls setup_log() which sets the
logging to either stdout or stderr depending on the silent level.
A user calling get_media() directly can either also use setup_log()
or configure the log manually.
* Progress information is printed to 'progress_stream' which defaults to
sys.stderr but can be changed to any stream.
* Many errors results in calls to system.exit() so catch 'SystemExit'-
Exceptions to prevent the entire application from exiting if that happens.
"""
def __init__(self):
self.output = None
self.resume = False
self.live = False
self.capture_time = -1
self.silent = False
self.force = False
self.quality = 0
self.flexibleq = 0
self.list_quality = False
self.other = None
self.subtitle = False
self.username = None
self.password = None
self.thumbnail = False
self.all_episodes = False
self.all_last = -1
self.merge_subtitle = False
self.force_subtitle = False
self.require_subtitle = False
self.get_all_subtitles = False
self.get_raw_subtitles = False
self.convert_subtitle_colors = False
self.preferred = None
self.verbose = False
self.output_auto = False
self.service = None
self.cookies = None
self.exclude = None
self.get_url = False
self.ssl_verify = True
self.http_headers = None
self.stream_prio = None
self.remux = False
self.silent_semi = False
self.proxy = None
self.hls_time_stamp = False
log = logging.getLogger('svtplay_dl')
def setup_log(silent, verbose=False):

View File

@ -1,6 +1,66 @@
import argparse
class Options(object):
"""
Options used when invoking the script from another Python script.
Simple container class used when calling get_media() from another Python
script. The variables corresponds to the command line parameters parsed
in main() when the script is called directly.
When called from a script there are a few more things to consider:
* Logging is done to 'log'. main() calls setup_log() which sets the
logging to either stdout or stderr depending on the silent level.
A user calling get_media() directly can either also use setup_log()
or configure the log manually.
* Progress information is printed to 'progress_stream' which defaults to
sys.stderr but can be changed to any stream.
* Many errors results in calls to system.exit() so catch 'SystemExit'-
Exceptions to prevent the entire application from exiting if that happens.
"""
def __init__(self):
self.output = None
self.resume = False
self.live = False
self.capture_time = -1
self.silent = False
self.force = False
self.quality = 0
self.flexibleq = 0
self.list_quality = False
self.other = None
self.subtitle = False
self.username = None
self.password = None
self.thumbnail = False
self.all_episodes = False
self.all_last = -1
self.merge_subtitle = False
self.force_subtitle = False
self.require_subtitle = False
self.get_all_subtitles = False
self.get_raw_subtitles = False
self.convert_subtitle_colors = False
self.preferred = None
self.verbose = False
self.output_auto = False
self.service = None
self.cookies = None
self.exclude = None
self.get_url = False
self.ssl_verify = True
self.http_headers = None
self.stream_prio = None
self.remux = False
self.silent_semi = False
self.proxy = None
def parser(version):
parser = argparse.ArgumentParser(prog="svtplay-dl")
general = parser.add_argument_group()
@ -84,6 +144,7 @@ def parser(version):
parser.add_argument('urls', nargs="*")
options = parser.parse_args()
return parser, options