mirror of
https://github.com/ytdl-org/youtube-dl
synced 2025-07-14 15:34:15 +09:00
Compare commits
15 Commits
2d0272724f
...
302bd87f37
Author | SHA1 | Date | |
---|---|---|---|
![]() |
302bd87f37 | ||
![]() |
da7223d4aa | ||
![]() |
37c2440d6a | ||
![]() |
526ef898bf | ||
![]() |
31595de72b | ||
![]() |
5a7243b741 | ||
![]() |
d30180d4f3 | ||
![]() |
ff47d11269 | ||
![]() |
7f40887b29 | ||
![]() |
c1a696ee40 | ||
![]() |
b955e0a5dc | ||
![]() |
030a5713e6 | ||
![]() |
a85625977d | ||
![]() |
fd733f52f5 | ||
![]() |
35779eda7a |
@ -232,8 +232,32 @@ _NSIG_TESTS = [
|
|||||||
'W9HJZKktxuYoDTqW', 'jHbbkcaxm54',
|
'W9HJZKktxuYoDTqW', 'jHbbkcaxm54',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'https://www.youtube.com/s/player/91201489/player_ias_tce.vflset/en_US/base.js',
|
'https://www.youtube.com/s/player/643afba4/player_ias.vflset/en_US/base.js',
|
||||||
'W9HJZKktxuYoDTqW', 'U48vOZHaeYS6vO',
|
'W9HJZKktxuYoDTqW', 'larxUlagTRAcSw',
|
||||||
|
),
|
||||||
|
(
|
||||||
|
'https://www.youtube.com/s/player/e7567ecf/player_ias_tce.vflset/en_US/base.js',
|
||||||
|
'Sy4aDGc0VpYRR9ew_', '5UPOT1VhoZxNLQ',
|
||||||
|
),
|
||||||
|
(
|
||||||
|
'https://www.youtube.com/s/player/d50f54ef/player_ias_tce.vflset/en_US/base.js',
|
||||||
|
'Ha7507LzRmH3Utygtj', 'XFTb2HoeOE5MHg',
|
||||||
|
),
|
||||||
|
(
|
||||||
|
'https://www.youtube.com/s/player/074a8365/player_ias_tce.vflset/en_US/base.js',
|
||||||
|
'Ha7507LzRmH3Utygtj', 'ufTsrE0IVYrkl8v',
|
||||||
|
),
|
||||||
|
(
|
||||||
|
'https://www.youtube.com/s/player/643afba4/player_ias.vflset/en_US/base.js',
|
||||||
|
'N5uAlLqm0eg1GyHO', 'dCBQOejdq5s-ww',
|
||||||
|
),
|
||||||
|
(
|
||||||
|
'https://www.youtube.com/s/player/69f581a5/tv-player-ias.vflset/tv-player-ias.js',
|
||||||
|
'-qIP447rVlTTwaZjY', 'KNcGOksBAvwqQg',
|
||||||
|
),
|
||||||
|
(
|
||||||
|
'https://www.youtube.com/s/player/643afba4/tv-player-ias.vflset/tv-player-ias.js',
|
||||||
|
'ir9-V6cdbCiyKxhr', '2PL7ZDYAALMfmA',
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -3,25 +3,38 @@ from __future__ import unicode_literals
|
|||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
|
ExtractorError,
|
||||||
determine_ext,
|
determine_ext,
|
||||||
js_to_json,
|
js_to_json,
|
||||||
)
|
)
|
||||||
|
from ..compat import (
|
||||||
|
compat_b64decode,
|
||||||
|
compat_urllib_parse_unquote,
|
||||||
|
)
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
|
|
||||||
|
def decode_b64_url(code):
|
||||||
|
decoded_url = re.match(r"[^[]*\[([^]]*)\]", code).groups()[0]
|
||||||
|
return compat_b64decode(
|
||||||
|
compat_urllib_parse_unquote(
|
||||||
|
decoded_url.replace('"', '').replace('\'', '').replace(',', ''))).decode('utf-8')
|
||||||
|
|
||||||
|
|
||||||
class RTPIE(InfoExtractor):
|
class RTPIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://(?:www\.)?rtp\.pt/play/p(?P<program_id>[0-9]+)/(?P<id>[^/?#]+)/?'
|
_VALID_URL = r'https?://(?:(?:(?:www\.)?rtp\.pt/play/(?P<subarea>.*/)?p(?P<program_id>[0-9]+)/(?P<episode_id>e[0-9]+/)?)|(?:arquivos\.rtp\.pt/conteudos/))(?P<id>[^/?#]+)/?'
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'http://www.rtp.pt/play/p405/e174042/paixoes-cruzadas',
|
'url': 'https://www.rtp.pt/play/p9165/e562949/por-do-sol',
|
||||||
'md5': 'e736ce0c665e459ddb818546220b4ef8',
|
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': 'e174042',
|
'id': 'por-do-sol',
|
||||||
'ext': 'mp3',
|
'ext': 'mp4',
|
||||||
'title': 'Paixões Cruzadas',
|
'title': 'Pôr do Sol Episódio 1 - de 16 Ago 2021',
|
||||||
'description': 'As paixões musicais de António Cartaxo e António Macedo',
|
'description': 'Madalena Bourbon de Linhaça vive atormentada pelo segredo que esconde desde 1990. Matilde Bourbon de Linhaça sonha fugir com o seu amor proibido. O en',
|
||||||
'thumbnail': r're:^https?://.*\.jpg',
|
'thumbnail': r're:^https?://.*\.jpg',
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
'url': 'http://www.rtp.pt/play/p831/a-quimica-das-coisas',
|
'url': 'https://www.rtp.pt/play/p510/aleixo-fm',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
}]
|
}]
|
||||||
|
|
||||||
@ -29,30 +42,61 @@ class RTPIE(InfoExtractor):
|
|||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
|
|
||||||
webpage = self._download_webpage(url, video_id)
|
webpage = self._download_webpage(url, video_id)
|
||||||
title = self._html_search_meta(
|
|
||||||
'twitter:title', webpage, display_name='title', fatal=True)
|
|
||||||
|
|
||||||
config = self._parse_json(self._search_regex(
|
# Remove JS multi-line comments from webpage source
|
||||||
r'(?s)RTPPlayer\(({.+?})\);', webpage,
|
webpage = re.sub(r'(\/\*.*\*\/)', '', webpage, flags=re.DOTALL)
|
||||||
'player config'), video_id, js_to_json)
|
|
||||||
file_url = config['file']
|
title = self._html_search_regex(r'<title>(.+?)</title>', webpage, 'title')
|
||||||
ext = determine_ext(file_url)
|
|
||||||
if ext == 'm3u8':
|
# Replace irrelevant text in title
|
||||||
file_key = config.get('fileKey')
|
title = title.replace(' - RTP Play - RTP', '')
|
||||||
formats = self._extract_m3u8_formats(
|
|
||||||
file_url, video_id, 'mp4', 'm3u8_native',
|
# Check if it's a video split in parts, if so add part number to title
|
||||||
m3u8_id='hls', fatal=file_key)
|
part = self._html_search_regex(r'section\-parts.*<span.*>(.+?)</span>.*</ul>', webpage, 'part', default=None)
|
||||||
if file_key:
|
if part:
|
||||||
formats.append({
|
title = f'{title} {part}'
|
||||||
'url': 'https://cdn-ondemand.rtp.pt' + file_key,
|
|
||||||
'preference': 1,
|
# Get JS object
|
||||||
})
|
js_object = self._search_regex(r'(?s)RTPPlayer *\( *({.+?}) *\);', webpage, 'player config')
|
||||||
|
json_string_for_config = ''
|
||||||
|
full_url = None
|
||||||
|
|
||||||
|
# Verify JS object since it isn't pure JSON and maybe it needs some tuning
|
||||||
|
for line in js_object.splitlines():
|
||||||
|
stripped_line = line.strip()
|
||||||
|
|
||||||
|
# key == 'fileKey', then we found what we wanted
|
||||||
|
if re.match(r'fileKey:', stripped_line):
|
||||||
|
if re.match(r'fileKey: *""', stripped_line):
|
||||||
|
raise ExtractorError("Episode not found (probably removed)", expected=True)
|
||||||
|
url = decode_b64_url(stripped_line)
|
||||||
|
if 'mp3' in url:
|
||||||
|
full_url = 'https://cdn-ondemand.rtp.pt' + url
|
||||||
|
else:
|
||||||
|
full_url = 'https://streaming-vod.rtp.pt/dash{}/manifest.mpd'.format(url)
|
||||||
|
|
||||||
|
elif not stripped_line.startswith("//") and not re.match('file *:', stripped_line) and not re.match('.*extraSettings ?:', stripped_line):
|
||||||
|
# Ignore commented lines, `extraSettings` and `f`. The latter seems to some random unrelated video.
|
||||||
|
json_string_for_config += '\n' + line
|
||||||
|
|
||||||
|
if not full_url:
|
||||||
|
raise ExtractorError("No valid media source found in page")
|
||||||
|
|
||||||
|
# Finally send pure JSON string for JSON parsing
|
||||||
|
config = self._parse_json(json_string_for_config, video_id, js_to_json)
|
||||||
|
full_url = full_url.replace('drm-dash', 'dash')
|
||||||
|
ext = determine_ext(full_url)
|
||||||
|
|
||||||
|
if ext == 'mpd':
|
||||||
|
# Download via mpd file
|
||||||
|
formats = self._extract_mpd_formats(full_url, video_id)
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
else:
|
else:
|
||||||
formats = [{
|
formats = [{
|
||||||
'url': file_url,
|
'url': full_url,
|
||||||
'ext': ext,
|
'ext': ext,
|
||||||
}]
|
}]
|
||||||
|
|
||||||
if config.get('mediaType') == 'audio':
|
if config.get('mediaType') == 'audio':
|
||||||
for f in formats:
|
for f in formats:
|
||||||
f['vcodec'] = 'none'
|
f['vcodec'] = 'none'
|
||||||
|
@ -91,12 +91,12 @@ class YoutubeBaseInfoExtractor(InfoExtractor):
|
|||||||
'INNERTUBE_CONTEXT': {
|
'INNERTUBE_CONTEXT': {
|
||||||
'client': {
|
'client': {
|
||||||
'clientName': 'IOS',
|
'clientName': 'IOS',
|
||||||
'clientVersion': '19.45.4',
|
'clientVersion': '20.10.4',
|
||||||
'deviceMake': 'Apple',
|
'deviceMake': 'Apple',
|
||||||
'deviceModel': 'iPhone16,2',
|
'deviceModel': 'iPhone16,2',
|
||||||
'userAgent': 'com.google.ios.youtube/19.45.4 (iPhone16,2; U; CPU iOS 18_1_0 like Mac OS X;)',
|
'userAgent': 'com.google.ios.youtube/20.10.4 (iPhone16,2; U; CPU iOS 18_3_2 like Mac OS X;)',
|
||||||
'osName': 'iPhone',
|
'osName': 'iPhone',
|
||||||
'osVersion': '18.1.0.22B83',
|
'osVersion': '18.3.2.22D82',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'INNERTUBE_CONTEXT_CLIENT_NAME': 5,
|
'INNERTUBE_CONTEXT_CLIENT_NAME': 5,
|
||||||
@ -109,7 +109,7 @@ class YoutubeBaseInfoExtractor(InfoExtractor):
|
|||||||
'INNERTUBE_CONTEXT': {
|
'INNERTUBE_CONTEXT': {
|
||||||
'client': {
|
'client': {
|
||||||
'clientName': 'MWEB',
|
'clientName': 'MWEB',
|
||||||
'clientVersion': '2.20241202.07.00',
|
'clientVersion': '2.20250311.03.00',
|
||||||
# mweb previously did not require PO Token with this UA
|
# mweb previously did not require PO Token with this UA
|
||||||
'userAgent': 'Mozilla/5.0 (iPad; CPU OS 16_7_10 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1,gzip(gfe)',
|
'userAgent': 'Mozilla/5.0 (iPad; CPU OS 16_7_10 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1,gzip(gfe)',
|
||||||
},
|
},
|
||||||
@ -122,7 +122,7 @@ class YoutubeBaseInfoExtractor(InfoExtractor):
|
|||||||
'INNERTUBE_CONTEXT': {
|
'INNERTUBE_CONTEXT': {
|
||||||
'client': {
|
'client': {
|
||||||
'clientName': 'TVHTML5',
|
'clientName': 'TVHTML5',
|
||||||
'clientVersion': '7.20250120.19.00',
|
'clientVersion': '7.20250312.16.00',
|
||||||
'userAgent': 'Mozilla/5.0 (ChromiumStylePlatform) Cobalt/Version',
|
'userAgent': 'Mozilla/5.0 (ChromiumStylePlatform) Cobalt/Version',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -133,7 +133,7 @@ class YoutubeBaseInfoExtractor(InfoExtractor):
|
|||||||
'INNERTUBE_CONTEXT': {
|
'INNERTUBE_CONTEXT': {
|
||||||
'client': {
|
'client': {
|
||||||
'clientName': 'WEB',
|
'clientName': 'WEB',
|
||||||
'clientVersion': '2.20241126.01.00',
|
'clientVersion': '2.20250312.04.00',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'INNERTUBE_CONTEXT_CLIENT_NAME': 1,
|
'INNERTUBE_CONTEXT_CLIENT_NAME': 1,
|
||||||
@ -692,7 +692,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
|||||||
'invidious': '|'.join(_INVIDIOUS_SITES),
|
'invidious': '|'.join(_INVIDIOUS_SITES),
|
||||||
}
|
}
|
||||||
_PLAYER_INFO_RE = (
|
_PLAYER_INFO_RE = (
|
||||||
r'/s/player/(?P<id>[a-zA-Z0-9_-]{8,})/player',
|
r'/s/player/(?P<id>[a-zA-Z0-9_-]{8,})//(?:tv-)?player',
|
||||||
r'/(?P<id>[a-zA-Z0-9_-]{8,})/player(?:_ias\.vflset(?:/[a-zA-Z]{2,3}_[a-zA-Z]{2,3})?|-plasma-ias-(?:phone|tablet)-[a-z]{2}_[A-Z]{2}\.vflset)/base\.js$',
|
r'/(?P<id>[a-zA-Z0-9_-]{8,})/player(?:_ias\.vflset(?:/[a-zA-Z]{2,3}_[a-zA-Z]{2,3})?|-plasma-ias-(?:phone|tablet)-[a-z]{2}_[A-Z]{2}\.vflset)/base\.js$',
|
||||||
r'\b(?P<id>vfl[a-zA-Z0-9_-]+)\b.*?\.js$',
|
r'\b(?P<id>vfl[a-zA-Z0-9_-]+)\b.*?\.js$',
|
||||||
)
|
)
|
||||||
@ -1857,7 +1857,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
|||||||
def _extract_n_function_code_jsi(self, video_id, jsi, player_id=None):
|
def _extract_n_function_code_jsi(self, video_id, jsi, player_id=None):
|
||||||
|
|
||||||
var_ay = self._search_regex(
|
var_ay = self._search_regex(
|
||||||
r'(?:[;\s]|^)\s*(var\s*[\w$]+\s*=\s*"[^"]+"\s*\.\s*split\("\{"\))(?=\s*[,;])',
|
r'(?:[;\s]|^)\s*(var\s*[\w$]+\s*=\s*"(?:\\"|[^"])+"\s*\.\s*split\("\W+"\))(?=\s*[,;])',
|
||||||
jsi.code, 'useful values', default='')
|
jsi.code, 'useful values', default='')
|
||||||
|
|
||||||
func_name = self._extract_n_function_name(jsi.code)
|
func_name = self._extract_n_function_name(jsi.code)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user