mirror of
https://github.com/spaam/svtplay-dl.git
synced 2024-11-30 15:14:14 +01:00
Move Options to parser?
This commit is contained in:
parent
03c8b68bb6
commit
d496955cb4
@ -6,71 +6,14 @@ import sys
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from svtplay_dl.log import log
|
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.utils.getmedia import get_all_episodes, get_media, get_multiple_media, get_one_media
|
||||||
|
|
||||||
from svtplay_dl.service.cmore import Cmore
|
from svtplay_dl.service.cmore import Cmore
|
||||||
|
|
||||||
__version__ = "1.9.11"
|
__version__ = "1.9.11"
|
||||||
|
|
||||||
class Options(object):
|
log = logging.getLogger('svtplay_dl')
|
||||||
"""
|
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
def setup_log(silent, verbose=False):
|
def setup_log(silent, verbose=False):
|
||||||
|
@ -1,6 +1,66 @@
|
|||||||
import argparse
|
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):
|
def parser(version):
|
||||||
parser = argparse.ArgumentParser(prog="svtplay-dl")
|
parser = argparse.ArgumentParser(prog="svtplay-dl")
|
||||||
general = parser.add_argument_group()
|
general = parser.add_argument_group()
|
||||||
@ -84,6 +144,7 @@ def parser(version):
|
|||||||
|
|
||||||
parser.add_argument('urls', nargs="*")
|
parser.add_argument('urls', nargs="*")
|
||||||
options = parser.parse_args()
|
options = parser.parse_args()
|
||||||
|
|
||||||
return parser, options
|
return parser, options
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user