fix parsing youtube URL
This commit is contained in:
parent
f28fac3a27
commit
eb5b5a312f
1 changed files with 4 additions and 2 deletions
|
|
@ -103,12 +103,12 @@ class VideoPage(BaseYoutubePage):
|
||||||
if not text:
|
if not text:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
pattern = "'PLAYER_CONFIG': "
|
pattern = "yt.playerConfig = "
|
||||||
pos = text.find(pattern)
|
pos = text.find(pattern)
|
||||||
if pos < 0:
|
if pos < 0:
|
||||||
continue
|
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)
|
a = json.loads(sub)
|
||||||
|
|
||||||
for part in a['args']['url_encoded_fmt_stream_map'].split('&'):
|
for part in a['args']['url_encoded_fmt_stream_map'].split('&'):
|
||||||
|
|
@ -120,6 +120,8 @@ class VideoPage(BaseYoutubePage):
|
||||||
fmt, url = value.split(',url=')
|
fmt, url = value.split(',url=')
|
||||||
formats[int(fmt)] = url
|
formats[int(fmt)] = url
|
||||||
|
|
||||||
|
break
|
||||||
|
|
||||||
# choose the better format to use.
|
# choose the better format to use.
|
||||||
for format in self.AVAILABLE_FORMATS[self.AVAILABLE_FORMATS.index(format):]:
|
for format in self.AVAILABLE_FORMATS[self.AVAILABLE_FORMATS.index(format):]:
|
||||||
if format in formats:
|
if format in formats:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue