1
0
mirror of https://github.com/l1ving/youtube-dl synced 2025-01-24 19:23:02 +08:00

Error Prevention and Different Qualitys

Added some error preventions and an autoselection for the best quality, thats avaible
This commit is contained in:
flatt3rn 2017-01-07 15:15:26 +01:00 committed by GitHub
parent 92803c6c01
commit b6a91ea750

View File

@ -17,13 +17,34 @@ class UniversalMusicServiceIE(InfoExtractor):
def _real_extract(self, url):
video_id = self._match_id(url)
video_url = "http://mediadelivery.universal-music-services.de/vod/mp4:autofill/storage/" + video_id[0:1] + "/" + video_id[1:2] + "/" + video_id[2:3] + "/" + video_id[3:4] + "/" + video_id[4:5] + "/" + video_id[5:6] + "/content/836/file/playlist.m3u8"
#video_url = "http://mediadelivery.universal-music-services.de/vod/mp4:autofill/storage/" + video_id[0:1] + "/" + video_id[1:2] + "/" + video_id[2:3] + "/" + video_id[3:4] + "/" + video_id[4:5] + "/" + video_id[5:6] + "/content/686/file/playlist.m3u8"
webpage = self._download_webpage(url, video_id)
if " <p>Dieser Inhalt ist nicht (mehr) verfügbar.</p>" in webpage:
self.to_screen("ERROR: Webpage not found")
sys.exit()
title = self._html_search_regex(r'<title>.+ \| (.+) \| .+<\/title>', webpage, 'title')
album = self._html_search_regex(r'class="product-banner-text1">(.+)<\/p>', webpage, 'album')
if len(title) == 0:
self.to_screen("Title not found")
title = "Unknown"
if len(album) == 0:
self.to_screen("Album not found"))
album = "Unknown"
qualitys = ["940","836",867]
#836: 1024x576
#940: 1920x1080
#867: 483x272
for quality in qualitys:
video_url = "http://mediadelivery.universal-music-services.de/vod/mp4:autofill/storage/" + video_id[0:1] + "/" + video_id[1:2] + "/" + video_id[2:3] + "/" + video_id[3:4] + "/" + video_id[4:5] + "/" + video_id[5:6] + "/content/" + quality + "/file/playlist.m3u8"
webpage = self._download_webpage(video_url, video_id)
if "RESOLUTION=" in webpage:
break
if len(video_url) == 0:
self.to_screen("ERROR: No Stream found")
sys.exit()
return {
'id': video_id,
'title': title,