Guest User

Untitled

a guest
Apr 15th, 2024
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.64 KB | None | 0 0
  1. from yt_dlp.extractor.common import InfoExtractor
  2. from datetime import datetime
  3.  
  4. class PomfLiveIE(InfoExtractor):
  5.     _VALID_URL = r'https?://(?:www\.)?pomf\.tv/stream/(?P<uploader>[^/]+)'
  6.  
  7.     def _real_extract(self, url):
  8.         match = self._match_valid_url(url)
  9.         uploader = match.group('uploader')
  10.         channel = self._download_json(f"https://pomf.tv/api/streams/getinfo.php?data=streamdata&stream={uploader}", uploader)
  11.         live = bool(channel.get('stream_online'))
  12.  
  13.         if not live:
  14.             raise Exception(f"{uploader} is not live!")
  15.  
  16.         webpage = self._download_webpage(url, uploader)
  17.         channel_id = self._search_regex(r'window\.players\["_(?P<channel_id>[0-9a-f]+)"', webpage, 'channel_id')
  18.         video_id = int(datetime.now().timestamp())
  19.  
  20.         formats = [
  21.             { 'url': f"https://eu1.pomf.tv/hls-live/{channel_id}_lq/index.m3u8", 'ext': 'mp4', 'vcodec': 'h264', 'acodec': 'AAC', 'width': 480, 'height': 270},
  22.             { 'url': f"https://eu1.pomf.tv/hls-live/{channel_id}_mq/index.m3u8", 'ext': 'mp4', 'vcodec': 'h264', 'acodec': 'AAC', 'width': 720, 'height': 404},
  23.             { 'url': f"https://eu1.pomf.tv/hls-live/{channel_id}_hd720/index.m3u8", 'ext': 'mp4', 'vcodec': 'h264', 'acodec': 'AAC', 'width': 1280, 'height': 720},
  24.             { 'url': f"https://eu1.pomf.tv/srs/live/{channel_id}.flv", 'vcodec': 'h264', 'acodec': 'AAC', 'width': 1920, 'height': 1080},
  25.         ]
  26.  
  27.         return {
  28.             'is_live': True,
  29.             'id': str(video_id),
  30.             'title': channel.get('streamtitle'),
  31.             'uploader': uploader,
  32.             'formats': formats,
  33.         }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment