fix parsing youtube URL

This commit is contained in:
Romain Bignon 2012-01-21 16:19:45 +01:00
commit eb5b5a312f

View file

@ -103,12 +103,12 @@ class VideoPage(BaseYoutubePage):
if not text:
continue
pattern = "'PLAYER_CONFIG': "
pattern = "yt.playerConfig = "
pos = text.find(pattern)
if pos < 0:
continue
sub = text[pos+len(pattern):pos+text[pos:].find('\n')]
sub = text[pos+len(pattern):pos+text[pos:].find('\n')].rstrip(';')
a = json.loads(sub)
for part in a['args']['url_encoded_fmt_stream_map'].split('&'):
@ -120,6 +120,8 @@ class VideoPage(BaseYoutubePage):
fmt, url = value.split(',url=')
formats[int(fmt)] = url
break
# choose the better format to use.
for format in self.AVAILABLE_FORMATS[self.AVAILABLE_FORMATS.index(format):]:
if format in formats: