mirror of
https://github.com/yt-dlp/yt-dlp
synced 2024-12-26 21:59:08 +01:00
Cleanup
This commit is contained in:
parent
7c0f6d7836
commit
07e7a402bb
2 changed files with 35 additions and 73 deletions
|
@ -1534,7 +1534,6 @@ from .pinterest import (
|
||||||
)
|
)
|
||||||
from .piramidetv import (
|
from .piramidetv import (
|
||||||
PiramideTVChannelIE,
|
PiramideTVChannelIE,
|
||||||
PiramideTVChannelURLIE,
|
|
||||||
PiramideTVIE,
|
PiramideTVIE,
|
||||||
)
|
)
|
||||||
from .pixivsketch import (
|
from .pixivsketch import (
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
from .common import InfoExtractor, SearchInfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import parse_iso8601, url_or_none
|
||||||
traverse_obj,
|
from ..utils.traversal import traverse_obj
|
||||||
unified_timestamp,
|
|
||||||
url_or_none,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class PiramideTVIE(InfoExtractor):
|
class PiramideTVIE(InfoExtractor):
|
||||||
|
@ -25,89 +22,55 @@ class PiramideTVIE(InfoExtractor):
|
||||||
'url': 'https://piramide.tv/video/wcYn6li79NgN',
|
'url': 'https://piramide.tv/video/wcYn6li79NgN',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': 'wcYn6li79NgN',
|
'id': 'wcYn6li79NgN',
|
||||||
|
'ext': 'mp4',
|
||||||
'title': 'ACEPTO TENER UN BEBE CON MI NOVIA\u2026? | Parte 1',
|
'title': 'ACEPTO TENER UN BEBE CON MI NOVIA\u2026? | Parte 1',
|
||||||
'description': '',
|
'description': '',
|
||||||
'channel': 'ARTA GAME',
|
'channel': 'ARTA GAME',
|
||||||
'channel_id': 'arta_game',
|
'channel_id': 'arta_game',
|
||||||
|
'thumbnail': 'https://cdn.jwplayer.com/v2/media/cnEdGp5X/thumbnails/rHAaWfP7.jpg',
|
||||||
|
'timestamp': 1703434976,
|
||||||
|
'upload_date': '20231224',
|
||||||
},
|
},
|
||||||
'playlist_count': 4,
|
|
||||||
}]
|
}]
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
def extract_video(video_id, fatal=False):
|
|
||||||
video_data = self._download_json(f'https://hermes.piramide.tv/video/data/{video_id}',
|
|
||||||
video_id, fatal=fatal)
|
|
||||||
formats, subtitles = self._extract_m3u8_formats_and_subtitles(
|
|
||||||
f'https://cdn.piramide.tv/video/{video_id}/manifest.m3u8', video_id, fatal=fatal)
|
|
||||||
video_info = {**traverse_obj(video_data, {
|
|
||||||
'id': ('video', 'id', {str}),
|
|
||||||
'title': ('video', 'title', {str}),
|
|
||||||
'description': ('video', 'description', {str}),
|
|
||||||
'thumbnail': ('video', 'media', 'thumbnail', {url_or_none}),
|
|
||||||
'channel': ('video', 'channel', 'name', {str}),
|
|
||||||
'channel_id': ('video', 'channel', 'id', {str}),
|
|
||||||
'timestamp': ('video', 'date', {unified_timestamp}),
|
|
||||||
}),
|
|
||||||
'formats': formats,
|
|
||||||
'subtitles': subtitles,
|
|
||||||
'webpage_url': f'https://piramide.tv/video/{video_id}',
|
|
||||||
'webpage_url_basename': video_id,
|
|
||||||
}
|
|
||||||
next_video_id = traverse_obj(video_data, ('video', 'next_video', 'id', {str}))
|
|
||||||
return video_info, next_video_id
|
|
||||||
|
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
entries = []
|
video_data = self._download_json(
|
||||||
while video_id is not None:
|
f'https://hermes.piramide.tv/video/data/{video_id}', video_id, fatal=False)
|
||||||
video, next_video = extract_video(video_id, (not entries))
|
formats, subtitles = self._extract_m3u8_formats_and_subtitles(
|
||||||
if video.get('formats'):
|
f'https://cdn.piramide.tv/video/{video_id}/manifest.m3u8', video_id, fatal=False)
|
||||||
entries.append(video)
|
return {
|
||||||
video_id = next_video if next_video != video_id else None
|
'id': video_id,
|
||||||
|
'formats': formats,
|
||||||
if len(entries) == 1:
|
'subtitles': subtitles,
|
||||||
return entries[0]
|
**traverse_obj(video_data, ('video', {
|
||||||
elif len(entries) > 1:
|
'id': ('id', {str}),
|
||||||
return self.playlist_result(entries, **traverse_obj(entries[0], {
|
'title': ('title', {str}),
|
||||||
'id': ('id'),
|
'description': ('description', {str}),
|
||||||
'title': ('title'),
|
'thumbnail': ('media', 'thumbnail', {url_or_none}),
|
||||||
'description': ('description'),
|
'channel': ('channel', 'name', {str}),
|
||||||
'channel': ('channel'),
|
'channel_id': ('channel', 'id', {str}),
|
||||||
'channel_id': ('channel_id'),
|
'timestamp': ('date', {parse_iso8601}),
|
||||||
}))
|
})),
|
||||||
else:
|
}
|
||||||
return {'id': video_id}
|
|
||||||
|
|
||||||
|
|
||||||
class PiramideTVChannelURLIE(InfoExtractor):
|
class PiramideTVChannelIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://piramide\.tv/channel/(?P<id>[\w-]+)'
|
_VALID_URL = r'https?://piramide\.tv/channel/(?P<id>[\w-]+)'
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'https://piramide.tv/channel/thekalo',
|
'url': 'https://piramide.tv/channel/thekalo',
|
||||||
'playlist_count': 10,
|
'playlist_mincount': 10,
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': 'thekalo',
|
'id': 'thekalo',
|
||||||
'title': 'thekalo',
|
|
||||||
},
|
},
|
||||||
}]
|
}]
|
||||||
|
|
||||||
|
def _entries(self, channel_name):
|
||||||
|
videos = self._download_json(
|
||||||
|
f'https://hermes.piramide.tv/channel/list/{channel_name}/date/100000', channel_name)
|
||||||
|
for video_id in traverse_obj(videos, ('videos', ..., 'id', {str})):
|
||||||
|
yield self.url_result(f'https://piramide.tv/video/{video_id}')
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
if query := self._match_id(url):
|
channel_name = self._match_id(url)
|
||||||
return self.url_result(url=f'piramidetvall:{query}', url_transparent=True)
|
return self.playlist_result(self._entries(channel_name), channel_name)
|
||||||
|
|
||||||
|
|
||||||
class PiramideTVChannelIE(SearchInfoExtractor):
|
|
||||||
IE_NAME = 'PiramideTV:channel'
|
|
||||||
_SEARCH_KEY = 'piramidetv'
|
|
||||||
_TESTS = [{
|
|
||||||
'url': 'piramidetv5:bobicraft',
|
|
||||||
'playlist_count': 5,
|
|
||||||
'info_dict': {
|
|
||||||
'id': 'bobicraft',
|
|
||||||
'title': 'bobicraft',
|
|
||||||
},
|
|
||||||
}]
|
|
||||||
|
|
||||||
def _search_results(self, query):
|
|
||||||
videos = self._download_json(f'https://hermes.piramide.tv/channel/list/{query}/date/100000', query)
|
|
||||||
for video in videos.get('videos'):
|
|
||||||
if video_id := video.get('id'):
|
|
||||||
yield self.url_result(f'https://piramide.tv/video/{video_id}')
|
|
||||||
|
|
Loading…
Reference in a new issue