Implement new return object format for videos, including priority index

develop
Sven Slootweg 13 years ago
parent de3b321769
commit a7113a77fd

@ -21,7 +21,14 @@ def resolve(url):
video_file = matches.group(1)
return { 'title': "", 'videos': { 'video': video_file } }
stream_dict = {
'url' : video_file,
'quality' : "unknown",
'priority' : 1,
'format' : "unknown"
}
return { 'title': "", 'videos': [stream_dict] }
def resolve2(url):
# This is a fallback function in case no video could be found through the resolve() method.

@ -52,4 +52,11 @@ def resolve(url):
except:
raise ResolverError("Could not find the video title.")
return { 'title': video_title, 'videos': { 'video': video_file } }
stream_dict = {
'url' : video_file,
'quality' : "unknown",
'priority' : 1,
'format' : "unknown"
}
return { 'title': video_title, 'videos': [stream_dict] }

@ -52,4 +52,11 @@ def resolve(url):
except:
raise ResolverError("Could not find the video title.")
return { 'title': video_title, 'videos': { 'video': video_file } }
stream_dict = {
'url' : video_file,
'quality' : "unknown",
'priority' : 1,
'format' : "unknown"
}
return { 'title': video_title, 'videos': [stream_dict] }

@ -28,7 +28,7 @@ def resolve(url):
except:
raise ResolverError("The YouTube player configuration is corrupted.")
stream_pool = {}
stream_pool = []
for stream in streams:
fields = stream.split('&')
@ -55,18 +55,30 @@ def resolve(url):
if quality == "small":
video_quality = "240p"
video_priority = 5
elif quality == "medium":
video_quality = "360p"
video_priority = 4
elif quality == "large":
video_quality = "480p"
video_priority = 3
elif quality == "hd720":
video_quality = "720p"
video_priority = 2
elif quality == "hd1080":
video_quality = "1080p"
video_priority = 1
else:
video_quality = "unknown"
stream_pool['video_%s_%s' % (video_quality, video_format)] = video_url
stream_dict = {
'url' : video_url,
'quality' : video_quality,
'priority' : video_priority,
'format' : video_format
}
stream_pool.append(stream_dict)
try:
video_title = unescape(re.search('<meta property="og:title" content="([^"]*)">', contents).group(1))

Loading…
Cancel
Save