Skip to content

Commit

Permalink
Update piramidetv.py
Browse files Browse the repository at this point in the history
  • Loading branch information
kclauhk committed Jan 16, 2025
1 parent 1be3d71 commit f407f5f
Showing 1 changed file with 27 additions and 32 deletions.
59 changes: 27 additions & 32 deletions yt_dlp/extractor/piramidetv.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,25 @@ class PiramideTVIE(InfoExtractor):
}]

def _extract_video(self, video_id):
if video_data := self._download_json(
f'https://hermes.piramide.tv/video/data/{video_id}', video_id, fatal=False):
formats, subtitles = self._extract_m3u8_formats_and_subtitles(
f'https://cdn.piramide.tv/video/{video_id}/manifest.m3u8', video_id, fatal=False)
next_video = traverse_obj(video_data, ('video', 'next_video', 'id', {str}))
return next_video, {
'id': video_id,
'formats': formats,
'subtitles': subtitles,
'webpage_url': f'https://piramide.tv/video/{video_id}',
'original_url': f'https://piramide.tv/video/{video_id}',
**traverse_obj(video_data, ('video', {
'id': ('id', {str}),
'title': ('title', {str}),
'description': ('description', {str}),
'thumbnail': ('media', 'thumbnail', {url_or_none}),
'channel': ('channel', 'name', {str}),
'channel_id': ('channel', 'id', {str}),
'timestamp': ('date', {parse_iso8601}),
})),
}
return None, {'id': video_id}
video_data = self._download_json(
f'https://hermes.piramide.tv/video/data/{video_id}', video_id, fatal=False)
formats, subtitles = self._extract_m3u8_formats_and_subtitles(
f'https://cdn.piramide.tv/video/{video_id}/manifest.m3u8', video_id, fatal=False)
next_video = traverse_obj(video_data, ('video', 'next_video', 'id', {str}))
return next_video, {
'id': video_id,
'formats': formats,
'subtitles': subtitles,
**traverse_obj(video_data, ('video', {
'id': ('id', {str}),
'title': ('title', {str}),
'description': ('description', {str}),
'thumbnail': ('media', 'thumbnail', {url_or_none}),
'channel': ('channel', 'name', {str}),
'channel_id': ('channel', 'id', {str}),
'timestamp': ('date', {parse_iso8601}),
})),
}

def _entries(self, video_id):
visited = set()
Expand Down Expand Up @@ -88,16 +85,14 @@ class PiramideTVChannelIE(InfoExtractor):
def _entries(self, channel_name):
videos = self._download_json(
f'https://hermes.piramide.tv/channel/list/{channel_name}/date/100000', channel_name)
for video in videos.get('videos', []):
if video_id := video.get('id'):
yield self.url_result(smuggle_url(
f'https://piramide.tv/video/{video_id}', {'force_noplaylist': True}),
**traverse_obj(video, {
'id': ('id', {str}),
'title': ('title', {str}),
'description': ('description', {str}),
'webpage_url': ('id', {str}, {lambda v: f'https://piramide.tv/video/{v}'}),
}))
for video in traverse_obj(videos, ('videos', lambda _, v: v['id'])):
yield self.url_result(smuggle_url(
f'https://piramide.tv/video/{video['id']}', {'force_noplaylist': True}),
**traverse_obj(video, {
'id': ('id', {str}),
'title': ('title', {str}),
'description': ('description', {str}),
}))

def _real_extract(self, url):
channel_name = self._match_id(url)
Expand Down

0 comments on commit f407f5f

Please sign in to comment.