Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from yt_dlp.extractor.common import InfoExtractor
- from datetime import datetime
- class PomfLiveIE(InfoExtractor):
- _VALID_URL = r'https?://(?:www\.)?pomf\.tv/stream/(?P<uploader>[^/]+)'
- def _real_extract(self, url):
- match = self._match_valid_url(url)
- uploader = match.group('uploader')
- channel = self._download_json(f"https://pomf.tv/api/streams/getinfo.php?data=streamdata&stream={uploader}", uploader)
- live = bool(channel.get('stream_online'))
- if not live:
- raise Exception(f"{uploader} is not live!")
- webpage = self._download_webpage(url, uploader)
- channel_id = self._search_regex(r'window\.players\["_(?P<channel_id>[0-9a-f]+)"', webpage, 'channel_id')
- video_id = int(datetime.now().timestamp())
- formats = [
- { 'url': f"https://eu1.pomf.tv/hls-live/{channel_id}_lq/index.m3u8", 'ext': 'mp4', 'vcodec': 'h264', 'acodec': 'AAC', 'width': 480, 'height': 270},
- { 'url': f"https://eu1.pomf.tv/hls-live/{channel_id}_mq/index.m3u8", 'ext': 'mp4', 'vcodec': 'h264', 'acodec': 'AAC', 'width': 720, 'height': 404},
- { 'url': f"https://eu1.pomf.tv/hls-live/{channel_id}_hd720/index.m3u8", 'ext': 'mp4', 'vcodec': 'h264', 'acodec': 'AAC', 'width': 1280, 'height': 720},
- { 'url': f"https://eu1.pomf.tv/srs/live/{channel_id}.flv", 'vcodec': 'h264', 'acodec': 'AAC', 'width': 1920, 'height': 1080},
- ]
- return {
- 'is_live': True,
- 'id': str(video_id),
- 'title': channel.get('streamtitle'),
- 'uploader': uploader,
- 'formats': formats,
- }
Advertisement
Add Comment
Please, Sign In to add comment