1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-24 04:05:39 +01:00

get_media: split all_episodes to its own function

This commit is contained in:
Johan Andersson 2016-03-26 13:08:45 +01:00
parent 504b3ccf22
commit f7488af095

View File

@ -152,33 +152,37 @@ def get_media(url, options):
sys.exit(2)
if options.all_episodes:
if options.output and os.path.isfile(options.output):
log.error("Output must be a directory if used with --all-episodes")
sys.exit(2)
elif options.output and not os.path.exists(options.output):
try:
os.makedirs(options.output)
except OSError as e:
log.error("%s: %s" % (e.strerror, e.filename))
return
episodes = stream.find_all_episodes(options)
if episodes is None:
return
for idx, o in enumerate(episodes):
if o == url:
substream = stream
else:
substream = service_handler(sites, options, o)
log.info("Episode %d of %d", idx + 1, len(episodes))
# get_one_media overwrites options.output...
get_one_media(substream, copy.copy(options))
get_all_episodes(stream, options, url)
else:
get_one_media(stream, options)
def get_all_episodes(stream, options, url):
if options.output and os.path.isfile(options.output):
log.error("Output must be a directory if used with --all-episodes")
sys.exit(2)
elif options.output and not os.path.exists(options.output):
try:
os.makedirs(options.output)
except OSError as e:
log.error("%s: %s" % (e.strerror, e.filename))
return
episodes = stream.find_all_episodes(options)
if episodes is None:
return
for idx, o in enumerate(episodes):
if o == url:
substream = stream
else:
substream = service_handler(sites, options, o)
log.info("Episode %d of %d", idx + 1, len(episodes))
# get_one_media overwrites options.output...
get_one_media(substream, copy.copy(options))
def get_one_media(stream, options):
# Make an automagic filename
if not filename(stream):