Compare commits

...

8 Commits

Author SHA1 Message Date
Aiur Adept
06bbdeb317
Merge 29e60290cfc508f7823b9191d2a2a124128e9876 into da7223d4aa42ff9fc680b0951d043dd03cec2d30 2025-03-21 20:37:20 +01:00
dirkf
da7223d4aa [YouTube] Improve support for tce-style player JS
* improve extraction of global "useful data" Array from player JS
* also handle tv-player and add tests: thx seproDev (yt-dlp/yt-dlp#12684)

Co-Authored-By: sepro <sepro@sepr0.com>
2025-03-21 16:26:25 +00:00
dirkf
37c2440d6a [YouTube] Update player client data
thx seproDev (yt-dlp/yt-dlp#12603)

Co-authored-by: sepro <sepro@sepr0.com>
2025-03-21 16:13:24 +00:00
nicole trinity
29e60290cf extract mpd for single video 2024-08-01 11:33:20 -04:00
nicole trinity
2e31ae21dd sort formats before return 2024-07-30 10:03:41 -04:00
nicole trinity
8b8d196f65 flake8 fixes for la1ere extractor 2024-07-29 16:31:08 -04:00
nicole trinity
d933a0ef76 skip tests for la1ere extractor as its only available in FR 2024-07-29 16:29:12 -04:00
nicole trinity
c346035bdf basic working la1ere extractor 2024-07-29 16:27:34 -04:00
4 changed files with 125 additions and 10 deletions

View File

@ -232,8 +232,32 @@ _NSIG_TESTS = [
'W9HJZKktxuYoDTqW', 'jHbbkcaxm54',
),
(
'https://www.youtube.com/s/player/91201489/player_ias_tce.vflset/en_US/base.js',
'W9HJZKktxuYoDTqW', 'U48vOZHaeYS6vO',
'https://www.youtube.com/s/player/643afba4/player_ias.vflset/en_US/base.js',
'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',
),
]

View File

@ -585,6 +585,7 @@ from .kuwo import (
KuwoCategoryIE,
KuwoMvIE,
)
from .la1ere import La1ereExtractorPageIE, La1ereExtractorShowPageIE
from .la7 import LA7IE
from .laola1tv import (
Laola1TvEmbedIE,

View File

@ -0,0 +1,90 @@
# coding: utf-8
from __future__ import unicode_literals
from urllib.parse import quote
from .common import InfoExtractor
class La1ereExrtractorBaseIE(InfoExtractor):
def _extract_given_title(self, webpage, title):
# get the ID
video_id = self._html_search_regex(r'data-id="([^"]+)"', webpage, 'id')
# request the mpd-request url
json_request_url = 'https://k7.ftven.fr/videos/%s?country_code=FR&w=937&h=527&screen_w=1920&screen_h=1200&player_version=5.116.1&domain=la1ere.francetvinfo.fr&device_type=desktop&browser=chrome&browser_version=126&os=linux&diffusion_mode=tunnel&gmt=-0400&capabilities=drm' % video_id
json_request = self._download_json(json_request_url, video_id)
mpd_request_url = json_request['video']['url']
# using the mpd-request url, auth to get the full mpd URL with auth params
auth_request_url = 'https://hdfauth.ftven.fr/esi/TA?format=json&url=%s' % quote(mpd_request_url)
auth_request = self._download_json(auth_request_url, video_id)
# this is the full playlist URL with auth params
playlist_url = auth_request['url']
return video_id, playlist_url
class La1ereExtractorPageIE(La1ereExrtractorBaseIE):
_VALID_URL = r'https://la1ere.francetvinfo.fr/(?P<region>[^/]+)/programme-video/diffusion/(?P<page>[^\.]+).html'
_TEST = {
'skip': 'Only available in FR',
'url': 'https://la1ere.francetvinfo.fr/martinique/programme-video/diffusion/4774522-origine-kongo.html',
'info_dict': {
'ext': 'mp4',
'title': 'Origine Kongo',
}
}
def _real_extract(self, url):
webpage = self._download_webpage(url, 'la1ere')
title = self._html_search_regex(r'<h1 .*title.*>(.+?)</h1>', webpage, 'title')
video_id, playlist_url = self._extract_given_title(webpage, title)
# get the mpd playlist
formats = self._extract_mpd_formats(playlist_url, video_id)
self._sort_formats(formats)
return {
'id': video_id,
'title': title,
'formats': formats,
}
class La1ereExtractorShowPageIE(La1ereExrtractorBaseIE):
_VALID_URL = r'https://la1ere.francetvinfo.fr/(?P<region>[^/]+)/programme-video/(?P<show>[^/]+)/diffusion/(?P<page>[^\.]+).html'
_TEST = {
'skip': 'Only available in FR',
'url': 'https://la1ere.francetvinfo.fr/guadeloupe/programme-video/la1ere_guadeloupe_le-13h-en-guadeloupe/diffusion/5643549-emission-du-lundi-29-janvier-2024.html',
'info_dict': {
'ext': 'mp4',
'title': '13H en Guadeloupe - Émission du lundi 29 janvier 2024',
}
}
def _real_extract(self, url):
webpage = self._download_webpage(url, 'la1ere')
series_name = self._html_search_regex(r'<span class="m-dtv-player-title__subtitle">(.+?)</span>', webpage, 'series_name')
episode_name = self._html_search_regex(r'<h1 .*title.*>(.+?)</h1>', webpage, 'episode_name')
title = f'{series_name} - {episode_name}'
video_id, playlist_url = self._extract_given_title(webpage, title)
# get the m3u8 playlist
formats = self._extract_m3u8_formats(playlist_url, video_id)
self._sort_formats(formats)
return {
'id': video_id,
'title': title,
'formats': formats,
}

View File

@ -91,12 +91,12 @@ class YoutubeBaseInfoExtractor(InfoExtractor):
'INNERTUBE_CONTEXT': {
'client': {
'clientName': 'IOS',
'clientVersion': '19.45.4',
'clientVersion': '20.10.4',
'deviceMake': 'Apple',
'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',
'osVersion': '18.1.0.22B83',
'osVersion': '18.3.2.22D82',
},
},
'INNERTUBE_CONTEXT_CLIENT_NAME': 5,
@ -109,7 +109,7 @@ class YoutubeBaseInfoExtractor(InfoExtractor):
'INNERTUBE_CONTEXT': {
'client': {
'clientName': 'MWEB',
'clientVersion': '2.20241202.07.00',
'clientVersion': '2.20250311.03.00',
# 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)',
},
@ -122,7 +122,7 @@ class YoutubeBaseInfoExtractor(InfoExtractor):
'INNERTUBE_CONTEXT': {
'client': {
'clientName': 'TVHTML5',
'clientVersion': '7.20250120.19.00',
'clientVersion': '7.20250312.16.00',
'userAgent': 'Mozilla/5.0 (ChromiumStylePlatform) Cobalt/Version',
},
},
@ -133,7 +133,7 @@ class YoutubeBaseInfoExtractor(InfoExtractor):
'INNERTUBE_CONTEXT': {
'client': {
'clientName': 'WEB',
'clientVersion': '2.20241126.01.00',
'clientVersion': '2.20250312.04.00',
},
},
'INNERTUBE_CONTEXT_CLIENT_NAME': 1,
@ -692,7 +692,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
'invidious': '|'.join(_INVIDIOUS_SITES),
}
_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'\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):
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='')
func_name = self._extract_n_function_name(jsi.code)