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

get_one_media: select quality

This commit is contained in:
Johan Andersson 2014-04-27 10:43:26 +02:00
parent 4265d1222b
commit a857f1d906
2 changed files with 8 additions and 7 deletions

View File

@ -11,7 +11,7 @@ from optparse import OptionParser
from svtplay_dl.error import UIException from svtplay_dl.error import UIException
from svtplay_dl.log import log from svtplay_dl.log import log
from svtplay_dl.utils import get_http_data, decode_html_entities, filenamify from svtplay_dl.utils import get_http_data, decode_html_entities, filenamify, select_quality
from svtplay_dl.service import service_handler, Generic from svtplay_dl.service import service_handler, Generic
from svtplay_dl.fetcher import VideoRetriever from svtplay_dl.fetcher import VideoRetriever
from svtplay_dl.subtitle import subtitle, subtitle_json, subtitle_sami, subtitle_smi, subtitle_tt, subtitle_wsrt from svtplay_dl.subtitle import subtitle, subtitle_json, subtitle_sami, subtitle_smi, subtitle_tt, subtitle_wsrt
@ -116,10 +116,8 @@ def get_one_media(stream, options):
if subs: if subs:
subs[0].download(options) subs[0].download(options)
bitrate = sorted(x.bitrate for x in videos)
for i in videos: stream = select_quality(options, videos)
if i.bitrate == bitrate[0]:
stream = i
try: try:
stream.download() stream.download()
except UIException as e: except UIException as e:

View File

@ -106,7 +106,7 @@ def check_redirect(url):
return url return url
def select_quality(options, streams): def select_quality(options, streams):
available = sorted(streams.keys(), key=int) available = sorted(x.bitrate for x in streams)
try: try:
optq = int(options.quality) optq = int(options.quality)
@ -137,7 +137,10 @@ def select_quality(options, streams):
", ".join([str(elm) for elm in available])) ", ".join([str(elm) for elm in available]))
sys.exit(4) sys.exit(4)
return streams[selected] for i in streams:
if i.bitrate == selected:
stream = i
return stream
def ensure_unicode(s): def ensure_unicode(s):
""" """