mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-08-15 08:58:28 +00:00
Double quotes fixed
This commit is contained in:
parent
9ca66dec4d
commit
70a45aa336
@ -5,114 +5,115 @@
|
|||||||
|
|
||||||
|
|
||||||
class SmotrimIE(InfoExtractor):
|
class SmotrimIE(InfoExtractor):
|
||||||
_VALID_URL = r"https?://smotrim\.ru/(?P<type>brand|video|article|live|channel)/(?P<id>[0-9]+)"
|
_VALID_URL = r'https?://smotrim\.ru/(?P<type>brand|video|article|live|channel)/(?P<id>[0-9]+)'
|
||||||
_TESTS = [
|
_TESTS = [
|
||||||
{
|
{
|
||||||
"url": "https://smotrim.ru/video/3003613",
|
'url': 'https://smotrim.ru/video/3003613',
|
||||||
"info_dict": {
|
'info_dict': {
|
||||||
"id": "3003613",
|
'id': '3003613',
|
||||||
"ext": "mp4",
|
'ext': 'mp4',
|
||||||
"title": "Погода. на 2 августа 2025 года",
|
'title': 'Погода. на 2 августа 2025 года',
|
||||||
"thumbnail": "https://cdn-st2.smotrim.ru/vh/pictures/xw/635/545/7.jpg",
|
'thumbnail': 'https://cdn-st2.smotrim.ru/vh/pictures/xw/635/545/7.jpg',
|
||||||
},
|
},
|
||||||
"add_ie": ["RUTV"],
|
'add_ie': ['RUTV'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"url": "https://smotrim.ru/article/4609632",
|
'url': 'https://smotrim.ru/article/4609632',
|
||||||
"info_dict": {
|
'info_dict': {
|
||||||
"id": "3000761",
|
'id': '3000761',
|
||||||
"ext": "mp4",
|
'ext': 'mp4',
|
||||||
"title": "Новости культуры. Ольга Любимова провела рабочую встречу в Еврейской автономной области",
|
'title': 'Новости культуры. Ольга Любимова провела рабочую встречу в Еврейской автономной области',
|
||||||
"thumbnail": "https://cdn-st2.smotrim.ru/vh/pictures/xw/638/386/6.jpg",
|
'thumbnail': 'https://cdn-st2.smotrim.ru/vh/pictures/xw/638/386/6.jpg',
|
||||||
},
|
},
|
||||||
"add_ie": ["RUTV"],
|
'add_ie': ['RUTV'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"url": "https://smotrim.ru/brand/64356",
|
'url': 'https://smotrim.ru/brand/64356',
|
||||||
"info_dict": {
|
'info_dict': {
|
||||||
"id": "2885093",
|
'id': '2885093',
|
||||||
"ext": "mp4",
|
'ext': 'mp4',
|
||||||
"title": "Большие и маленькие. 6-й сезон 8-й выпуск",
|
'title': 'Большие и маленькие. 6-й сезон 8-й выпуск',
|
||||||
"thumbnail": "https://cdn-st2.smotrim.ru/vh/pictures/xw/527/187/3.jpg",
|
'thumbnail': 'https://cdn-st2.smotrim.ru/vh/pictures/xw/527/187/3.jpg',
|
||||||
},
|
},
|
||||||
"add_ie": ["RUTV"],
|
'add_ie': ['RUTV'],
|
||||||
},
|
},
|
||||||
{ # GEO RESTRICTED
|
{ # GEO RESTRICTED
|
||||||
"url": "https://smotrim.ru/live/19201",
|
'url': 'https://smotrim.ru/live/19201',
|
||||||
"info_dict": {
|
'info_dict': {
|
||||||
"id": "381308c7-a066-4c4f-9656-83e2e792a7b4",
|
'id': '381308c7-a066-4c4f-9656-83e2e792a7b4',
|
||||||
"ext": "mp4",
|
'ext': 'mp4',
|
||||||
"title": "Россия К",
|
'title': 'Россия К',
|
||||||
"thumbnail": "https://cdn-st2.smotrim.ru/vh/pictures/xw/441/085/7.png",
|
'thumbnail': 'https://cdn-st2.smotrim.ru/vh/pictures/xw/441/085/7.png',
|
||||||
},
|
},
|
||||||
"add_ie": ["RUTV"],
|
'add_ie': ['RUTV'],
|
||||||
},
|
},
|
||||||
{ # GEO RESTRICTED, REDIRECT FROM live, CANONICAL FOR live urls
|
{ # GEO RESTRICTED, REDIRECT FROM live, CANONICAL FOR live urls
|
||||||
"url": "https://smotrim.ru/channel/4",
|
'url': 'https://smotrim.ru/channel/4',
|
||||||
"info_dict": {
|
'info_dict': {
|
||||||
"id": "4",
|
'id': '4',
|
||||||
"ext": "mp4",
|
'ext': 'mp4',
|
||||||
"title": "Россия К",
|
'title': 'Россия К',
|
||||||
"thumbnail": "https://cdn-st2.smotrim.ru/vh/pictures/xw/441/085/7.png",
|
'thumbnail': 'https://cdn-st2.smotrim.ru/vh/pictures/xw/441/085/7.png',
|
||||||
},
|
},
|
||||||
"add_ie": ["RUTV"],
|
'add_ie': ['RUTV'],
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id, type = self._match_valid_url(url).group("id", "type")
|
video_id, type = self._match_valid_url(url).group('id', 'type')
|
||||||
webpage = self._download_webpage(url, video_id, f"Resolving {type} link")
|
webpage = self._download_webpage(url, video_id, f'Resolving {type} link')
|
||||||
iframe_url = self._search_regex(
|
iframe_url = self._search_regex(
|
||||||
r'<iframe\b[^>]+\bsrc=["\'](https?://player\.smotrim\.ru/iframe/[^"\']+)',
|
r'<iframe\b[^>]+\bsrc=["\'](https?://player\.smotrim\.ru/iframe/[^"\']+)',
|
||||||
webpage,
|
webpage,
|
||||||
"iframe URL",
|
'iframe URL',
|
||||||
)
|
)
|
||||||
if type in {"live", "channel"}:
|
if type in {'live', 'channel'}:
|
||||||
# iframe_url = "https://player.smotrim.ru/iframe/live/uid/381308c7-a066-4c4f-9656-83e2e792a7b4/showZoomBtn/false/isPlay/true/mute/true/sid/smotrim_rk/"
|
# iframe_url = 'https://player.smotrim.ru/iframe/live/uid/381308c7-a066-4c4f-9656-83e2e792a7b4/showZoomBtn/false/isPlay/true/mute/true/sid/smotrim_rk/'
|
||||||
video_id = re.search(
|
video_id = re.search(
|
||||||
r"(?P<video_id>[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})",
|
r'(?P<video_id>[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})',
|
||||||
iframe_url,
|
iframe_url,
|
||||||
)
|
)
|
||||||
if not video_id:
|
if not video_id:
|
||||||
raise ExtractorError(
|
raise ExtractorError(
|
||||||
"There are no player uuid in this page.", expected=True
|
'There are no player uuid in this page.', expected=True
|
||||||
)
|
)
|
||||||
video_id = video_id.group("video_id")
|
video_id = video_id.group('video_id')
|
||||||
jsondata_url = (
|
jsondata_url = (
|
||||||
f"https://player.smotrim.ru/iframe/datalive/uid/{video_id}/sid/smotrim"
|
f'https://player.smotrim.ru/iframe/datalive/uid/{video_id}/sid/smotrim'
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
# iframe_url = "https://player.smotrim.ru/iframe/video/id/3000761/sid/smotrim/isPlay/true/mute/true/?acc_video_id=3204061"
|
# iframe_url = 'https://player.smotrim.ru/iframe/video/id/3000761/sid/smotrim/isPlay/true/mute/true/?acc_video_id=3204061'
|
||||||
video_id = re.search(
|
video_id = re.search(
|
||||||
r"^https?://player\.smotrim\.ru/iframe/video/id/(?P<video_id>\d+)/sid/",
|
r'^https?://player\.smotrim\.ru/iframe/video/id/(?P<video_id>\d+)/sid/',
|
||||||
iframe_url,
|
iframe_url,
|
||||||
)
|
)
|
||||||
if not video_id:
|
if not video_id:
|
||||||
raise ExtractorError(
|
raise ExtractorError(
|
||||||
"There are no player id in this page.", expected=True
|
'There are no player id in this page.', expected=True
|
||||||
)
|
)
|
||||||
video_id = video_id.group("video_id")
|
video_id = video_id.group('video_id')
|
||||||
jsondata_url = (
|
jsondata_url = (
|
||||||
f"https://player.smotrim.ru/iframe/datavideo/id/{video_id}/sid/smotrim"
|
f'https://player.smotrim.ru/iframe/datavideo/id/{video_id}/sid/smotrim'
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
json_info = self._download_json(
|
json_info = self._download_json(
|
||||||
jsondata_url, video_id, "Downloading player config JSON metadata"
|
jsondata_url, video_id, 'Downloading player config JSON metadata'
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise ExtractorError(str(e), expected=True)
|
raise ExtractorError(str(e), expected=True)
|
||||||
m3u8_url = json_info["data"]["playlist"]["medialist"][0]["sources"]["m3u8"][
|
m3u8_url = json_info['data']['playlist']['medialist'][0]['sources']['m3u8'][
|
||||||
"auto"
|
'auto'
|
||||||
]
|
]
|
||||||
formats, subtitles = self._extract_m3u8_formats_and_subtitles(
|
formats, subtitles = self._extract_m3u8_formats_and_subtitles(
|
||||||
m3u8_url, video_id, "mp4", m3u8_id="hls"
|
m3u8_url, video_id, 'mp4', m3u8_id='hls'
|
||||||
)
|
)
|
||||||
return {
|
return {
|
||||||
"id": video_id,
|
'id': video_id,
|
||||||
"title": json_info["data"]["playlist"]["medialist"][0]["title"],
|
'title': json_info['data']['playlist']['medialist'][0]['title'],
|
||||||
"thumbnail": json_info["data"]["playlist"]["medialist"][0]["pictures"][
|
'thumbnail': json_info['data']['playlist']['medialist'][0]['pictures'][
|
||||||
"16:9"
|
'16:9'
|
||||||
],
|
],
|
||||||
"formats": formats,
|
'formats': formats,
|
||||||
"subtitles": subtitles,
|
'subtitles': subtitles,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user