1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-24 12:15:40 +01:00

get_one_media: select quality

This commit is contained in:
Johan Andersson 2014-04-27 10:43:26 +02:00
parent 850eabf276
commit 69b28712b3
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.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.fetcher import VideoRetriever
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:
subs[0].download(options)
bitrate = sorted(x.bitrate for x in videos)
for i in videos:
if i.bitrate == bitrate[0]:
stream = i
stream = select_quality(options, videos)
try:
stream.download()
except UIException as e:

View File

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