1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-09-03 00:25:08 +00:00

[compat, networking] Deprecate old functions (#2861)

Authored by: coletdjnz, pukkandan
This commit is contained in:
coletdjnz
2023-07-09 13:23:02 +05:30
committed by pukkandan
parent 227bf1a33b
commit 3d2623a898
176 changed files with 707 additions and 729 deletions

View File

@ -2,16 +2,15 @@ import re
from .common import InfoExtractor
from ..compat import compat_str
from ..networking import HEADRequest, Request
from ..utils import (
ExtractorError,
RegexNotFoundError,
find_xpath_attr,
fix_xml_ampersands,
float_or_none,
HEADRequest,
int_or_none,
join_nonempty,
RegexNotFoundError,
sanitized_Request,
strip_or_none,
timeconvert,
try_get,
@ -51,15 +50,15 @@ class MTVServicesInfoExtractor(InfoExtractor):
def _extract_mobile_video_formats(self, mtvn_id):
webpage_url = self._MOBILE_TEMPLATE % mtvn_id
req = sanitized_Request(webpage_url)
req = Request(webpage_url)
# Otherwise we get a webpage that would execute some javascript
req.add_header('User-Agent', 'curl/7')
req.headers['User-Agent'] = 'curl/7'
webpage = self._download_webpage(req, mtvn_id,
'Downloading mobile page')
metrics_url = unescapeHTML(self._search_regex(r'<a href="(http://metrics.+?)"', webpage, 'url'))
req = HEADRequest(metrics_url)
response = self._request_webpage(req, mtvn_id, 'Resolving url')
url = response.geturl()
url = response.url
# Transform the url to get the best quality:
url = re.sub(r'.+pxE=mp4', 'http://mtvnmobile.vo.llnwd.net/kip0/_pxn=0+_pxK=18639+_pxE=mp4', url, 1)
return [{'url': url, 'ext': 'mp4'}]