mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-11-28 09:30:57 +01:00
This commit is contained in:
parent
0606808746
commit
f41347260c
@ -227,12 +227,13 @@ class PornHubIE(PornHubBaseIE):
|
|||||||
else:
|
else:
|
||||||
thumbnail, duration = [None] * 2
|
thumbnail, duration = [None] * 2
|
||||||
|
|
||||||
if not video_urls:
|
def extract_js_vars(webpage, pattern, fatal=True):
|
||||||
tv_webpage = dl_webpage('tv')
|
|
||||||
|
|
||||||
assignments = self._search_regex(
|
assignments = self._search_regex(
|
||||||
r'(var.+?mediastring.+?)</script>', tv_webpage,
|
pattern, webpage, 'encoded url', fatal=fatal)
|
||||||
'encoded url').split(';')
|
if not assignments:
|
||||||
|
return {}
|
||||||
|
|
||||||
|
assignments = assignments.split(';')
|
||||||
|
|
||||||
js_vars = {}
|
js_vars = {}
|
||||||
|
|
||||||
@ -254,11 +255,31 @@ class PornHubIE(PornHubBaseIE):
|
|||||||
assn = re.sub(r'var\s+', '', assn)
|
assn = re.sub(r'var\s+', '', assn)
|
||||||
vname, value = assn.split('=', 1)
|
vname, value = assn.split('=', 1)
|
||||||
js_vars[vname] = parse_js_value(value)
|
js_vars[vname] = parse_js_value(value)
|
||||||
|
return js_vars
|
||||||
|
|
||||||
video_url = js_vars['mediastring']
|
def add_video_url(video_url):
|
||||||
if video_url not in video_urls_set:
|
v_url = url_or_none(video_url)
|
||||||
video_urls.append((video_url, None))
|
if not v_url:
|
||||||
video_urls_set.add(video_url)
|
return
|
||||||
|
if v_url in video_urls_set:
|
||||||
|
return
|
||||||
|
video_urls.append((v_url, None))
|
||||||
|
video_urls_set.add(v_url)
|
||||||
|
|
||||||
|
if not video_urls:
|
||||||
|
FORMAT_PREFIXES = ('media', 'quality')
|
||||||
|
js_vars = extract_js_vars(
|
||||||
|
webpage, r'(var\s+(?:%s)_.+)' % '|'.join(FORMAT_PREFIXES),
|
||||||
|
fatal=False)
|
||||||
|
if js_vars:
|
||||||
|
for key, format_url in js_vars.items():
|
||||||
|
if any(key.startswith(p) for p in FORMAT_PREFIXES):
|
||||||
|
add_video_url(format_url)
|
||||||
|
|
||||||
|
if not video_urls:
|
||||||
|
js_vars = extract_js_vars(
|
||||||
|
dl_webpage('tv'), r'(var.+?mediastring.+?)</script>')
|
||||||
|
add_video_url(js_vars['mediastring'])
|
||||||
|
|
||||||
for mobj in re.finditer(
|
for mobj in re.finditer(
|
||||||
r'<a[^>]+\bclass=["\']downloadBtn\b[^>]+\bhref=(["\'])(?P<url>(?:(?!\1).)+)\1',
|
r'<a[^>]+\bclass=["\']downloadBtn\b[^>]+\bhref=(["\'])(?P<url>(?:(?!\1).)+)\1',
|
||||||
@ -276,10 +297,16 @@ class PornHubIE(PornHubBaseIE):
|
|||||||
r'/(\d{6}/\d{2})/', video_url, 'upload data', default=None)
|
r'/(\d{6}/\d{2})/', video_url, 'upload data', default=None)
|
||||||
if upload_date:
|
if upload_date:
|
||||||
upload_date = upload_date.replace('/', '')
|
upload_date = upload_date.replace('/', '')
|
||||||
if determine_ext(video_url) == 'mpd':
|
ext = determine_ext(video_url)
|
||||||
|
if ext == 'mpd':
|
||||||
formats.extend(self._extract_mpd_formats(
|
formats.extend(self._extract_mpd_formats(
|
||||||
video_url, video_id, mpd_id='dash', fatal=False))
|
video_url, video_id, mpd_id='dash', fatal=False))
|
||||||
continue
|
continue
|
||||||
|
elif ext == 'm3u8':
|
||||||
|
formats.extend(self._extract_m3u8_formats(
|
||||||
|
video_url, video_id, 'mp4', entry_protocol='m3u8_native',
|
||||||
|
m3u8_id='hls', fatal=False))
|
||||||
|
continue
|
||||||
tbr = None
|
tbr = None
|
||||||
mobj = re.search(r'(?P<height>\d+)[pP]?_(?P<tbr>\d+)[kK]', video_url)
|
mobj = re.search(r'(?P<height>\d+)[pP]?_(?P<tbr>\d+)[kK]', video_url)
|
||||||
if mobj:
|
if mobj:
|
||||||
|
Loading…
Reference in New Issue
Block a user