mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-11-16 06:15:46 +00:00
[doodstream] only use metadata from the page
This commit is contained in:
parent
3be8521c91
commit
948c020489
1 changed files with 8 additions and 39 deletions
|
@ -9,36 +9,9 @@ from .common import InfoExtractor
|
|||
from ..utils import (
|
||||
js_to_json,
|
||||
urljoin,
|
||||
try_get,
|
||||
)
|
||||
|
||||
|
||||
def doodExe(crp, crs):
|
||||
if crp == 'N_crp':
|
||||
return crs
|
||||
sorted_crp = ''.join(sorted(crp))
|
||||
result = ''
|
||||
for c in crs:
|
||||
i = crp.find(c)
|
||||
if i >= 0:
|
||||
result += sorted_crp[i]
|
||||
result = result.replace('+.+', '(')
|
||||
result = result.replace('+..+', ')')
|
||||
result = result.replace('+-+', '[')
|
||||
result = result.replace('+--+', ']')
|
||||
result = result.replace('+', ' ')
|
||||
return result
|
||||
|
||||
|
||||
def try_doodExe(metadata, key):
|
||||
try:
|
||||
x = metadata[key]
|
||||
# everything that can go wrong in this call raises a TypeError
|
||||
return doodExe(**x)
|
||||
except (KeyError, TypeError):
|
||||
return None
|
||||
|
||||
|
||||
class DoodStreamIE(InfoExtractor):
|
||||
_VALID_URL = r'https?://(?:www\.)?(?:doodstream\.com|dood\.(?:la|so|to|watch))/[de]/(?P<id>[^/?#]+)'
|
||||
_TESTS = [{
|
||||
|
@ -49,8 +22,6 @@ class DoodStreamIE(InfoExtractor):
|
|||
'ext': 'mp4',
|
||||
'title': 'Big Buck Bunny Trailer',
|
||||
'thumbnail': r're:^https?://.*\.jpg$',
|
||||
'filesize': 4447915,
|
||||
'duration': 33,
|
||||
},
|
||||
}]
|
||||
|
||||
|
@ -61,12 +32,12 @@ class DoodStreamIE(InfoExtractor):
|
|||
referer = {'Referer': url}
|
||||
webpage = self._download_webpage(url, video_id)
|
||||
|
||||
metadata_url = self._html_search_regex(r"('/cptr/[^']*')", webpage,
|
||||
'video metadata')
|
||||
metadata_url = self._parse_json(metadata_url, video_id,
|
||||
transform_source=js_to_json)
|
||||
metadata_url = urljoin(url, metadata_url)
|
||||
metadata = self._download_json(metadata_url, video_id, headers=referer)
|
||||
title = self._html_search_regex(r'<title>(.+?)\s+-\s+DoodStream</title>',
|
||||
webpage, 'title')
|
||||
thumbnail = self._html_search_regex(r"('https?://img\.doodcdn\.com/splash/.+?')",
|
||||
webpage, 'thumbnail')
|
||||
thumbnail = self._parse_json(thumbnail, video_id,
|
||||
transform_source=js_to_json)
|
||||
|
||||
token = self._html_search_regex(r"[?&]token=([a-z0-9]+)[&']", webpage, 'token')
|
||||
auth_url = self._html_search_regex(r"('/pass_md5.*?')", webpage,
|
||||
|
@ -80,11 +51,9 @@ class DoodStreamIE(InfoExtractor):
|
|||
|
||||
return {
|
||||
'id': video_id,
|
||||
'title': try_doodExe(metadata, 'ttl') or video_id,
|
||||
'title': title,
|
||||
'url': final_url,
|
||||
'http_headers': referer,
|
||||
'ext': 'mp4',
|
||||
'thumbnail': self._og_search_thumbnail(webpage),
|
||||
'filesize': try_get(try_doodExe(metadata, 'siz'), lambda x: int(x, 10)),
|
||||
'duration': try_get(try_doodExe(metadata, 'len'), lambda x: int(x, 10)),
|
||||
'thumbnail': thumbnail,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue