repo
stringlengths
7
90
file_url
stringlengths
81
315
file_path
stringlengths
4
228
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 14:38:15
2026-01-05 02:33:18
truncated
bool
2 classes
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/c56.py
youtube_dl/extractor/c56.py
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import js_to_json class C56IE(InfoExtractor): _VALID_URL = r'https?://(?:(?:www|player)\.)?56\.com/(?:.+?/)?(?:v_|(?:play_album.+-))(?P<textid>.+?)\.(?:html|swf)' IE_NAME = '56.com' _TESTS = [{ 'url': 'http://www.56.com/u39/v_OTM0NDA3MTY.html', 'md5': 'e59995ac63d0457783ea05f93f12a866', 'info_dict': { 'id': '93440716', 'ext': 'flv', 'title': '网事知多少 第32期:车怒', 'duration': 283.813, }, }, { 'url': 'http://www.56.com/u47/v_MTM5NjQ5ODc2.html', 'md5': '', 'info_dict': { 'id': '82247482', 'title': '爱的诅咒之杜鹃花开', }, 'playlist_count': 7, 'add_ie': ['Sohu'], }] def _real_extract(self, url): mobj = re.match(self._VALID_URL, url, flags=re.VERBOSE) text_id = mobj.group('textid') webpage = self._download_webpage(url, text_id) sohu_video_info_str = self._search_regex( r'var\s+sohuVideoInfo\s*=\s*({[^}]+});', webpage, 'Sohu video info', default=None) if sohu_video_info_str: sohu_video_info = self._parse_json( sohu_video_info_str, text_id, transform_source=js_to_json) return self.url_result(sohu_video_info['url'], 'Sohu') page = self._download_json( 'http://vxml.56.com/json/%s/' % text_id, text_id, 'Downloading video info') info = page['info'] formats = [ { 'format_id': f['type'], 'filesize': int(f['filesize']), 'url': f['url'] } for f in info['rfiles'] ] self._sort_formats(formats) return { 'id': info['vid'], 'title': info['Subject'], 'duration': int(info['duration']) / 1000.0, 'formats': formats, 'thumbnail': info.get('bimg') or info.get('img'), }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/nhk.py
youtube_dl/extractor/nhk.py
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import urljoin class NhkBaseIE(InfoExtractor): _API_URL_TEMPLATE = 'https://nwapi.nhk.jp/nhkworld/%sod%slist/v7b/%s/%s/%s/all%s.json' _BASE_URL_REGEX = r'https?://www3\.nhk\.or\.jp/nhkworld/(?P<lang>[a-z]{2})/ondemand' _TYPE_REGEX = r'/(?P<type>video|audio)/' def _call_api(self, m_id, lang, is_video, is_episode, is_clip): return self._download_json( self._API_URL_TEMPLATE % ( 'v' if is_video else 'r', 'clip' if is_clip else 'esd', 'episode' if is_episode else 'program', m_id, lang, '/all' if is_video else ''), m_id, query={'apikey': 'EJfK8jdS57GqlupFgAfAAwr573q01y6k'})['data']['episodes'] or [] def _extract_episode_info(self, url, episode=None): fetch_episode = episode is None lang, m_type, episode_id = re.match(NhkVodIE._VALID_URL, url).groups() if len(episode_id) == 7: episode_id = episode_id[:4] + '-' + episode_id[4:] is_video = m_type == 'video' if fetch_episode: episode = self._call_api( episode_id, lang, is_video, True, episode_id[:4] == '9999')[0] title = episode.get('sub_title_clean') or episode['sub_title'] def get_clean_field(key): return episode.get(key + '_clean') or episode.get(key) series = get_clean_field('title') thumbnails = [] for s, w, h in [('', 640, 360), ('_l', 1280, 720)]: img_path = episode.get('image' + s) if not img_path: continue thumbnails.append({ 'id': '%dp' % h, 'height': h, 'width': w, 'url': 'https://www3.nhk.or.jp' + img_path, }) info = { 'id': episode_id + '-' + lang, 'title': '%s - %s' % (series, title) if series and title else title, 'description': get_clean_field('description'), 'thumbnails': thumbnails, 'series': series, 'episode': title, } if is_video: vod_id = episode['vod_id'] info.update({ '_type': 'url_transparent', 'ie_key': 'Piksel', 'url': 'https://player.piksel.com/v/refid/nhkworld/prefid/' + vod_id, 'id': vod_id, }) else: if fetch_episode: audio_path = episode['audio']['audio'] info['formats'] = self._extract_m3u8_formats( 'https://nhkworld-vh.akamaihd.net/i%s/master.m3u8' % audio_path, episode_id, 'm4a', entry_protocol='m3u8_native', m3u8_id='hls', fatal=False) for f in info['formats']: f['language'] = lang else: info.update({ '_type': 'url_transparent', 'ie_key': NhkVodIE.ie_key(), 'url': url, }) return info class NhkVodIE(NhkBaseIE): # the 7-character IDs can have alphabetic chars too: assume [a-z] rather than just [a-f], eg _VALID_URL = r'%s%s(?P<id>[0-9a-z]{7}|[^/]+?-\d{8}-[0-9a-z]+)' % (NhkBaseIE._BASE_URL_REGEX, NhkBaseIE._TYPE_REGEX) # Content available only for a limited period of time. Visit # https://www3.nhk.or.jp/nhkworld/en/ondemand/ for working samples. _TESTS = [{ # video clip 'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/video/9999011/', 'md5': '7a90abcfe610ec22a6bfe15bd46b30ca', 'info_dict': { 'id': 'a95j5iza', 'ext': 'mp4', 'title': "Dining with the Chef - Chef Saito's Family recipe: MENCHI-KATSU", 'description': 'md5:5aee4a9f9d81c26281862382103b0ea5', 'timestamp': 1565965194, 'upload_date': '20190816', }, }, { # audio clip 'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/audio/r_inventions-20201104-1/', 'info_dict': { 'id': 'r_inventions-20201104-1-en', 'ext': 'm4a', 'title': "Japan's Top Inventions - Miniature Video Cameras", 'description': 'md5:07ea722bdbbb4936fdd360b6a480c25b', }, 'params': { # m3u8 download 'skip_download': True, }, }, { 'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/video/2015173/', 'only_matching': True, }, { 'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/audio/plugin-20190404-1/', 'only_matching': True, }, { 'url': 'https://www3.nhk.or.jp/nhkworld/fr/ondemand/audio/plugin-20190404-1/', 'only_matching': True, }, { 'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/audio/j_art-20150903-1/', 'only_matching': True, }, { # video, alphabetic character in ID #29670 'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/video/9999a34/', 'only_matching': True, 'info_dict': { 'id': 'qfjay6cg', 'ext': 'mp4', 'title': 'DESIGN TALKS plus - Fishermen’s Finery', 'description': 'md5:8a8f958aaafb0d7cb59d38de53f1e448', 'thumbnail': r're:^https?:/(/[a-z0-9.-]+)+\.jpg\?w=1920&h=1080$', 'upload_date': '20210615', 'timestamp': 1623722008, } }] def _real_extract(self, url): return self._extract_episode_info(url) class NhkVodProgramIE(NhkBaseIE): _VALID_URL = r'%s/program%s(?P<id>[0-9a-z]+)(?:.+?\btype=(?P<episode_type>clip|(?:radio|tv)Episode))?' % (NhkBaseIE._BASE_URL_REGEX, NhkBaseIE._TYPE_REGEX) _TESTS = [{ # video program episodes 'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/program/video/japanrailway', 'info_dict': { 'id': 'japanrailway', 'title': 'Japan Railway Journal', }, 'playlist_mincount': 1, }, { # video program clips 'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/program/video/japanrailway/?type=clip', 'info_dict': { 'id': 'japanrailway', 'title': 'Japan Railway Journal', }, 'playlist_mincount': 5, }, { 'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/program/video/10yearshayaomiyazaki/', 'only_matching': True, }, { # audio program 'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/program/audio/listener/', 'only_matching': True, }] def _real_extract(self, url): lang, m_type, program_id, episode_type = re.match(self._VALID_URL, url).groups() episodes = self._call_api( program_id, lang, m_type == 'video', False, episode_type == 'clip') entries = [] for episode in episodes: episode_path = episode.get('url') if not episode_path: continue entries.append(self._extract_episode_info( urljoin(url, episode_path), episode)) program_title = None if entries: program_title = entries[0].get('series') return self.playlist_result(entries, program_id, program_title)
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/r7.py
youtube_dl/extractor/r7.py
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..utils import int_or_none class R7IE(InfoExtractor): _VALID_URL = r'''(?x) https?:// (?: (?:[a-zA-Z]+)\.r7\.com(?:/[^/]+)+/idmedia/| noticias\.r7\.com(?:/[^/]+)+/[^/]+-| player\.r7\.com/video/i/ ) (?P<id>[\da-f]{24}) ''' _TESTS = [{ 'url': 'http://videos.r7.com/policiais-humilham-suspeito-a-beira-da-morte-morre-com-dignidade-/idmedia/54e7050b0cf2ff57e0279389.html', 'md5': '403c4e393617e8e8ddc748978ee8efde', 'info_dict': { 'id': '54e7050b0cf2ff57e0279389', 'ext': 'mp4', 'title': 'Policiais humilham suspeito à beira da morte: "Morre com dignidade"', 'description': 'md5:01812008664be76a6479aa58ec865b72', 'thumbnail': r're:^https?://.*\.jpg$', 'duration': 98, 'like_count': int, 'view_count': int, }, }, { 'url': 'http://esportes.r7.com/videos/cigano-manda-recado-aos-fas/idmedia/4e176727b51a048ee6646a1b.html', 'only_matching': True, }, { 'url': 'http://noticias.r7.com/record-news/video/representante-do-instituto-sou-da-paz-fala-sobre-fim-do-estatuto-do-desarmamento-5480fc580cf2285b117f438d/', 'only_matching': True, }, { 'url': 'http://player.r7.com/video/i/54e7050b0cf2ff57e0279389?play=true&video=http://vsh.r7.com/54e7050b0cf2ff57e0279389/ER7_RE_BG_MORTE_JOVENS_570kbps_2015-02-2009f17818-cc82-4c8f-86dc-89a66934e633-ATOS_copy.mp4&linkCallback=http://videos.r7.com/policiais-humilham-suspeito-a-beira-da-morte-morre-com-dignidade-/idmedia/54e7050b0cf2ff57e0279389.html&thumbnail=http://vtb.r7.com/ER7_RE_BG_MORTE_JOVENS_570kbps_2015-02-2009f17818-cc82-4c8f-86dc-89a66934e633-thumb.jpg&idCategory=192&share=true&layout=full&full=true', 'only_matching': True, }] def _real_extract(self, url): video_id = self._match_id(url) video = self._download_json( 'http://player-api.r7.com/video/i/%s' % video_id, video_id) title = video['title'] formats = [] media_url_hls = video.get('media_url_hls') if media_url_hls: formats.extend(self._extract_m3u8_formats( media_url_hls, video_id, 'mp4', entry_protocol='m3u8_native', m3u8_id='hls', fatal=False)) media_url = video.get('media_url') if media_url: f = { 'url': media_url, 'format_id': 'http', } # m3u8 format always matches the http format, let's copy metadata from # one to another m3u8_formats = list(filter( lambda f: f.get('vcodec') != 'none', formats)) if len(m3u8_formats) == 1: f_copy = m3u8_formats[0].copy() f_copy.update(f) f_copy['protocol'] = 'http' f = f_copy formats.append(f) self._sort_formats(formats) description = video.get('description') thumbnail = video.get('thumb') duration = int_or_none(video.get('media_duration')) like_count = int_or_none(video.get('likes')) view_count = int_or_none(video.get('views')) return { 'id': video_id, 'title': title, 'description': description, 'thumbnail': thumbnail, 'duration': duration, 'like_count': like_count, 'view_count': view_count, 'formats': formats, } class R7ArticleIE(InfoExtractor): _VALID_URL = r'https?://(?:[a-zA-Z]+)\.r7\.com/(?:[^/]+/)+[^/?#&]+-(?P<id>\d+)' _TEST = { 'url': 'http://tv.r7.com/record-play/balanco-geral/videos/policiais-humilham-suspeito-a-beira-da-morte-morre-com-dignidade-16102015', 'only_matching': True, } @classmethod def suitable(cls, url): return False if R7IE.suitable(url) else super(R7ArticleIE, cls).suitable(url) def _real_extract(self, url): display_id = self._match_id(url) webpage = self._download_webpage(url, display_id) video_id = self._search_regex( r'<div[^>]+(?:id=["\']player-|class=["\']embed["\'][^>]+id=["\'])([\da-f]{24})', webpage, 'video id') return self.url_result('http://player.r7.com/video/i/%s' % video_id, R7IE.ie_key())
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/jove.py
youtube_dl/extractor/jove.py
from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import ( ExtractorError, unified_strdate ) class JoveIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?jove\.com/video/(?P<id>[0-9]+)' _CHAPTERS_URL = 'http://www.jove.com/video-chapters?videoid={video_id:}' _TESTS = [ { 'url': 'http://www.jove.com/video/2744/electrode-positioning-montage-transcranial-direct-current', 'md5': '93723888d82dbd6ba8b3d7d0cd65dd2b', 'info_dict': { 'id': '2744', 'ext': 'mp4', 'title': 'Electrode Positioning and Montage in Transcranial Direct Current Stimulation', 'description': 'md5:015dd4509649c0908bc27f049e0262c6', 'thumbnail': r're:^https?://.*\.png$', 'upload_date': '20110523', } }, { 'url': 'http://www.jove.com/video/51796/culturing-caenorhabditis-elegans-axenic-liquid-media-creation', 'md5': '914aeb356f416811d911996434811beb', 'info_dict': { 'id': '51796', 'ext': 'mp4', 'title': 'Culturing Caenorhabditis elegans in Axenic Liquid Media and Creation of Transgenic Worms by Microparticle Bombardment', 'description': 'md5:35ff029261900583970c4023b70f1dc9', 'thumbnail': r're:^https?://.*\.png$', 'upload_date': '20140802', } }, ] def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) video_id = mobj.group('id') webpage = self._download_webpage(url, video_id) chapters_id = self._html_search_regex( r'/video-chapters\?videoid=([0-9]+)', webpage, 'chapters id') chapters_xml = self._download_xml( self._CHAPTERS_URL.format(video_id=chapters_id), video_id, note='Downloading chapters XML', errnote='Failed to download chapters XML') video_url = chapters_xml.attrib.get('video') if not video_url: raise ExtractorError('Failed to get the video URL') title = self._html_search_meta('citation_title', webpage, 'title') thumbnail = self._og_search_thumbnail(webpage) description = self._html_search_regex( r'<div id="section_body_summary"><p class="jove_content">(.+?)</p>', webpage, 'description', fatal=False) publish_date = unified_strdate(self._html_search_meta( 'citation_publication_date', webpage, 'publish date', fatal=False)) comment_count = int(self._html_search_regex( r'<meta name="num_comments" content="(\d+) Comments?"', webpage, 'comment count', fatal=False)) return { 'id': video_id, 'title': title, 'url': video_url, 'thumbnail': thumbnail, 'description': description, 'upload_date': publish_date, 'comment_count': comment_count, }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/noz.py
youtube_dl/extractor/noz.py
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..compat import ( compat_urllib_parse_unquote, compat_xpath, ) from ..utils import ( int_or_none, find_xpath_attr, xpath_text, update_url_query, ) class NozIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?noz\.de/video/(?P<id>[0-9]+)/' _TESTS = [{ 'url': 'http://www.noz.de/video/25151/32-Deutschland-gewinnt-Badminton-Lnderspiel-in-Melle', 'info_dict': { 'id': '25151', 'ext': 'mp4', 'duration': 215, 'title': '3:2 - Deutschland gewinnt Badminton-Länderspiel in Melle', 'description': 'Vor rund 370 Zuschauern gewinnt die deutsche Badminton-Nationalmannschaft am Donnerstag ein EM-Vorbereitungsspiel gegen Frankreich in Melle. Video Moritz Frankenberg.', 'thumbnail': r're:^http://.*\.jpg', }, }] def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) description = self._og_search_description(webpage) edge_url = self._html_search_regex( r'<script\s+(?:type="text/javascript"\s+)?src="(.*?/videojs_.*?)"', webpage, 'edge URL') edge_content = self._download_webpage(edge_url, 'meta configuration') config_url_encoded = self._search_regex( r'so\.addVariable\("config_url","[^,]*,(.*?)"', edge_content, 'config URL' ) config_url = compat_urllib_parse_unquote(config_url_encoded) doc = self._download_xml(config_url, 'video configuration') title = xpath_text(doc, './/title') thumbnail = xpath_text(doc, './/article/thumbnail/url') duration = int_or_none(xpath_text( doc, './/article/movie/file/duration')) formats = [] for qnode in doc.findall(compat_xpath('.//article/movie/file/qualities/qual')): http_url_ele = find_xpath_attr( qnode, './html_urls/video_url', 'format', 'video/mp4') http_url = http_url_ele.text if http_url_ele is not None else None if http_url: formats.append({ 'url': http_url, 'format_name': xpath_text(qnode, './name'), 'format_id': '%s-%s' % ('http', xpath_text(qnode, './id')), 'height': int_or_none(xpath_text(qnode, './height')), 'width': int_or_none(xpath_text(qnode, './width')), 'tbr': int_or_none(xpath_text(qnode, './bitrate'), scale=1000), }) else: f4m_url = xpath_text(qnode, 'url_hd2') if f4m_url: formats.extend(self._extract_f4m_formats( update_url_query(f4m_url, {'hdcore': '3.4.0'}), video_id, f4m_id='hds', fatal=False)) m3u8_url_ele = find_xpath_attr( qnode, './html_urls/video_url', 'format', 'application/vnd.apple.mpegurl') m3u8_url = m3u8_url_ele.text if m3u8_url_ele is not None else None if m3u8_url: formats.extend(self._extract_m3u8_formats( m3u8_url, video_id, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False)) self._sort_formats(formats) return { 'id': video_id, 'formats': formats, 'title': title, 'duration': duration, 'description': description, 'thumbnail': thumbnail, }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/veoh.py
youtube_dl/extractor/veoh.py
from __future__ import unicode_literals from .common import InfoExtractor from ..utils import ( int_or_none, parse_duration, qualities, ) class VeohIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?veoh\.com/(?:watch|embed|iphone/#_Watch)/(?P<id>(?:v|e|yapi-)[\da-zA-Z]+)' _TESTS = [{ 'url': 'http://www.veoh.com/watch/v56314296nk7Zdmz3', 'md5': '9e7ecc0fd8bbee7a69fe38953aeebd30', 'info_dict': { 'id': 'v56314296nk7Zdmz3', 'ext': 'mp4', 'title': 'Straight Backs Are Stronger', 'uploader': 'LUMOback', 'description': 'At LUMOback, we believe straight backs are stronger. The LUMOback Posture & Movement Sensor: It gently vibrates when you slouch, inspiring improved posture and mobility. Use the app to track your data and improve your posture over time. ', }, }, { 'url': 'http://www.veoh.com/embed/v56314296nk7Zdmz3', 'only_matching': True, }, { 'url': 'http://www.veoh.com/watch/v27701988pbTc4wzN?h1=Chile+workers+cover+up+to+avoid+skin+damage', 'md5': '4a6ff84b87d536a6a71e6aa6c0ad07fa', 'info_dict': { 'id': '27701988', 'ext': 'mp4', 'title': 'Chile workers cover up to avoid skin damage', 'description': 'md5:2bd151625a60a32822873efc246ba20d', 'uploader': 'afp-news', 'duration': 123, }, 'skip': 'This video has been deleted.', }, { 'url': 'http://www.veoh.com/watch/v69525809F6Nc4frX', 'md5': '4fde7b9e33577bab2f2f8f260e30e979', 'note': 'Embedded ooyala video', 'info_dict': { 'id': '69525809', 'ext': 'mp4', 'title': 'Doctors Alter Plan For Preteen\'s Weight Loss Surgery', 'description': 'md5:f5a11c51f8fb51d2315bca0937526891', 'uploader': 'newsy-videos', }, 'skip': 'This video has been deleted.', }, { 'url': 'http://www.veoh.com/watch/e152215AJxZktGS', 'only_matching': True, }] def _extract_video(self, source): return { 'id': source.get('videoId'), 'title': source.get('title'), 'description': source.get('description'), 'thumbnail': source.get('highResImage') or source.get('medResImage'), 'uploader': source.get('username'), 'duration': int_or_none(source.get('length')), 'view_count': int_or_none(source.get('views')), 'age_limit': 18 if source.get('isMature') == 'true' or source.get('isSexy') == 'true' else 0, 'formats': self._extract_formats(source), } def _real_extract(self, url): video_id = self._match_id(url) video = self._download_json( 'https://www.veoh.com/watch/getVideo/' + video_id, video_id)['video'] title = video['title'] thumbnail_url = None q = qualities(['HQ', 'Regular']) formats = [] for f_id, f_url in video.get('src', {}).items(): if not f_url: continue if f_id == 'poster': thumbnail_url = f_url else: formats.append({ 'format_id': f_id, 'quality': q(f_id), 'url': f_url, }) self._sort_formats(formats) return { 'id': video_id, 'title': title, 'description': video.get('description'), 'thumbnail': thumbnail_url, 'uploader': video.get('author', {}).get('nickname'), 'duration': int_or_none(video.get('lengthBySec')) or parse_duration(video.get('length')), 'view_count': int_or_none(video.get('views')), 'formats': formats, 'average_rating': int_or_none(video.get('rating')), 'comment_count': int_or_none(video.get('numOfComments')), }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/crackle.py
youtube_dl/extractor/crackle.py
# coding: utf-8 from __future__ import unicode_literals, division import hashlib import hmac import re import time from .common import InfoExtractor from ..compat import compat_HTTPError from ..utils import ( determine_ext, float_or_none, int_or_none, parse_age_limit, parse_duration, url_or_none, ExtractorError ) class CrackleIE(InfoExtractor): _VALID_URL = r'(?:crackle:|https?://(?:(?:www|m)\.)?(?:sony)?crackle\.com/(?:playlist/\d+/|(?:[^/]+/)+))(?P<id>\d+)' _TESTS = [{ # geo restricted to CA 'url': 'https://www.crackle.com/andromeda/2502343', 'info_dict': { 'id': '2502343', 'ext': 'mp4', 'title': 'Under The Night', 'description': 'md5:d2b8ca816579ae8a7bf28bfff8cefc8a', 'duration': 2583, 'view_count': int, 'average_rating': 0, 'age_limit': 14, 'genre': 'Action, Sci-Fi', 'creator': 'Allan Kroeker', 'artist': 'Keith Hamilton Cobb, Kevin Sorbo, Lisa Ryder, Lexa Doig, Robert Hewitt Wolfe', 'release_year': 2000, 'series': 'Andromeda', 'episode': 'Under The Night', 'season_number': 1, 'episode_number': 1, }, 'params': { # m3u8 download 'skip_download': True, } }, { 'url': 'https://www.sonycrackle.com/andromeda/2502343', 'only_matching': True, }] _MEDIA_FILE_SLOTS = { '360p.mp4': { 'width': 640, 'height': 360, }, '480p.mp4': { 'width': 768, 'height': 432, }, '480p_1mbps.mp4': { 'width': 852, 'height': 480, }, } def _real_extract(self, url): video_id = self._match_id(url) country_code = self._downloader.params.get('geo_bypass_country', None) countries = [country_code] if country_code else ( 'US', 'AU', 'CA', 'AS', 'FM', 'GU', 'MP', 'PR', 'PW', 'MH', 'VI') last_e = None for country in countries: try: # Authorization generation algorithm is reverse engineered from: # https://www.sonycrackle.com/static/js/main.ea93451f.chunk.js media_detail_url = 'https://web-api-us.crackle.com/Service.svc/details/media/%s/%s?disableProtocols=true' % (video_id, country) timestamp = time.strftime('%Y%m%d%H%M', time.gmtime()) h = hmac.new(b'IGSLUQCBDFHEOIFM', '|'.join([media_detail_url, timestamp]).encode(), hashlib.sha1).hexdigest().upper() media = self._download_json( media_detail_url, video_id, 'Downloading media JSON as %s' % country, 'Unable to download media JSON', headers={ 'Accept': 'application/json', 'Authorization': '|'.join([h, timestamp, '117', '1']), }) except ExtractorError as e: # 401 means geo restriction, trying next country if isinstance(e.cause, compat_HTTPError) and e.cause.code == 401: last_e = e continue raise media_urls = media.get('MediaURLs') if not media_urls or not isinstance(media_urls, list): continue title = media['Title'] formats = [] for e in media['MediaURLs']: if e.get('UseDRM') is True: continue format_url = url_or_none(e.get('Path')) if not format_url: continue ext = determine_ext(format_url) if ext == 'm3u8': formats.extend(self._extract_m3u8_formats( format_url, video_id, 'mp4', entry_protocol='m3u8_native', m3u8_id='hls', fatal=False)) elif ext == 'mpd': formats.extend(self._extract_mpd_formats( format_url, video_id, mpd_id='dash', fatal=False)) elif format_url.endswith('.ism/Manifest'): formats.extend(self._extract_ism_formats( format_url, video_id, ism_id='mss', fatal=False)) else: mfs_path = e.get('Type') mfs_info = self._MEDIA_FILE_SLOTS.get(mfs_path) if not mfs_info: continue formats.append({ 'url': format_url, 'format_id': 'http-' + mfs_path.split('.')[0], 'width': mfs_info['width'], 'height': mfs_info['height'], }) self._sort_formats(formats) description = media.get('Description') duration = int_or_none(media.get( 'DurationInSeconds')) or parse_duration(media.get('Duration')) view_count = int_or_none(media.get('CountViews')) average_rating = float_or_none(media.get('UserRating')) age_limit = parse_age_limit(media.get('Rating')) genre = media.get('Genre') release_year = int_or_none(media.get('ReleaseYear')) creator = media.get('Directors') artist = media.get('Cast') if media.get('MediaTypeDisplayValue') == 'Full Episode': series = media.get('ShowName') episode = title season_number = int_or_none(media.get('Season')) episode_number = int_or_none(media.get('Episode')) else: series = episode = season_number = episode_number = None subtitles = {} cc_files = media.get('ClosedCaptionFiles') if isinstance(cc_files, list): for cc_file in cc_files: if not isinstance(cc_file, dict): continue cc_url = url_or_none(cc_file.get('Path')) if not cc_url: continue lang = cc_file.get('Locale') or 'en' subtitles.setdefault(lang, []).append({'url': cc_url}) thumbnails = [] images = media.get('Images') if isinstance(images, list): for image_key, image_url in images.items(): mobj = re.search(r'Img_(\d+)[xX](\d+)', image_key) if not mobj: continue thumbnails.append({ 'url': image_url, 'width': int(mobj.group(1)), 'height': int(mobj.group(2)), }) return { 'id': video_id, 'title': title, 'description': description, 'duration': duration, 'view_count': view_count, 'average_rating': average_rating, 'age_limit': age_limit, 'genre': genre, 'creator': creator, 'artist': artist, 'release_year': release_year, 'series': series, 'episode': episode, 'season_number': season_number, 'episode_number': episode_number, 'thumbnails': thumbnails, 'subtitles': subtitles, 'formats': formats, } raise last_e
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/vodlocker.py
youtube_dl/extractor/vodlocker.py
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..utils import ( ExtractorError, NO_DEFAULT, sanitized_Request, urlencode_postdata, ) class VodlockerIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?vodlocker\.(?:com|city)/(?:embed-)?(?P<id>[0-9a-zA-Z]+)(?:\..*?)?' _TESTS = [{ 'url': 'http://vodlocker.com/e8wvyzz4sl42', 'md5': 'ce0c2d18fa0735f1bd91b69b0e54aacf', 'info_dict': { 'id': 'e8wvyzz4sl42', 'ext': 'mp4', 'title': 'Germany vs Brazil', 'thumbnail': r're:http://.*\.jpg', }, }] def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) if any(p in webpage for p in ( '>THIS FILE WAS DELETED<', '>File Not Found<', 'The file you were looking for could not be found, sorry for any inconvenience.<', '>The file was removed')): raise ExtractorError('Video %s does not exist' % video_id, expected=True) fields = self._hidden_inputs(webpage) if fields['op'] == 'download1': self._sleep(3, video_id) # they do detect when requests happen too fast! post = urlencode_postdata(fields) req = sanitized_Request(url, post) req.add_header('Content-type', 'application/x-www-form-urlencoded') webpage = self._download_webpage( req, video_id, 'Downloading video page') def extract_file_url(html, default=NO_DEFAULT): return self._search_regex( r'file:\s*"(http[^\"]+)",', html, 'file url', default=default) video_url = extract_file_url(webpage, default=None) if not video_url: embed_url = self._search_regex( r'<iframe[^>]+src=(["\'])(?P<url>(?:https?://)?vodlocker\.(?:com|city)/embed-.+?)\1', webpage, 'embed url', group='url') embed_webpage = self._download_webpage( embed_url, video_id, 'Downloading embed webpage') video_url = extract_file_url(embed_webpage) thumbnail_webpage = embed_webpage else: thumbnail_webpage = webpage title = self._search_regex( r'id="file_title".*?>\s*(.*?)\s*<(?:br|span)', webpage, 'title') thumbnail = self._search_regex( r'image:\s*"(http[^\"]+)",', thumbnail_webpage, 'thumbnail', fatal=False) formats = [{ 'format_id': 'sd', 'url': video_url, }] return { 'id': video_id, 'title': title, 'thumbnail': thumbnail, 'formats': formats, }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/howcast.py
youtube_dl/extractor/howcast.py
from __future__ import unicode_literals from .common import InfoExtractor from ..utils import parse_iso8601 class HowcastIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?howcast\.com/videos/(?P<id>\d+)' _TEST = { 'url': 'http://www.howcast.com/videos/390161-How-to-Tie-a-Square-Knot-Properly', 'md5': '7d45932269a288149483144f01b99789', 'info_dict': { 'id': '390161', 'ext': 'mp4', 'title': 'How to Tie a Square Knot Properly', 'description': 'md5:dbe792e5f6f1489027027bf2eba188a3', 'timestamp': 1276081287, 'upload_date': '20100609', 'duration': 56.823, }, 'params': { 'skip_download': True, }, 'add_ie': ['Ooyala'], } def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) embed_code = self._search_regex( r'<iframe[^>]+src="[^"]+\bembed_code=([^\b]+)\b', webpage, 'ooyala embed code') return { '_type': 'url_transparent', 'ie_key': 'Ooyala', 'url': 'ooyala:%s' % embed_code, 'id': video_id, 'timestamp': parse_iso8601(self._html_search_meta( 'article:published_time', webpage, 'timestamp')), }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/animeondemand.py
youtube_dl/extractor/animeondemand.py
from __future__ import unicode_literals import re from .common import InfoExtractor from ..compat import compat_str from ..utils import ( determine_ext, extract_attributes, ExtractorError, url_or_none, urlencode_postdata, urljoin, ) class AnimeOnDemandIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?anime-on-demand\.de/anime/(?P<id>\d+)' _LOGIN_URL = 'https://www.anime-on-demand.de/users/sign_in' _APPLY_HTML5_URL = 'https://www.anime-on-demand.de/html5apply' _NETRC_MACHINE = 'animeondemand' # German-speaking countries of Europe _GEO_COUNTRIES = ['AT', 'CH', 'DE', 'LI', 'LU'] _TESTS = [{ # jap, OmU 'url': 'https://www.anime-on-demand.de/anime/161', 'info_dict': { 'id': '161', 'title': 'Grimgar, Ashes and Illusions (OmU)', 'description': 'md5:6681ce3c07c7189d255ac6ab23812d31', }, 'playlist_mincount': 4, }, { # Film wording is used instead of Episode, ger/jap, Dub/OmU 'url': 'https://www.anime-on-demand.de/anime/39', 'only_matching': True, }, { # Episodes without titles, jap, OmU 'url': 'https://www.anime-on-demand.de/anime/162', 'only_matching': True, }, { # ger/jap, Dub/OmU, account required 'url': 'https://www.anime-on-demand.de/anime/169', 'only_matching': True, }, { # Full length film, non-series, ger/jap, Dub/OmU, account required 'url': 'https://www.anime-on-demand.de/anime/185', 'only_matching': True, }, { # Flash videos 'url': 'https://www.anime-on-demand.de/anime/12', 'only_matching': True, }] def _login(self): username, password = self._get_login_info() if username is None: return login_page = self._download_webpage( self._LOGIN_URL, None, 'Downloading login page') if '>Our licensing terms allow the distribution of animes only to German-speaking countries of Europe' in login_page: self.raise_geo_restricted( '%s is only available in German-speaking countries of Europe' % self.IE_NAME) login_form = self._form_hidden_inputs('new_user', login_page) login_form.update({ 'user[login]': username, 'user[password]': password, }) post_url = self._search_regex( r'<form[^>]+action=(["\'])(?P<url>.+?)\1', login_page, 'post url', default=self._LOGIN_URL, group='url') if not post_url.startswith('http'): post_url = urljoin(self._LOGIN_URL, post_url) response = self._download_webpage( post_url, None, 'Logging in', data=urlencode_postdata(login_form), headers={ 'Referer': self._LOGIN_URL, }) if all(p not in response for p in ('>Logout<', 'href="/users/sign_out"')): error = self._search_regex( r'<p[^>]+\bclass=(["\'])(?:(?!\1).)*\balert\b(?:(?!\1).)*\1[^>]*>(?P<error>.+?)</p>', response, 'error', default=None, group='error') if error: raise ExtractorError('Unable to login: %s' % error, expected=True) raise ExtractorError('Unable to log in') def _real_initialize(self): self._login() def _real_extract(self, url): anime_id = self._match_id(url) webpage = self._download_webpage(url, anime_id) if 'data-playlist=' not in webpage: self._download_webpage( self._APPLY_HTML5_URL, anime_id, 'Activating HTML5 beta', 'Unable to apply HTML5 beta') webpage = self._download_webpage(url, anime_id) csrf_token = self._html_search_meta( 'csrf-token', webpage, 'csrf token', fatal=True) anime_title = self._html_search_regex( r'(?s)<h1[^>]+itemprop="name"[^>]*>(.+?)</h1>', webpage, 'anime name') anime_description = self._html_search_regex( r'(?s)<div[^>]+itemprop="description"[^>]*>(.+?)</div>', webpage, 'anime description', default=None) def extract_info(html, video_id, num=None): title, description = [None] * 2 formats = [] for input_ in re.findall( r'<input[^>]+class=["\'].*?streamstarter[^>]+>', html): attributes = extract_attributes(input_) title = attributes.get('data-dialog-header') playlist_urls = [] for playlist_key in ('data-playlist', 'data-otherplaylist', 'data-stream'): playlist_url = attributes.get(playlist_key) if isinstance(playlist_url, compat_str) and re.match( r'/?[\da-zA-Z]+', playlist_url): playlist_urls.append(attributes[playlist_key]) if not playlist_urls: continue lang = attributes.get('data-lang') lang_note = attributes.get('value') for playlist_url in playlist_urls: kind = self._search_regex( r'videomaterialurl/\d+/([^/]+)/', playlist_url, 'media kind', default=None) format_id_list = [] if lang: format_id_list.append(lang) if kind: format_id_list.append(kind) if not format_id_list and num is not None: format_id_list.append(compat_str(num)) format_id = '-'.join(format_id_list) format_note = ', '.join(filter(None, (kind, lang_note))) item_id_list = [] if format_id: item_id_list.append(format_id) item_id_list.append('videomaterial') playlist = self._download_json( urljoin(url, playlist_url), video_id, 'Downloading %s JSON' % ' '.join(item_id_list), headers={ 'X-Requested-With': 'XMLHttpRequest', 'X-CSRF-Token': csrf_token, 'Referer': url, 'Accept': 'application/json, text/javascript, */*; q=0.01', }, fatal=False) if not playlist: continue stream_url = url_or_none(playlist.get('streamurl')) if stream_url: rtmp = re.search( r'^(?P<url>rtmpe?://(?P<host>[^/]+)/(?P<app>.+/))(?P<playpath>mp[34]:.+)', stream_url) if rtmp: formats.append({ 'url': rtmp.group('url'), 'app': rtmp.group('app'), 'play_path': rtmp.group('playpath'), 'page_url': url, 'player_url': 'https://www.anime-on-demand.de/assets/jwplayer.flash-55abfb34080700304d49125ce9ffb4a6.swf', 'rtmp_real_time': True, 'format_id': 'rtmp', 'ext': 'flv', }) continue start_video = playlist.get('startvideo', 0) playlist = playlist.get('playlist') if not playlist or not isinstance(playlist, list): continue playlist = playlist[start_video] title = playlist.get('title') if not title: continue description = playlist.get('description') for source in playlist.get('sources', []): file_ = source.get('file') if not file_: continue ext = determine_ext(file_) format_id_list = [lang, kind] if ext == 'm3u8': format_id_list.append('hls') elif source.get('type') == 'video/dash' or ext == 'mpd': format_id_list.append('dash') format_id = '-'.join(filter(None, format_id_list)) if ext == 'm3u8': file_formats = self._extract_m3u8_formats( file_, video_id, 'mp4', entry_protocol='m3u8_native', m3u8_id=format_id, fatal=False) elif source.get('type') == 'video/dash' or ext == 'mpd': continue file_formats = self._extract_mpd_formats( file_, video_id, mpd_id=format_id, fatal=False) else: continue for f in file_formats: f.update({ 'language': lang, 'format_note': format_note, }) formats.extend(file_formats) return { 'title': title, 'description': description, 'formats': formats, } def extract_entries(html, video_id, common_info, num=None): info = extract_info(html, video_id, num) if info['formats']: self._sort_formats(info['formats']) f = common_info.copy() f.update(info) yield f # Extract teaser/trailer only when full episode is not available if not info['formats']: m = re.search( r'data-dialog-header=(["\'])(?P<title>.+?)\1[^>]+href=(["\'])(?P<href>.+?)\3[^>]*>(?P<kind>Teaser|Trailer)<', html) if m: f = common_info.copy() f.update({ 'id': '%s-%s' % (f['id'], m.group('kind').lower()), 'title': m.group('title'), 'url': urljoin(url, m.group('href')), }) yield f def extract_episodes(html): for num, episode_html in enumerate(re.findall( r'(?s)<h3[^>]+class="episodebox-title".+?>Episodeninhalt<', html), 1): episodebox_title = self._search_regex( (r'class="episodebox-title"[^>]+title=(["\'])(?P<title>.+?)\1', r'class="episodebox-title"[^>]+>(?P<title>.+?)<'), episode_html, 'episodebox title', default=None, group='title') if not episodebox_title: continue episode_number = int(self._search_regex( r'(?:Episode|Film)\s*(\d+)', episodebox_title, 'episode number', default=num)) episode_title = self._search_regex( r'(?:Episode|Film)\s*\d+\s*-\s*(.+)', episodebox_title, 'episode title', default=None) video_id = 'episode-%d' % episode_number common_info = { 'id': video_id, 'series': anime_title, 'episode': episode_title, 'episode_number': episode_number, } for e in extract_entries(episode_html, video_id, common_info): yield e def extract_film(html, video_id): common_info = { 'id': anime_id, 'title': anime_title, 'description': anime_description, } for e in extract_entries(html, video_id, common_info): yield e def entries(): has_episodes = False for e in extract_episodes(webpage): has_episodes = True yield e if not has_episodes: for e in extract_film(webpage, anime_id): yield e return self.playlist_result( entries(), anime_id, anime_title, anime_description)
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/historicfilms.py
youtube_dl/extractor/historicfilms.py
from __future__ import unicode_literals from .common import InfoExtractor from ..utils import parse_duration class HistoricFilmsIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?historicfilms\.com/(?:tapes/|play)(?P<id>\d+)' _TEST = { 'url': 'http://www.historicfilms.com/tapes/4728', 'md5': 'd4a437aec45d8d796a38a215db064e9a', 'info_dict': { 'id': '4728', 'ext': 'mov', 'title': 'Historic Films: GP-7', 'description': 'md5:1a86a0f3ac54024e419aba97210d959a', 'thumbnail': r're:^https?://.*\.jpg$', 'duration': 2096, }, } def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) tape_id = self._search_regex( [r'class="tapeId"[^>]*>([^<]+)<', r'tapeId\s*:\s*"([^"]+)"'], webpage, 'tape id') title = self._og_search_title(webpage) description = self._og_search_description(webpage) thumbnail = self._html_search_meta( 'thumbnailUrl', webpage, 'thumbnails') or self._og_search_thumbnail(webpage) duration = parse_duration(self._html_search_meta( 'duration', webpage, 'duration')) video_url = 'http://www.historicfilms.com/video/%s_%s_web.mov' % (tape_id, video_id) return { 'id': video_id, 'url': video_url, 'title': title, 'description': description, 'thumbnail': thumbnail, 'duration': duration, }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/mixcloud.py
youtube_dl/extractor/mixcloud.py
# coding: utf-8 from __future__ import unicode_literals import itertools import re from .common import InfoExtractor from ..compat import ( compat_b64decode, compat_chr, compat_ord, compat_str, compat_urllib_parse_unquote, compat_zip as zip, ) from ..utils import ( int_or_none, parse_iso8601, strip_or_none, try_get, ) class MixcloudBaseIE(InfoExtractor): def _call_api(self, object_type, object_fields, display_id, username, slug=None): lookup_key = object_type + 'Lookup' return self._download_json( 'https://app.mixcloud.com/graphql', display_id, query={ 'query': '''{ %s(lookup: {username: "%s"%s}) { %s } }''' % (lookup_key, username, ', slug: "%s"' % slug if slug else '', object_fields) })['data'][lookup_key] class MixcloudIE(MixcloudBaseIE): _VALID_URL = r'https?://(?:(?:www|beta|m)\.)?mixcloud\.com/([^/]+)/(?!stream|uploads|favorites|listens|playlists)([^/]+)' IE_NAME = 'mixcloud' _TESTS = [{ 'url': 'http://www.mixcloud.com/dholbach/cryptkeeper/', 'info_dict': { 'id': 'dholbach_cryptkeeper', 'ext': 'm4a', 'title': 'Cryptkeeper', 'description': 'After quite a long silence from myself, finally another Drum\'n\'Bass mix with my favourite current dance floor bangers.', 'uploader': 'dholbach', # was: 'Daniel Holbach', 'uploader_id': 'dholbach', 'thumbnail': r're:https?://.*\.jpg', 'view_count': int, 'timestamp': 1321359578, 'upload_date': '20111115', }, }, { 'url': 'http://www.mixcloud.com/gillespeterson/caribou-7-inch-vinyl-mix-chat/', 'info_dict': { 'id': 'gillespeterson_caribou-7-inch-vinyl-mix-chat', 'ext': 'mp3', 'title': 'Caribou 7 inch Vinyl Mix & Chat', 'description': r're:Last week Dan Snaith aka Caribou swung by the Brownswood.{136}', 'uploader': 'Gilles Peterson Worldwide', 'uploader_id': 'gillespeterson', 'thumbnail': 're:https?://.*', 'view_count': int, 'timestamp': 1422987057, 'upload_date': '20150203', }, 'params': { 'skip_download': '404 not found', }, }, { 'url': 'https://www.mixcloud.com/gillespeterson/carnival-m%C3%BAsica-popular-brasileira-mix/', 'info_dict': { 'id': 'gillespeterson_carnival-música-popular-brasileira-mix', 'ext': 'm4a', 'title': 'Carnival Música Popular Brasileira Mix', 'description': r're:Gilles was recently in Brazil to play at Boiler Room.{208}', 'timestamp': 1454347174, 'upload_date': '20160201', 'uploader': 'Gilles Peterson Worldwide', 'uploader_id': 'gillespeterson', 'thumbnail': 're:https?://.*', 'view_count': int, }, }, { 'url': 'https://beta.mixcloud.com/RedLightRadio/nosedrip-15-red-light-radio-01-18-2016/', 'only_matching': True, }] _DECRYPTION_KEY = 'IFYOUWANTTHEARTISTSTOGETPAIDDONOTDOWNLOADFROMMIXCLOUD' @staticmethod def _decrypt_xor_cipher(key, ciphertext): """Encrypt/Decrypt XOR cipher. Both ways are possible because it's XOR.""" return ''.join([ compat_chr(compat_ord(ch) ^ compat_ord(k)) for ch, k in zip(ciphertext, itertools.cycle(key))]) def _real_extract(self, url): username, slug = self._match_valid_url(url).groups() username, slug = compat_urllib_parse_unquote(username), compat_urllib_parse_unquote(slug) track_id = '%s_%s' % (username, slug) cloudcast = self._call_api('cloudcast', '''audioLength comments(first: 100) { edges { node { comment created user { displayName username } } } totalCount } description favorites { totalCount } featuringArtistList isExclusive name owner { displayName url username } picture(width: 1024, height: 1024) { url } plays publishDate reposts { totalCount } streamInfo { dashUrl hlsUrl url } tags { tag { name } }''', track_id, username, slug) title = cloudcast['name'] stream_info = cloudcast['streamInfo'] formats = [] for url_key in ('url', 'hlsUrl', 'dashUrl'): format_url = stream_info.get(url_key) if not format_url: continue decrypted = self._decrypt_xor_cipher( self._DECRYPTION_KEY, compat_b64decode(format_url)) if url_key == 'hlsUrl': formats.extend(self._extract_m3u8_formats( decrypted, track_id, 'mp4', entry_protocol='m3u8_native', m3u8_id='hls', fatal=False)) elif url_key == 'dashUrl': formats.extend(self._extract_mpd_formats( decrypted, track_id, mpd_id='dash', fatal=False)) else: formats.append({ 'format_id': 'http', 'url': decrypted, 'downloader_options': { # Mixcloud starts throttling at >~5M 'http_chunk_size': 5242880, }, }) if not formats and cloudcast.get('isExclusive'): self.raise_login_required() self._sort_formats(formats) comments = [] for edge in (try_get(cloudcast, lambda x: x['comments']['edges']) or []): node = edge.get('node') or {} text = strip_or_none(node.get('comment')) if not text: continue user = node.get('user') or {} comments.append({ 'author': user.get('displayName'), 'author_id': user.get('username'), 'text': text, 'timestamp': parse_iso8601(node.get('created')), }) tags = [] for t in cloudcast.get('tags'): tag = try_get(t, lambda x: x['tag']['name'], compat_str) if not tag: tags.append(tag) get_count = lambda x: int_or_none(try_get(cloudcast, lambda y: y[x]['totalCount'])) owner = cloudcast.get('owner') or {} return { 'id': track_id, 'title': title, 'formats': formats, 'description': cloudcast.get('description'), 'thumbnail': try_get(cloudcast, lambda x: x['picture']['url'], compat_str), 'uploader': owner.get('displayName'), 'timestamp': parse_iso8601(cloudcast.get('publishDate')), 'uploader_id': owner.get('username'), 'uploader_url': owner.get('url'), 'duration': int_or_none(cloudcast.get('audioLength')), 'view_count': int_or_none(cloudcast.get('plays')), 'like_count': get_count('favorites'), 'repost_count': get_count('reposts'), 'comment_count': get_count('comments'), 'comments': comments, 'tags': tags, 'artist': ', '.join(cloudcast.get('featuringArtistList') or []) or None, } class MixcloudPlaylistBaseIE(MixcloudBaseIE): def _get_cloudcast(self, node): return node def _get_playlist_title(self, title, slug): return title def _real_extract(self, url): username, slug = re.match(self._VALID_URL, url).groups() username = compat_urllib_parse_unquote(username) if not slug: slug = 'uploads' else: slug = compat_urllib_parse_unquote(slug) playlist_id = '%s_%s' % (username, slug) is_playlist_type = self._ROOT_TYPE == 'playlist' playlist_type = 'items' if is_playlist_type else slug list_filter = '' has_next_page = True entries = [] while has_next_page: playlist = self._call_api( self._ROOT_TYPE, '''%s %s %s(first: 100%s) { edges { node { %s } } pageInfo { endCursor hasNextPage } }''' % (self._TITLE_KEY, self._DESCRIPTION_KEY, playlist_type, list_filter, self._NODE_TEMPLATE), playlist_id, username, slug if is_playlist_type else None) items = playlist.get(playlist_type) or {} for edge in items.get('edges', []): cloudcast = self._get_cloudcast(edge.get('node') or {}) cloudcast_url = cloudcast.get('url') if not cloudcast_url: continue slug = try_get(cloudcast, lambda x: x['slug'], compat_str) owner_username = try_get(cloudcast, lambda x: x['owner']['username'], compat_str) video_id = '%s_%s' % (owner_username, slug) if slug and owner_username else None entries.append(self.url_result( cloudcast_url, MixcloudIE.ie_key(), video_id)) page_info = items['pageInfo'] has_next_page = page_info['hasNextPage'] list_filter = ', after: "%s"' % page_info['endCursor'] return self.playlist_result( entries, playlist_id, self._get_playlist_title(playlist[self._TITLE_KEY], slug), playlist.get(self._DESCRIPTION_KEY)) class MixcloudUserIE(MixcloudPlaylistBaseIE): _VALID_URL = r'https?://(?:www\.)?mixcloud\.com/(?P<id>[^/]+)/(?P<type>uploads|favorites|listens|stream)?/?$' IE_NAME = 'mixcloud:user' _TESTS = [{ 'url': 'http://www.mixcloud.com/dholbach/', 'info_dict': { 'id': 'dholbach_uploads', 'title': 'Daniel Holbach (uploads)', 'description': 'md5:b60d776f0bab534c5dabe0a34e47a789', }, 'playlist_mincount': 36, }, { 'url': 'http://www.mixcloud.com/dholbach/uploads/', 'info_dict': { 'id': 'dholbach_uploads', 'title': 'Daniel Holbach (uploads)', 'description': 'md5:b60d776f0bab534c5dabe0a34e47a789', }, 'playlist_mincount': 36, }, { 'url': 'http://www.mixcloud.com/dholbach/favorites/', 'info_dict': { 'id': 'dholbach_favorites', 'title': 'Daniel Holbach (favorites)', 'description': 'md5:b60d776f0bab534c5dabe0a34e47a789', }, # 'params': { # 'playlist_items': '1-100', # }, 'playlist_mincount': 396, }, { 'url': 'http://www.mixcloud.com/dholbach/listens/', 'info_dict': { 'id': 'dholbach_listens', 'title': 'Daniel Holbach (listens)', 'description': 'md5:b60d776f0bab534c5dabe0a34e47a789', }, # 'params': { # 'playlist_items': '1-100', # }, 'playlist_mincount': 1623, 'skip': 'Large list', }, { 'url': 'https://www.mixcloud.com/FirstEar/stream/', 'info_dict': { 'id': 'FirstEar_stream', 'title': 'First Ear (stream)', 'description': 'Curators of good music\r\n\r\nfirstearmusic.com', }, 'playlist_mincount': 271, }] _TITLE_KEY = 'displayName' _DESCRIPTION_KEY = 'biog' _ROOT_TYPE = 'user' _NODE_TEMPLATE = '''slug url owner { username }''' def _get_playlist_title(self, title, slug): return '%s (%s)' % (title, slug) class MixcloudPlaylistIE(MixcloudPlaylistBaseIE): _VALID_URL = r'https?://(?:www\.)?mixcloud\.com/(?P<user>[^/]+)/playlists/(?P<playlist>[^/]+)/?$' IE_NAME = 'mixcloud:playlist' _TESTS = [{ 'url': 'https://www.mixcloud.com/maxvibes/playlists/jazzcat-on-ness-radio/', 'info_dict': { 'id': 'maxvibes_jazzcat-on-ness-radio', 'title': 'Ness Radio sessions', }, 'playlist_mincount': 59, }] _TITLE_KEY = 'name' _DESCRIPTION_KEY = 'description' _ROOT_TYPE = 'playlist' _NODE_TEMPLATE = '''cloudcast { slug url owner { username } }''' def _get_cloudcast(self, node): return node.get('cloudcast') or {}
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/googlesearch.py
youtube_dl/extractor/googlesearch.py
from __future__ import unicode_literals import itertools import re from .common import SearchInfoExtractor class GoogleSearchIE(SearchInfoExtractor): IE_DESC = 'Google Video search' _MAX_RESULTS = 1000 IE_NAME = 'video.google:search' _SEARCH_KEY = 'gvsearch' _TEST = { 'url': 'gvsearch15:python language', 'info_dict': { 'id': 'python language', 'title': 'python language', }, 'playlist_count': 15, } def _get_n_results(self, query, n): """Get a specified number of results for a query""" entries = [] res = { '_type': 'playlist', 'id': query, 'title': query, } for pagenum in itertools.count(): webpage = self._download_webpage( 'http://www.google.com/search', 'gvsearch:' + query, note='Downloading result page %s' % (pagenum + 1), query={ 'tbm': 'vid', 'q': query, 'start': pagenum * 10, 'hl': 'en', }) for hit_idx, mobj in enumerate(re.finditer( r'<h3 class="r"><a href="([^"]+)"', webpage)): # Skip playlists if not re.search(r'id="vidthumb%d"' % (hit_idx + 1), webpage): continue entries.append({ '_type': 'url', 'url': mobj.group(1) }) if (len(entries) >= n) or not re.search(r'id="pnnext"', webpage): res['entries'] = entries[:n] return res
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/vrt.py
youtube_dl/extractor/vrt.py
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import ( extract_attributes, float_or_none, get_element_by_class, strip_or_none, unified_timestamp, ) class VRTIE(InfoExtractor): IE_DESC = 'VRT NWS, Flanders News, Flandern Info and Sporza' _VALID_URL = r'https?://(?:www\.)?(?P<site>vrt\.be/vrtnws|sporza\.be)/[a-z]{2}/\d{4}/\d{2}/\d{2}/(?P<id>[^/?&#]+)' _TESTS = [{ 'url': 'https://www.vrt.be/vrtnws/nl/2019/05/15/beelden-van-binnenkant-notre-dame-een-maand-na-de-brand/', 'md5': 'e1663accf5cf13f375f3cd0d10476669', 'info_dict': { 'id': 'pbs-pub-7855fc7b-1448-49bc-b073-316cb60caa71$vid-2ca50305-c38a-4762-9890-65cbd098b7bd', 'ext': 'mp4', 'title': 'Beelden van binnenkant Notre-Dame, één maand na de brand', 'description': 'Op maandagavond 15 april ging een deel van het dakgebinte van de Parijse kathedraal in vlammen op.', 'timestamp': 1557924660, 'upload_date': '20190515', 'duration': 31.2, }, }, { 'url': 'https://sporza.be/nl/2019/05/15/de-belgian-cats-zijn-klaar-voor-het-ek/', 'md5': '910bba927566e9ab992278f647eb4b75', 'info_dict': { 'id': 'pbs-pub-f2c86a46-8138-413a-a4b9-a0015a16ce2c$vid-1f112b31-e58e-4379-908d-aca6d80f8818', 'ext': 'mp4', 'title': 'De Belgian Cats zijn klaar voor het EK mét Ann Wauters', 'timestamp': 1557923760, 'upload_date': '20190515', 'duration': 115.17, }, }, { 'url': 'https://www.vrt.be/vrtnws/en/2019/05/15/belgium_s-eurovision-entry-falls-at-the-first-hurdle/', 'only_matching': True, }, { 'url': 'https://www.vrt.be/vrtnws/de/2019/05/15/aus-fuer-eliott-im-halbfinale-des-eurosongfestivals/', 'only_matching': True, }] _CLIENT_MAP = { 'vrt.be/vrtnws': 'vrtnieuws', 'sporza.be': 'sporza', } def _real_extract(self, url): site, display_id = re.match(self._VALID_URL, url).groups() webpage = self._download_webpage(url, display_id) attrs = extract_attributes(self._search_regex( r'(<[^>]+class="vrtvideo"[^>]*>)', webpage, 'vrt video')) asset_id = attrs['data-videoid'] publication_id = attrs.get('data-publicationid') if publication_id: asset_id = publication_id + '$' + asset_id client = attrs.get('data-client') or self._CLIENT_MAP[site] title = strip_or_none(get_element_by_class( 'vrt-title', webpage) or self._html_search_meta( ['og:title', 'twitter:title', 'name'], webpage)) description = self._html_search_meta( ['og:description', 'twitter:description', 'description'], webpage) if description == '…': description = None timestamp = unified_timestamp(self._html_search_meta( 'article:published_time', webpage)) return { '_type': 'url_transparent', 'id': asset_id, 'display_id': display_id, 'title': title, 'description': description, 'thumbnail': attrs.get('data-posterimage'), 'timestamp': timestamp, 'duration': float_or_none(attrs.get('data-duration'), 1000), 'url': 'https://mediazone.vrt.be/api/v1/%s/assets/%s' % (client, asset_id), 'ie_key': 'Canvas', }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/drtuber.py
youtube_dl/extractor/drtuber.py
from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import ( int_or_none, NO_DEFAULT, parse_duration, str_to_int, ) class DrTuberIE(InfoExtractor): _VALID_URL = r'https?://(?:(?:www|m)\.)?drtuber\.com/(?:video|embed)/(?P<id>\d+)(?:/(?P<display_id>[\w-]+))?' _TESTS = [{ 'url': 'http://www.drtuber.com/video/1740434/hot-perky-blonde-naked-golf', 'md5': '93e680cf2536ad0dfb7e74d94a89facd', 'info_dict': { 'id': '1740434', 'display_id': 'hot-perky-blonde-naked-golf', 'ext': 'mp4', 'title': 'hot perky blonde naked golf', 'like_count': int, 'comment_count': int, 'categories': ['Babe', 'Blonde', 'Erotic', 'Outdoor', 'Softcore', 'Solo'], 'thumbnail': r're:https?://.*\.jpg$', 'age_limit': 18, } }, { 'url': 'http://www.drtuber.com/embed/489939', 'only_matching': True, }, { 'url': 'http://m.drtuber.com/video/3893529/lingerie-blowjob-from-beautiful-teen', 'only_matching': True, }] @staticmethod def _extract_urls(webpage): return re.findall( r'<iframe[^>]+?src=["\'](?P<url>(?:https?:)?//(?:www\.)?drtuber\.com/embed/\d+)', webpage) def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) video_id = mobj.group('id') display_id = mobj.group('display_id') or video_id webpage = self._download_webpage( 'http://www.drtuber.com/video/%s' % video_id, display_id) video_data = self._download_json( 'http://www.drtuber.com/player_config_json/', video_id, query={ 'vid': video_id, 'embed': 0, 'aid': 0, 'domain_id': 0, }) formats = [] for format_id, video_url in video_data['files'].items(): if video_url: formats.append({ 'format_id': format_id, 'quality': 2 if format_id == 'hq' else 1, 'url': video_url }) self._sort_formats(formats) duration = int_or_none(video_data.get('duration')) or parse_duration( video_data.get('duration_format')) title = self._html_search_regex( (r'<h1[^>]+class=["\']title[^>]+>([^<]+)', r'<title>([^<]+)\s*@\s+DrTuber', r'class="title_watch"[^>]*><(?:p|h\d+)[^>]*>([^<]+)<', r'<p[^>]+class="title_substrate">([^<]+)</p>', r'<title>([^<]+) - \d+'), webpage, 'title') thumbnail = self._html_search_regex( r'poster="([^"]+)"', webpage, 'thumbnail', fatal=False) def extract_count(id_, name, default=NO_DEFAULT): return str_to_int(self._html_search_regex( r'<span[^>]+(?:class|id)="%s"[^>]*>([\d,\.]+)</span>' % id_, webpage, '%s count' % name, default=default, fatal=False)) like_count = extract_count('rate_likes', 'like') dislike_count = extract_count('rate_dislikes', 'dislike', default=None) comment_count = extract_count('comments_count', 'comment') cats_str = self._search_regex( r'<div[^>]+class="categories_list">(.+?)</div>', webpage, 'categories', fatal=False) categories = [] if not cats_str else re.findall( r'<a title="([^"]+)"', cats_str) return { 'id': video_id, 'display_id': display_id, 'formats': formats, 'title': title, 'thumbnail': thumbnail, 'like_count': like_count, 'dislike_count': dislike_count, 'comment_count': comment_count, 'categories': categories, 'age_limit': self._rta_search(webpage), 'duration': duration, }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/gedidigital.py
youtube_dl/extractor/gedidigital.py
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import ( determine_ext, int_or_none, ) class GediDigitalIE(InfoExtractor): _VALID_URL = r'''(?x)https?://video\. (?: (?: (?:espresso\.)?repubblica |lastampa |ilsecoloxix )| (?: iltirreno |messaggeroveneto |ilpiccolo |gazzettadimantova |mattinopadova |laprovinciapavese |tribunatreviso |nuovavenezia |gazzettadimodena |lanuovaferrara |corrierealpi |lasentinella )\.gelocal )\.it(?:/[^/]+){2,3}?/(?P<id>\d+)(?:[/?&#]|$)''' _TESTS = [{ 'url': 'https://video.lastampa.it/politica/il-paradosso-delle-regionali-la-lega-vince-ma-sembra-aver-perso/121559/121683', 'md5': '84658d7fb9e55a6e57ecc77b73137494', 'info_dict': { 'id': '121559', 'ext': 'mp4', 'title': 'Il paradosso delle Regionali: ecco perché la Lega vince ma sembra aver perso', 'description': 'md5:de7f4d6eaaaf36c153b599b10f8ce7ca', 'thumbnail': r're:^https://www\.repstatic\.it/video/photo/.+?-thumb-full-.+?\.jpg$', 'duration': 125, }, }, { 'url': 'https://video.espresso.repubblica.it/embed/tutti-i-video/01-ted-villa/14772/14870&width=640&height=360', 'only_matching': True, }, { 'url': 'https://video.repubblica.it/motori/record-della-pista-a-spa-francorchamps-la-pagani-huayra-roadster-bc-stupisce/367415/367963', 'only_matching': True, }, { 'url': 'https://video.ilsecoloxix.it/sport/cassani-e-i-brividi-azzurri-ai-mondiali-di-imola-qui-mi-sono-innamorato-del-ciclismo-da-ragazzino-incredibile-tornarci-da-ct/66184/66267', 'only_matching': True, }, { 'url': 'https://video.iltirreno.gelocal.it/sport/dentro-la-notizia-ferrari-cosa-succede-a-maranello/141059/142723', 'only_matching': True, }, { 'url': 'https://video.messaggeroveneto.gelocal.it/locale/maria-giovanna-elmi-covid-vaccino/138155/139268', 'only_matching': True, }, { 'url': 'https://video.ilpiccolo.gelocal.it/dossier/big-john/dinosauro-big-john-al-via-le-visite-guidate-a-trieste/135226/135751', 'only_matching': True, }, { 'url': 'https://video.gazzettadimantova.gelocal.it/locale/dal-ponte-visconteo-di-valeggio-l-and-8217sos-dei-ristoratori-aprire-anche-a-cena/137310/137818', 'only_matching': True, }, { 'url': 'https://video.mattinopadova.gelocal.it/dossier/coronavirus-in-veneto/covid-a-vo-un-anno-dopo-un-cuore-tricolore-per-non-dimenticare/138402/138964', 'only_matching': True, }, { 'url': 'https://video.laprovinciapavese.gelocal.it/locale/mede-zona-rossa-via-alle-vaccinazioni-per-gli-over-80/137545/138120', 'only_matching': True, }, { 'url': 'https://video.tribunatreviso.gelocal.it/dossier/coronavirus-in-veneto/ecco-le-prima-vaccinazioni-di-massa-nella-marca/134485/135024', 'only_matching': True, }, { 'url': 'https://video.nuovavenezia.gelocal.it/locale/camion-troppo-alto-per-il-ponte-ferroviario-perde-il-carico/135734/136266', 'only_matching': True, }, { 'url': 'https://video.gazzettadimodena.gelocal.it/locale/modena-scoperta-la-proteina-che-predice-il-livello-di-gravita-del-covid/139109/139796', 'only_matching': True, }, { 'url': 'https://video.lanuovaferrara.gelocal.it/locale/due-bombole-di-gpl-aperte-e-abbandonate-i-vigili-bruciano-il-gas/134391/134957', 'only_matching': True, }, { 'url': 'https://video.corrierealpi.gelocal.it/dossier/cortina-2021-i-mondiali-di-sci-alpino/mondiali-di-sci-il-timelapse-sulla-splendida-olympia/133760/134331', 'only_matching': True, }, { 'url': 'https://video.lasentinella.gelocal.it/locale/vestigne-centra-un-auto-e-si-ribalta/138931/139466', 'only_matching': True, }, { 'url': 'https://video.espresso.repubblica.it/tutti-i-video/01-ted-villa/14772', 'only_matching': True, }] def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) title = self._html_search_meta( ['twitter:title', 'og:title'], webpage, fatal=True) player_data = re.findall( r"PlayerFactory\.setParam\('(?P<type>format|param)',\s*'(?P<name>[^']+)',\s*'(?P<val>[^']+)'\);", webpage) formats = [] duration = thumb = None for t, n, v in player_data: if t == 'format': if n in ('video-hds-vod-ec', 'video-hls-vod-ec', 'video-viralize', 'video-youtube-pfp'): continue elif n.endswith('-vod-ak'): formats.extend(self._extract_akamai_formats( v, video_id, {'http': 'media.gedidigital.it'})) else: ext = determine_ext(v) if ext == 'm3u8': formats.extend(self._extract_m3u8_formats( v, video_id, 'mp4', 'm3u8_native', m3u8_id=n, fatal=False)) continue f = { 'format_id': n, 'url': v, } if ext == 'mp3': abr = int_or_none(self._search_regex( r'-mp3-audio-(\d+)', v, 'abr', default=None)) f.update({ 'abr': abr, 'tbr': abr, 'vcodec': 'none' }) else: mobj = re.match(r'^video-rrtv-(\d+)(?:-(\d+))?$', n) if mobj: f.update({ 'height': int(mobj.group(1)), 'vbr': int_or_none(mobj.group(2)), }) if not f.get('vbr'): f['vbr'] = int_or_none(self._search_regex( r'-video-rrtv-(\d+)', v, 'abr', default=None)) formats.append(f) elif t == 'param': if n in ['image_full', 'image']: thumb = v elif n == 'videoDuration': duration = int_or_none(v) self._sort_formats(formats) return { 'id': video_id, 'title': title, 'description': self._html_search_meta( ['twitter:description', 'og:description', 'description'], webpage), 'thumbnail': thumb or self._og_search_thumbnail(webpage), 'formats': formats, 'duration': duration, }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/camtube.py
youtube_dl/extractor/camtube.py
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..utils import ( int_or_none, unified_timestamp, ) class CamTubeIE(InfoExtractor): _VALID_URL = r'https?://(?:(?:www|api)\.)?camtube\.co/recordings?/(?P<id>[^/?#&]+)' _TESTS = [{ 'url': 'https://camtube.co/recording/minafay-030618-1136-chaturbate-female', 'info_dict': { 'id': '42ad3956-dd5b-445a-8313-803ea6079fac', 'display_id': 'minafay-030618-1136-chaturbate-female', 'ext': 'mp4', 'title': 'minafay-030618-1136-chaturbate-female', 'duration': 1274, 'timestamp': 1528018608, 'upload_date': '20180603', 'age_limit': 18 }, 'params': { 'skip_download': True, }, }] _API_BASE = 'https://api.camtube.co' def _real_extract(self, url): display_id = self._match_id(url) token = self._download_json( '%s/rpc/session/new' % self._API_BASE, display_id, 'Downloading session token')['token'] self._set_cookie('api.camtube.co', 'session', token) video = self._download_json( '%s/recordings/%s' % (self._API_BASE, display_id), display_id, headers={'Referer': url}) video_id = video['uuid'] timestamp = unified_timestamp(video.get('createdAt')) duration = int_or_none(video.get('duration')) view_count = int_or_none(video.get('viewCount')) like_count = int_or_none(video.get('likeCount')) creator = video.get('stageName') formats = [{ 'url': '%s/recordings/%s/manifest.m3u8' % (self._API_BASE, video_id), 'format_id': 'hls', 'ext': 'mp4', 'protocol': 'm3u8_native', }] return { 'id': video_id, 'display_id': display_id, 'title': display_id, 'timestamp': timestamp, 'duration': duration, 'view_count': view_count, 'like_count': like_count, 'creator': creator, 'formats': formats, 'age_limit': 18 }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/xtube.py
youtube_dl/extractor/xtube.py
from __future__ import unicode_literals import itertools import re from .common import InfoExtractor from ..utils import ( int_or_none, js_to_json, orderedSet, parse_duration, sanitized_Request, str_to_int, url_or_none, ) class XTubeIE(InfoExtractor): _VALID_URL = r'''(?x) (?: xtube:| https?://(?:www\.)?xtube\.com/(?:watch\.php\?.*\bv=|video-watch/(?:embedded/)?(?P<display_id>[^/]+)-) ) (?P<id>[^/?&#]+) ''' _TESTS = [{ # old URL schema 'url': 'http://www.xtube.com/watch.php?v=kVTUy_G222_', 'md5': '092fbdd3cbe292c920ef6fc6a8a9cdab', 'info_dict': { 'id': 'kVTUy_G222_', 'ext': 'mp4', 'title': 'strange erotica', 'description': 'contains:an ET kind of thing', 'uploader': 'greenshowers', 'duration': 450, 'view_count': int, 'comment_count': int, 'age_limit': 18, } }, { # FLV videos with duplicated formats 'url': 'http://www.xtube.com/video-watch/A-Super-Run-Part-1-YT-9299752', 'md5': 'a406963eb349dd43692ec54631efd88b', 'info_dict': { 'id': '9299752', 'display_id': 'A-Super-Run-Part-1-YT', 'ext': 'flv', 'title': 'A Super Run - Part 1 (YT)', 'description': 'md5:4cc3af1aa1b0413289babc88f0d4f616', 'uploader': 'tshirtguy59', 'duration': 579, 'view_count': int, 'comment_count': int, 'age_limit': 18, }, }, { # new URL schema 'url': 'http://www.xtube.com/video-watch/strange-erotica-625837', 'only_matching': True, }, { 'url': 'xtube:625837', 'only_matching': True, }, { 'url': 'xtube:kVTUy_G222_', 'only_matching': True, }, { 'url': 'https://www.xtube.com/video-watch/embedded/milf-tara-and-teen-shared-and-cum-covered-extreme-bukkake-32203482?embedsize=big', 'only_matching': True, }] def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) video_id = mobj.group('id') display_id = mobj.group('display_id') if not display_id: display_id = video_id if video_id.isdigit() and len(video_id) < 11: url_pattern = 'http://www.xtube.com/video-watch/-%s' else: url_pattern = 'http://www.xtube.com/watch.php?v=%s' webpage = self._download_webpage( url_pattern % video_id, display_id, headers={ 'Cookie': 'age_verified=1; cookiesAccepted=1', }) title, thumbnail, duration, sources, media_definition = [None] * 5 config = self._parse_json(self._search_regex( r'playerConf\s*=\s*({.+?})\s*,\s*(?:\n|loaderConf|playerWrapper)', webpage, 'config', default='{}'), video_id, transform_source=js_to_json, fatal=False) if config: config = config.get('mainRoll') if isinstance(config, dict): title = config.get('title') thumbnail = config.get('poster') duration = int_or_none(config.get('duration')) sources = config.get('sources') or config.get('format') media_definition = config.get('mediaDefinition') if not isinstance(sources, dict) and not media_definition: sources = self._parse_json(self._search_regex( r'(["\'])?sources\1?\s*:\s*(?P<sources>{.+?}),', webpage, 'sources', group='sources'), video_id, transform_source=js_to_json) formats = [] format_urls = set() if isinstance(sources, dict): for format_id, format_url in sources.items(): format_url = url_or_none(format_url) if not format_url: continue if format_url in format_urls: continue format_urls.add(format_url) formats.append({ 'url': format_url, 'format_id': format_id, 'height': int_or_none(format_id), }) if isinstance(media_definition, list): for media in media_definition: video_url = url_or_none(media.get('videoUrl')) if not video_url: continue if video_url in format_urls: continue format_urls.add(video_url) format_id = media.get('format') if format_id == 'hls': formats.extend(self._extract_m3u8_formats( video_url, video_id, 'mp4', entry_protocol='m3u8_native', m3u8_id='hls', fatal=False)) elif format_id == 'mp4': height = int_or_none(media.get('quality')) formats.append({ 'url': video_url, 'format_id': '%s-%d' % (format_id, height) if height else format_id, 'height': height, }) self._remove_duplicate_formats(formats) self._sort_formats(formats) if not title: title = self._search_regex( (r'<h1>\s*(?P<title>[^<]+?)\s*</h1>', r'videoTitle\s*:\s*(["\'])(?P<title>.+?)\1'), webpage, 'title', group='title') description = self._og_search_description( webpage, default=None) or self._html_search_meta( 'twitter:description', webpage, default=None) or self._search_regex( r'</h1>\s*<p>([^<]+)', webpage, 'description', fatal=False) uploader = self._search_regex( (r'<input[^>]+name="contentOwnerId"[^>]+value="([^"]+)"', r'<span[^>]+class="nickname"[^>]*>([^<]+)'), webpage, 'uploader', fatal=False) if not duration: duration = parse_duration(self._search_regex( r'<dt>Runtime:?</dt>\s*<dd>([^<]+)</dd>', webpage, 'duration', fatal=False)) view_count = str_to_int(self._search_regex( (r'["\']viewsCount["\'][^>]*>(\d+)\s+views', r'<dt>Views:?</dt>\s*<dd>([\d,\.]+)</dd>'), webpage, 'view count', fatal=False)) comment_count = str_to_int(self._html_search_regex( r'>Comments? \(([\d,\.]+)\)<', webpage, 'comment count', fatal=False)) return { 'id': video_id, 'display_id': display_id, 'title': title, 'description': description, 'thumbnail': thumbnail, 'uploader': uploader, 'duration': duration, 'view_count': view_count, 'comment_count': comment_count, 'age_limit': 18, 'formats': formats, } class XTubeUserIE(InfoExtractor): IE_DESC = 'XTube user profile' _VALID_URL = r'https?://(?:www\.)?xtube\.com/profile/(?P<id>[^/]+-\d+)' _TEST = { 'url': 'http://www.xtube.com/profile/greenshowers-4056496', 'info_dict': { 'id': 'greenshowers-4056496', 'age_limit': 18, }, 'playlist_mincount': 154, } def _real_extract(self, url): user_id = self._match_id(url) entries = [] for pagenum in itertools.count(1): request = sanitized_Request( 'http://www.xtube.com/profile/%s/videos/%d' % (user_id, pagenum), headers={ 'Cookie': 'popunder=4', 'X-Requested-With': 'XMLHttpRequest', 'Referer': url, }) page = self._download_json( request, user_id, 'Downloading videos JSON page %d' % pagenum) html = page.get('html') if not html: break for video_id in orderedSet([video_id for _, video_id in re.findall( r'data-plid=(["\'])(.+?)\1', html)]): entries.append(self.url_result('xtube:%s' % video_id, XTubeIE.ie_key())) page_count = int_or_none(page.get('pageCount')) if not page_count or pagenum == page_count: break playlist = self.playlist_result(entries, user_id) playlist['age_limit'] = 18 return playlist
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/rmcdecouverte.py
youtube_dl/extractor/rmcdecouverte.py
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor from .brightcove import BrightcoveLegacyIE from ..compat import ( compat_parse_qs, compat_urlparse, ) from ..utils import smuggle_url class RMCDecouverteIE(InfoExtractor): _VALID_URL = r'https?://rmcdecouverte\.bfmtv\.com/(?:(?:[^/]+/)*program_(?P<id>\d+)|(?P<live_id>mediaplayer-direct))' _TESTS = [{ 'url': 'https://rmcdecouverte.bfmtv.com/wheeler-dealers-occasions-a-saisir/program_2566/', 'info_dict': { 'id': '5983675500001', 'ext': 'mp4', 'title': 'CORVETTE', 'description': 'md5:c1e8295521e45ffebf635d6a7658f506', 'uploader_id': '1969646226001', 'upload_date': '20181226', 'timestamp': 1545861635, }, 'params': { 'skip_download': True, }, 'skip': 'only available for a week', }, { # live, geo restricted, bypassable 'url': 'https://rmcdecouverte.bfmtv.com/mediaplayer-direct/', 'only_matching': True, }] BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/1969646226001/default_default/index.html?videoId=%s' def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) display_id = mobj.group('id') or mobj.group('live_id') webpage = self._download_webpage(url, display_id) brightcove_legacy_url = BrightcoveLegacyIE._extract_brightcove_url(webpage) if brightcove_legacy_url: brightcove_id = compat_parse_qs(compat_urlparse.urlparse( brightcove_legacy_url).query)['@videoPlayer'][0] else: brightcove_id = self._search_regex( r'data-video-id=["\'](\d+)', webpage, 'brightcove id') return self.url_result( smuggle_url( self.BRIGHTCOVE_URL_TEMPLATE % brightcove_id, {'geo_countries': ['FR']}), 'BrightcoveNew', brightcove_id)
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/onionstudios.py
youtube_dl/extractor/onionstudios.py
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor from ..compat import compat_str from ..utils import js_to_json class OnionStudiosIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?onionstudios\.com/(?:video(?:s/[^/]+-|/)|embed\?.*\bid=)(?P<id>\d+)(?!-)' _TESTS = [{ 'url': 'http://www.onionstudios.com/videos/hannibal-charges-forward-stops-for-a-cocktail-2937', 'md5': '5a118d466d62b5cd03647cf2c593977f', 'info_dict': { 'id': '3459881', 'ext': 'mp4', 'title': 'Hannibal charges forward, stops for a cocktail', 'description': 'md5:545299bda6abf87e5ec666548c6a9448', 'thumbnail': r're:^https?://.*\.jpg$', 'uploader': 'a.v. club', 'upload_date': '20150619', 'timestamp': 1434728546, }, }, { 'url': 'http://www.onionstudios.com/embed?id=2855&autoplay=true', 'only_matching': True, }, { 'url': 'http://www.onionstudios.com/video/6139.json', 'only_matching': True, }] @staticmethod def _extract_url(webpage): mobj = re.search( r'(?s)<(?:iframe|bulbs-video)[^>]+?src=(["\'])(?P<url>(?:https?:)?//(?:www\.)?onionstudios\.com/(?:embed.+?|video/\d+\.json))\1', webpage) if mobj: return mobj.group('url') def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage( 'http://onionstudios.com/embed/dc94dc2899fe644c0e7241fa04c1b732.js', video_id) mcp_id = compat_str(self._parse_json(self._search_regex( r'window\.mcpMapping\s*=\s*({.+?});', webpage, 'MCP Mapping'), video_id, js_to_json)[video_id]['mcp_id']) return self.url_result( 'http://kinja.com/ajax/inset/iframe?id=mcp-' + mcp_id, 'KinjaEmbed', mcp_id)
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/regiotv.py
youtube_dl/extractor/regiotv.py
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..utils import ( sanitized_Request, xpath_text, xpath_with_ns, ) class RegioTVIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?regio-tv\.de/video/(?P<id>[0-9]+)' _TESTS = [{ 'url': 'http://www.regio-tv.de/video/395808.html', 'info_dict': { 'id': '395808', 'ext': 'mp4', 'title': 'Wir in Ludwigsburg', 'description': 'Mit unseren zuckersüßen Adventskindern, außerdem besuchen wir die Abendsterne!', } }, { 'url': 'http://www.regio-tv.de/video/395808', 'only_matching': True, }] def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) key = self._search_regex( r'key\s*:\s*(["\'])(?P<key>.+?)\1', webpage, 'key', group='key') title = self._og_search_title(webpage) SOAP_TEMPLATE = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><{0} xmlns="http://v.telvi.de/"><key xsi:type="xsd:string">{1}</key></{0}></soap:Body></soap:Envelope>' request = sanitized_Request( 'http://v.telvi.de/', SOAP_TEMPLATE.format('GetHTML5VideoData', key).encode('utf-8')) video_data = self._download_xml(request, video_id, 'Downloading video XML') NS_MAP = { 'xsi': 'http://www.w3.org/2001/XMLSchema-instance', 'soap': 'http://schemas.xmlsoap.org/soap/envelope/', } video_url = xpath_text( video_data, xpath_with_ns('.//video', NS_MAP), 'video url', fatal=True) thumbnail = xpath_text( video_data, xpath_with_ns('.//image', NS_MAP), 'thumbnail') description = self._og_search_description( webpage) or self._html_search_meta('description', webpage) return { 'id': video_id, 'url': video_url, 'title': title, 'description': description, 'thumbnail': thumbnail, }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/clipchamp.py
youtube_dl/extractor/clipchamp.py
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..compat import compat_str from ..utils import ( ExtractorError, merge_dicts, T, traverse_obj, unified_timestamp, url_or_none, ) class ClipchampIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?clipchamp\.com/watch/(?P<id>[\w-]+)' _TESTS = [{ 'url': 'https://clipchamp.com/watch/gRXZ4ZhdDaU', 'info_dict': { 'id': 'gRXZ4ZhdDaU', 'ext': 'mp4', 'title': 'Untitled video', 'uploader': 'Alexander Schwartz', 'timestamp': 1680805580, 'upload_date': '20230406', 'thumbnail': r're:^https?://.+\.jpg', }, 'params': { 'skip_download': 'm3u8', 'format': 'bestvideo', }, }] _STREAM_URL_TMPL = 'https://%s.cloudflarestream.com/%s/manifest/video.%s' _STREAM_URL_QUERY = {'parentOrigin': 'https://clipchamp.com'} def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) data = self._search_nextjs_data(webpage, video_id)['props']['pageProps']['video'] storage_location = data.get('storage_location') if storage_location != 'cf_stream': raise ExtractorError('Unsupported clip storage location "%s"' % (storage_location,)) path = data['download_url'] iframe = self._download_webpage( 'https://iframe.cloudflarestream.com/' + path, video_id, 'Downloading player iframe') subdomain = self._search_regex( r'''\bcustomer-domain-prefix\s*=\s*("|')(?P<sd>[\w-]+)\1''', iframe, 'subdomain', group='sd', fatal=False) or 'customer-2ut9yn3y6fta1yxe' formats = self._extract_mpd_formats( self._STREAM_URL_TMPL % (subdomain, path, 'mpd'), video_id, query=self._STREAM_URL_QUERY, fatal=False, mpd_id='dash') formats.extend(self._extract_m3u8_formats( self._STREAM_URL_TMPL % (subdomain, path, 'm3u8'), video_id, 'mp4', query=self._STREAM_URL_QUERY, fatal=False, m3u8_id='hls')) return merge_dicts({ 'id': video_id, 'formats': formats, 'uploader': ' '.join(traverse_obj(data, ('creator', ('first_name', 'last_name'), T(compat_str)))) or None, }, traverse_obj(data, { 'title': ('project', 'project_name', T(compat_str)), 'timestamp': ('created_at', T(unified_timestamp)), 'thumbnail': ('thumbnail_url', T(url_or_none)), }), rev=True)
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/dtube.py
youtube_dl/extractor/dtube.py
# coding: utf-8 from __future__ import unicode_literals import json import re from socket import timeout from .common import InfoExtractor from ..utils import ( int_or_none, parse_iso8601, ) class DTubeIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?d\.tube/(?:#!/)?v/(?P<uploader_id>[0-9a-z.-]+)/(?P<id>[0-9a-z]{8})' _TEST = { 'url': 'https://d.tube/#!/v/broncnutz/x380jtr1', 'md5': '9f29088fa08d699a7565ee983f56a06e', 'info_dict': { 'id': 'x380jtr1', 'ext': 'mp4', 'title': 'Lefty 3-Rings is Back Baby!! NCAA Picks', 'description': 'md5:60be222088183be3a42f196f34235776', 'uploader_id': 'broncnutz', 'upload_date': '20190107', 'timestamp': 1546854054, }, 'params': { 'format': '480p', }, } def _real_extract(self, url): uploader_id, video_id = re.match(self._VALID_URL, url).groups() result = self._download_json('https://api.steemit.com/', video_id, data=json.dumps({ 'jsonrpc': '2.0', 'method': 'get_content', 'params': [uploader_id, video_id], }).encode())['result'] metadata = json.loads(result['json_metadata']) video = metadata['video'] content = video['content'] info = video.get('info', {}) title = info.get('title') or result['title'] def canonical_url(h): if not h: return None return 'https://video.dtube.top/ipfs/' + h formats = [] for q in ('240', '480', '720', '1080', ''): video_url = canonical_url(content.get('video%shash' % q)) if not video_url: continue format_id = (q + 'p') if q else 'Source' try: self.to_screen('%s: Checking %s video format URL' % (video_id, format_id)) self._downloader._opener.open(video_url, timeout=5).close() except timeout: self.to_screen( '%s: %s URL is invalid, skipping' % (video_id, format_id)) continue formats.append({ 'format_id': format_id, 'url': video_url, 'height': int_or_none(q), 'ext': 'mp4', }) return { 'id': video_id, 'title': title, 'description': content.get('description'), 'thumbnail': canonical_url(info.get('snaphash')), 'tags': content.get('tags') or metadata.get('tags'), 'duration': info.get('duration'), 'formats': formats, 'timestamp': parse_iso8601(result.get('created')), 'uploader_id': uploader_id, }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/pladform.py
youtube_dl/extractor/pladform.py
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor from ..compat import compat_urlparse from ..utils import ( determine_ext, ExtractorError, int_or_none, xpath_text, qualities, ) class PladformIE(InfoExtractor): _VALID_URL = r'''(?x) https?:// (?: (?: out\.pladform\.ru/player| static\.pladform\.ru/player\.swf ) \?.*\bvideoid=| video\.pladform\.ru/catalog/video/videoid/ ) (?P<id>\d+) ''' _TESTS = [{ 'url': 'https://out.pladform.ru/player?pl=64471&videoid=3777899&vk_puid15=0&vk_puid34=0', 'md5': '53362fac3a27352da20fa2803cc5cd6f', 'info_dict': { 'id': '3777899', 'ext': 'mp4', 'title': 'СТУДИЯ СОЮЗ • Шоу Студия Союз, 24 выпуск (01.02.2018) Нурлан Сабуров и Слава Комиссаренко', 'description': 'md5:05140e8bf1b7e2d46e7ba140be57fd95', 'thumbnail': r're:^https?://.*\.jpg$', 'duration': 3190, }, }, { 'url': 'http://static.pladform.ru/player.swf?pl=21469&videoid=100183293&vkcid=0', 'only_matching': True, }, { 'url': 'http://video.pladform.ru/catalog/video/videoid/100183293/vkcid/0', 'only_matching': True, }] @staticmethod def _extract_url(webpage): mobj = re.search( r'<iframe[^>]+src=(["\'])(?P<url>(?:https?:)?//out\.pladform\.ru/player\?.+?)\1', webpage) if mobj: return mobj.group('url') def _real_extract(self, url): video_id = self._match_id(url) qs = compat_urlparse.parse_qs(compat_urlparse.urlparse(url).query) pl = qs.get('pl', ['1'])[0] video = self._download_xml( 'http://out.pladform.ru/getVideo', video_id, query={ 'pl': pl, 'videoid': video_id, }) def fail(text): raise ExtractorError( '%s returned error: %s' % (self.IE_NAME, text), expected=True) if video.tag == 'error': fail(video.text) quality = qualities(('ld', 'sd', 'hd')) formats = [] for src in video.findall('./src'): if src is None: continue format_url = src.text if not format_url: continue if src.get('type') == 'hls' or determine_ext(format_url) == 'm3u8': formats.extend(self._extract_m3u8_formats( format_url, video_id, 'mp4', entry_protocol='m3u8_native', m3u8_id='hls', fatal=False)) else: formats.append({ 'url': src.text, 'format_id': src.get('quality'), 'quality': quality(src.get('quality')), }) if not formats: error = xpath_text(video, './cap', 'error', default=None) if error: fail(error) self._sort_formats(formats) webpage = self._download_webpage( 'http://video.pladform.ru/catalog/video/videoid/%s' % video_id, video_id) title = self._og_search_title(webpage, fatal=False) or xpath_text( video, './/title', 'title', fatal=True) description = self._search_regex( r'</h3>\s*<p>([^<]+)</p>', webpage, 'description', fatal=False) thumbnail = self._og_search_thumbnail(webpage) or xpath_text( video, './/cover', 'cover') duration = int_or_none(xpath_text(video, './/time', 'duration')) age_limit = int_or_none(xpath_text(video, './/age18', 'age limit')) return { 'id': video_id, 'title': title, 'description': description, 'thumbnail': thumbnail, 'duration': duration, 'age_limit': age_limit, 'formats': formats, }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/kickstarter.py
youtube_dl/extractor/kickstarter.py
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..utils import smuggle_url class KickStarterIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?kickstarter\.com/projects/(?P<id>[^/]*)/.*' _TESTS = [{ 'url': 'https://www.kickstarter.com/projects/1404461844/intersection-the-story-of-josh-grant/description', 'md5': 'c81addca81327ffa66c642b5d8b08cab', 'info_dict': { 'id': '1404461844', 'ext': 'mp4', 'title': 'Intersection: The Story of Josh Grant by Kyle Cowling', 'description': ( 'A unique motocross documentary that examines the ' 'life and mind of one of sports most elite athletes: Josh Grant.' ), }, }, { 'note': 'Embedded video (not using the native kickstarter video service)', 'url': 'https://www.kickstarter.com/projects/597507018/pebble-e-paper-watch-for-iphone-and-android/posts/659178', 'info_dict': { 'id': '78704821', 'ext': 'mp4', 'uploader_id': 'pebble', 'uploader': 'Pebble Technology', 'title': 'Pebble iOS Notifications', }, 'add_ie': ['Vimeo'], }, { 'url': 'https://www.kickstarter.com/projects/1420158244/power-drive-2000/widget/video.html', 'info_dict': { 'id': '1420158244', 'ext': 'mp4', 'title': 'Power Drive 2000', }, }] def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) title = self._html_search_regex( r'<title>\s*(.*?)(?:\s*&mdash;\s*Kickstarter)?\s*</title>', webpage, 'title') video_url = self._search_regex( r'data-video-url="(.*?)"', webpage, 'video URL', default=None) if video_url is None: # No native kickstarter, look for embedded videos return { '_type': 'url_transparent', 'ie_key': 'Generic', 'url': smuggle_url(url, {'to_generic': True}), 'title': title, } thumbnail = self._og_search_thumbnail(webpage, default=None) if thumbnail is None: thumbnail = self._html_search_regex( r'<img[^>]+class="[^"]+\s*poster\s*[^"]+"[^>]+src="([^"]+)"', webpage, 'thumbnail image', fatal=False) return { 'id': video_id, 'url': video_url, 'title': title, 'description': self._og_search_description(webpage, default=None), 'thumbnail': thumbnail, }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/bellmedia.py
youtube_dl/extractor/bellmedia.py
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor class BellMediaIE(InfoExtractor): _VALID_URL = r'''(?x)https?://(?:www\.)? (?P<domain> (?: ctv| tsn| bnn(?:bloomberg)?| thecomedynetwork| discovery| discoveryvelocity| sciencechannel| investigationdiscovery| animalplanet| bravo| mtv| space| etalk| marilyn )\.ca| (?:much|cp24)\.com )/.*?(?:\b(?:vid(?:eoid)?|clipId)=|-vid|~|%7E|/(?:episode)?)(?P<id>[0-9]{6,})''' _TESTS = [{ 'url': 'https://www.bnnbloomberg.ca/video/david-cockfield-s-top-picks~1403070', 'md5': '36d3ef559cfe8af8efe15922cd3ce950', 'info_dict': { 'id': '1403070', 'ext': 'flv', 'title': 'David Cockfield\'s Top Picks', 'description': 'md5:810f7f8c6a83ad5b48677c3f8e5bb2c3', 'upload_date': '20180525', 'timestamp': 1527288600, }, }, { 'url': 'http://www.thecomedynetwork.ca/video/player?vid=923582', 'only_matching': True, }, { 'url': 'http://www.tsn.ca/video/expectations-high-for-milos-raonic-at-us-open~939549', 'only_matching': True, }, { 'url': 'http://www.bnn.ca/video/berman-s-call-part-two-viewer-questions~939654', 'only_matching': True, }, { 'url': 'http://www.ctv.ca/YourMorning/Video/S1E6-Monday-August-29-2016-vid938009', 'only_matching': True, }, { 'url': 'http://www.much.com/shows/atmidnight/episode948007/tuesday-september-13-2016', 'only_matching': True, }, { 'url': 'http://www.much.com/shows/the-almost-impossible-gameshow/928979/episode-6', 'only_matching': True, }, { 'url': 'http://www.ctv.ca/DCs-Legends-of-Tomorrow/Video/S2E11-Turncoat-vid1051430', 'only_matching': True, }, { 'url': 'http://www.etalk.ca/video?videoid=663455', 'only_matching': True, }, { 'url': 'https://www.cp24.com/video?clipId=1982548', 'only_matching': True, }] _DOMAINS = { 'thecomedynetwork': 'comedy', 'discoveryvelocity': 'discvel', 'sciencechannel': 'discsci', 'investigationdiscovery': 'invdisc', 'animalplanet': 'aniplan', 'etalk': 'ctv', 'bnnbloomberg': 'bnn', 'marilyn': 'ctv_marilyn', } def _real_extract(self, url): domain, video_id = re.match(self._VALID_URL, url).groups() domain = domain.split('.')[0] return { '_type': 'url_transparent', 'id': video_id, 'url': '9c9media:%s_web:%s' % (self._DOMAINS.get(domain, domain), video_id), 'ie_key': 'NineCNineMedia', }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/digiteka.py
youtube_dl/extractor/digiteka.py
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import int_or_none class DigitekaIE(InfoExtractor): _VALID_URL = r'''(?x) https?://(?:www\.)?(?:digiteka\.net|ultimedia\.com)/ (?: deliver/ (?P<embed_type> generic| musique ) (?:/[^/]+)*/ (?: src| article )| default/index/video (?P<site_type> generic| music ) /id )/(?P<id>[\d+a-z]+)''' _TESTS = [{ # news 'url': 'https://www.ultimedia.com/default/index/videogeneric/id/s8uk0r', 'md5': '276a0e49de58c7e85d32b057837952a2', 'info_dict': { 'id': 's8uk0r', 'ext': 'mp4', 'title': 'Loi sur la fin de vie: le texte prévoit un renforcement des directives anticipées', 'thumbnail': r're:^https?://.*\.jpg', 'duration': 74, 'upload_date': '20150317', 'timestamp': 1426604939, 'uploader_id': '3fszv', }, }, { # music 'url': 'https://www.ultimedia.com/default/index/videomusic/id/xvpfp8', 'md5': '2ea3513813cf230605c7e2ffe7eca61c', 'info_dict': { 'id': 'xvpfp8', 'ext': 'mp4', 'title': 'Two - C\'est La Vie (clip)', 'thumbnail': r're:^https?://.*\.jpg', 'duration': 233, 'upload_date': '20150224', 'timestamp': 1424760500, 'uploader_id': '3rfzk', }, }, { 'url': 'https://www.digiteka.net/deliver/generic/iframe/mdtk/01637594/src/lqm3kl/zone/1/showtitle/1/autoplay/yes', 'only_matching': True, }] @staticmethod def _extract_url(webpage): mobj = re.search( r'<(?:iframe|script)[^>]+src=["\'](?P<url>(?:https?:)?//(?:www\.)?ultimedia\.com/deliver/(?:generic|musique)(?:/[^/]+)*/(?:src|article)/[\d+a-z]+)', webpage) if mobj: return mobj.group('url') def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) video_id = mobj.group('id') video_type = mobj.group('embed_type') or mobj.group('site_type') if video_type == 'music': video_type = 'musique' deliver_info = self._download_json( 'http://www.ultimedia.com/deliver/video?video=%s&topic=%s' % (video_id, video_type), video_id) yt_id = deliver_info.get('yt_id') if yt_id: return self.url_result(yt_id, 'Youtube') jwconf = deliver_info['jwconf'] formats = [] for source in jwconf['playlist'][0]['sources']: formats.append({ 'url': source['file'], 'format_id': source.get('label'), }) self._sort_formats(formats) title = deliver_info['title'] thumbnail = jwconf.get('image') duration = int_or_none(deliver_info.get('duration')) timestamp = int_or_none(deliver_info.get('release_time')) uploader_id = deliver_info.get('owner_id') return { 'id': video_id, 'title': title, 'thumbnail': thumbnail, 'duration': duration, 'timestamp': timestamp, 'uploader_id': uploader_id, 'formats': formats, }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/hypem.py
youtube_dl/extractor/hypem.py
from __future__ import unicode_literals from .common import InfoExtractor from ..utils import int_or_none class HypemIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?hypem\.com/track/(?P<id>[0-9a-z]{5})' _TEST = { 'url': 'http://hypem.com/track/1v6ga/BODYWORK+-+TAME', 'md5': 'b9cc91b5af8995e9f0c1cee04c575828', 'info_dict': { 'id': '1v6ga', 'ext': 'mp3', 'title': 'Tame', 'uploader': 'BODYWORK', 'timestamp': 1371810457, 'upload_date': '20130621', } } def _real_extract(self, url): track_id = self._match_id(url) response = self._download_webpage(url, track_id) track = self._parse_json(self._html_search_regex( r'(?s)<script\s+type="application/json"\s+id="displayList-data">(.+?)</script>', response, 'tracks'), track_id)['tracks'][0] track_id = track['id'] title = track['song'] final_url = self._download_json( 'http://hypem.com/serve/source/%s/%s' % (track_id, track['key']), track_id, 'Downloading metadata', headers={ 'Content-Type': 'application/json' })['url'] return { 'id': track_id, 'url': final_url, 'ext': 'mp3', 'title': title, 'uploader': track.get('artist'), 'duration': int_or_none(track.get('time')), 'timestamp': int_or_none(track.get('ts')), 'track': title, }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/unity.py
youtube_dl/extractor/unity.py
from __future__ import unicode_literals from .common import InfoExtractor from .youtube import YoutubeIE class UnityIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?unity3d\.com/learn/tutorials/(?:[^/]+/)*(?P<id>[^/?#&]+)' _TESTS = [{ 'url': 'https://unity3d.com/learn/tutorials/topics/animation/animate-anything-mecanim', 'info_dict': { 'id': 'jWuNtik0C8E', 'ext': 'mp4', 'title': 'Live Training 22nd September 2014 - Animate Anything', 'description': 'md5:e54913114bd45a554c56cdde7669636e', 'duration': 2893, 'uploader': 'Unity', 'uploader_id': 'Unity3D', 'upload_date': '20140926', } }, { 'url': 'https://unity3d.com/learn/tutorials/projects/2d-ufo-tutorial/following-player-camera?playlist=25844', 'only_matching': True, }] def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) youtube_id = self._search_regex( r'data-video-id="([_0-9a-zA-Z-]+)"', webpage, 'youtube ID') return self.url_result(youtube_id, ie=YoutubeIE.ie_key(), video_id=video_id)
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/trutv.py
youtube_dl/extractor/trutv.py
# coding: utf-8 from __future__ import unicode_literals import re from .turner import TurnerBaseIE from ..utils import ( int_or_none, parse_iso8601, ) class TruTVIE(TurnerBaseIE): _VALID_URL = r'https?://(?:www\.)?trutv\.com/(?:shows|full-episodes)/(?P<series_slug>[0-9A-Za-z-]+)/(?:videos/(?P<clip_slug>[0-9A-Za-z-]+)|(?P<id>\d+))' _TEST = { 'url': 'https://www.trutv.com/shows/the-carbonaro-effect/videos/sunlight-activated-flower.html', 'info_dict': { 'id': 'f16c03beec1e84cd7d1a51f11d8fcc29124cc7f1', 'ext': 'mp4', 'title': 'Sunlight-Activated Flower', 'description': "A customer is stunned when he sees Michael's sunlight-activated flower.", }, 'params': { # m3u8 download 'skip_download': True, }, } def _real_extract(self, url): series_slug, clip_slug, video_id = re.match(self._VALID_URL, url).groups() if video_id: path = 'episode' display_id = video_id else: path = 'series/clip' display_id = clip_slug data = self._download_json( 'https://api.trutv.com/v2/web/%s/%s/%s' % (path, series_slug, display_id), display_id) video_data = data['episode'] if video_id else data['info'] media_id = video_data['mediaId'] title = video_data['title'].strip() info = self._extract_ngtv_info( media_id, {}, { 'url': url, 'site_name': 'truTV', 'auth_required': video_data.get('isAuthRequired'), }) thumbnails = [] for image in video_data.get('images', []): image_url = image.get('srcUrl') if not image_url: continue thumbnails.append({ 'url': image_url, 'width': int_or_none(image.get('width')), 'height': int_or_none(image.get('height')), }) info.update({ 'id': media_id, 'display_id': display_id, 'title': title, 'description': video_data.get('description'), 'thumbnails': thumbnails, 'timestamp': parse_iso8601(video_data.get('publicationDate')), 'series': video_data.get('showTitle'), 'season_number': int_or_none(video_data.get('seasonNum')), 'episode_number': int_or_none(video_data.get('episodeNum')), }) return info
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/playplustv.py
youtube_dl/extractor/playplustv.py
# coding: utf-8 from __future__ import unicode_literals import json import re from .common import InfoExtractor from ..compat import compat_HTTPError from ..utils import ( clean_html, ExtractorError, int_or_none, PUTRequest, ) class PlayPlusTVIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?playplus\.(?:com|tv)/VOD/(?P<project_id>[0-9]+)/(?P<id>[0-9a-f]{32})' _TEST = { 'url': 'https://www.playplus.tv/VOD/7572/db8d274a5163424e967f35a30ddafb8e', 'md5': 'd078cb89d7ab6b9df37ce23c647aef72', 'info_dict': { 'id': 'db8d274a5163424e967f35a30ddafb8e', 'ext': 'mp4', 'title': 'Capítulo 179 - Final', 'description': 'md5:01085d62d8033a1e34121d3c3cabc838', 'timestamp': 1529992740, 'upload_date': '20180626', }, 'skip': 'Requires account credential', } _NETRC_MACHINE = 'playplustv' _GEO_COUNTRIES = ['BR'] _token = None _profile_id = None def _call_api(self, resource, video_id=None, query=None): return self._download_json('https://api.playplus.tv/api/media/v2/get' + resource, video_id, headers={ 'Authorization': 'Bearer ' + self._token, }, query=query) def _real_initialize(self): email, password = self._get_login_info() if email is None: self.raise_login_required() req = PUTRequest( 'https://api.playplus.tv/api/web/login', json.dumps({ 'email': email, 'password': password, }).encode(), { 'Content-Type': 'application/json; charset=utf-8', }) try: self._token = self._download_json(req, None)['token'] except ExtractorError as e: if isinstance(e.cause, compat_HTTPError) and e.cause.code == 401: raise ExtractorError(self._parse_json( e.cause.read(), None)['errorMessage'], expected=True) raise self._profile = self._call_api('Profiles')['list'][0]['_id'] def _real_extract(self, url): project_id, media_id = re.match(self._VALID_URL, url).groups() media = self._call_api( 'Media', media_id, { 'profileId': self._profile, 'projectId': project_id, 'mediaId': media_id, })['obj'] title = media['title'] formats = [] for f in media.get('files', []): f_url = f.get('url') if not f_url: continue file_info = f.get('fileInfo') or {} formats.append({ 'url': f_url, 'width': int_or_none(file_info.get('width')), 'height': int_or_none(file_info.get('height')), }) self._sort_formats(formats) thumbnails = [] for thumb in media.get('thumbs', []): thumb_url = thumb.get('url') if not thumb_url: continue thumbnails.append({ 'url': thumb_url, 'width': int_or_none(thumb.get('width')), 'height': int_or_none(thumb.get('height')), }) return { 'id': media_id, 'title': title, 'formats': formats, 'thumbnails': thumbnails, 'description': clean_html(media.get('description')) or media.get('shortDescription'), 'timestamp': int_or_none(media.get('publishDate'), 1000), 'view_count': int_or_none(media.get('numberOfViews')), 'comment_count': int_or_none(media.get('numberOfComments')), 'tags': media.get('tags'), }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/ynet.py
youtube_dl/extractor/ynet.py
# coding: utf-8 from __future__ import unicode_literals import re import json from .common import InfoExtractor from ..compat import compat_urllib_parse_unquote_plus class YnetIE(InfoExtractor): _VALID_URL = r'https?://(?:.+?\.)?ynet\.co\.il/(?:.+?/)?0,7340,(?P<id>L(?:-[0-9]+)+),00\.html' _TESTS = [ { 'url': 'http://hot.ynet.co.il/home/0,7340,L-11659-99244,00.html', 'info_dict': { 'id': 'L-11659-99244', 'ext': 'flv', 'title': 'איש לא יודע מאיפה באנו', 'thumbnail': r're:^https?://.*\.jpg', } }, { 'url': 'http://hot.ynet.co.il/home/0,7340,L-8859-84418,00.html', 'info_dict': { 'id': 'L-8859-84418', 'ext': 'flv', 'title': "צפו: הנשיקה הלוהטת של תורגי' ויוליה פלוטקין", 'thumbnail': r're:^https?://.*\.jpg', } } ] def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) content = compat_urllib_parse_unquote_plus(self._og_search_video_url(webpage)) config = json.loads(self._search_regex(r'config=({.+?})$', content, 'video config')) f4m_url = config['clip']['url'] title = self._og_search_title(webpage) m = re.search(r'ynet - HOT -- (["\']+)(?P<title>.+?)\1', title) if m: title = m.group('title') formats = self._extract_f4m_formats(f4m_url, video_id) self._sort_formats(formats) return { 'id': video_id, 'title': title, 'formats': formats, 'thumbnail': self._og_search_thumbnail(webpage), }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/canalplus.py
youtube_dl/extractor/canalplus.py
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import ( # ExtractorError, # HEADRequest, int_or_none, qualities, unified_strdate, ) class CanalplusIE(InfoExtractor): IE_DESC = 'mycanal.fr and piwiplus.fr' _VALID_URL = r'https?://(?:www\.)?(?P<site>mycanal|piwiplus)\.fr/(?:[^/]+/)*(?P<display_id>[^?/]+)(?:\.html\?.*\bvid=|/p/)(?P<id>\d+)' _VIDEO_INFO_TEMPLATE = 'http://service.canal-plus.com/video/rest/getVideosLiees/%s/%s?format=json' _SITE_ID_MAP = { 'mycanal': 'cplus', 'piwiplus': 'teletoon', } # Only works for direct mp4 URLs _GEO_COUNTRIES = ['FR'] _TESTS = [{ 'url': 'https://www.mycanal.fr/d17-emissions/lolywood/p/1397061', 'info_dict': { 'id': '1397061', 'display_id': 'lolywood', 'ext': 'mp4', 'title': 'Euro 2016 : Je préfère te prévenir - Lolywood - Episode 34', 'description': 'md5:7d97039d455cb29cdba0d652a0efaa5e', 'upload_date': '20160602', }, }, { # geo restricted, bypassed 'url': 'http://www.piwiplus.fr/videos-piwi/pid1405-le-labyrinthe-boing-super-ranger.html?vid=1108190', 'info_dict': { 'id': '1108190', 'display_id': 'pid1405-le-labyrinthe-boing-super-ranger', 'ext': 'mp4', 'title': 'BOING SUPER RANGER - Ep : Le labyrinthe', 'description': 'md5:4cea7a37153be42c1ba2c1d3064376ff', 'upload_date': '20140724', }, 'expected_warnings': ['HTTP Error 403: Forbidden'], }] def _real_extract(self, url): site, display_id, video_id = re.match(self._VALID_URL, url).groups() site_id = self._SITE_ID_MAP[site] info_url = self._VIDEO_INFO_TEMPLATE % (site_id, video_id) video_data = self._download_json(info_url, video_id, 'Downloading video JSON') if isinstance(video_data, list): video_data = [video for video in video_data if video.get('ID') == video_id][0] media = video_data['MEDIA'] infos = video_data['INFOS'] preference = qualities(['MOBILE', 'BAS_DEBIT', 'HAUT_DEBIT', 'HD']) # _, fmt_url = next(iter(media['VIDEOS'].items())) # if '/geo' in fmt_url.lower(): # response = self._request_webpage( # HEADRequest(fmt_url), video_id, # 'Checking if the video is georestricted') # if '/blocage' in response.geturl(): # raise ExtractorError( # 'The video is not available in your country', # expected=True) formats = [] for format_id, format_url in media['VIDEOS'].items(): if not format_url: continue if format_id == 'HLS': formats.extend(self._extract_m3u8_formats( format_url, video_id, 'mp4', 'm3u8_native', m3u8_id=format_id, fatal=False)) elif format_id == 'HDS': formats.extend(self._extract_f4m_formats( format_url + '?hdcore=2.11.3', video_id, f4m_id=format_id, fatal=False)) else: formats.append({ # the secret extracted from ya function in http://player.canalplus.fr/common/js/canalPlayer.js 'url': format_url + '?secret=pqzerjlsmdkjfoiuerhsdlfknaes', 'format_id': format_id, 'preference': preference(format_id), }) self._sort_formats(formats) thumbnails = [{ 'id': image_id, 'url': image_url, } for image_id, image_url in media.get('images', {}).items()] titrage = infos['TITRAGE'] return { 'id': video_id, 'display_id': display_id, 'title': '%s - %s' % (titrage['TITRE'], titrage['SOUS_TITRE']), 'upload_date': unified_strdate(infos.get('PUBLICATION', {}).get('DATE')), 'thumbnails': thumbnails, 'description': infos.get('DESCRIPTION'), 'duration': int_or_none(infos.get('DURATION')), 'view_count': int_or_none(infos.get('NB_VUES')), 'like_count': int_or_none(infos.get('NB_LIKES')), 'comment_count': int_or_none(infos.get('NB_COMMENTS')), 'formats': formats, }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/whyp.py
youtube_dl/extractor/whyp.py
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..utils import ( float_or_none, merge_dicts, str_or_none, T, traverse_obj, url_or_none, ) class WhypIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?whyp\.it/tracks/(?P<id>\d+)' _TESTS = [{ 'url': 'https://www.whyp.it/tracks/18337/home-page-example-track-b4kq7', 'md5': 'c1187b42ebf8605284e3dc92aeb33d16', 'info_dict': { 'url': 'https://cdn.whyp.it/50eb17cc-e9ff-4e18-b89b-dc9206a95cb1.mp3', 'id': '18337', 'title': 'Home Page Example Track', 'description': r're:(?s).+\bexample track\b', 'ext': 'mp3', 'duration': 52.82, 'uploader': 'Brad', 'uploader_id': '1', 'thumbnail': 'https://cdn.whyp.it/a537bb36-3373-4c61-96c8-27fc1b2f427a.jpg', }, }, { 'url': 'https://www.whyp.it/tracks/18337', 'only_matching': True, }] def _real_extract(self, url): unique_id = self._match_id(url) webpage = self._download_webpage(url, unique_id) data = self._search_nuxt_data(webpage, unique_id)['rawTrack'] return merge_dicts({ 'url': data['audio_url'], 'id': unique_id, }, traverse_obj(data, { 'title': 'title', 'description': 'description', 'duration': ('duration', T(float_or_none)), 'uploader': ('user', 'username'), 'uploader_id': ('user', 'id', T(str_or_none)), 'thumbnail': ('artwork_url', T(url_or_none)), }), { 'ext': 'mp3', 'vcodec': 'none', 'http_headers': {'Referer': 'https://whyp.it/'}, }, rev=True)
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/tv4.py
youtube_dl/extractor/tv4.py
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import ( int_or_none, parse_iso8601, ) class TV4IE(InfoExtractor): IE_DESC = 'tv4.se and tv4play.se' _VALID_URL = r'''(?x)https?://(?:www\.)? (?: tv4\.se/(?:[^/]+)/klipp/(?:.*)-| tv4play\.se/ (?: (?:program|barn)/(?:(?:[^/]+/){1,2}|(?:[^\?]+)\?video_id=)| iframe/video/| film/| sport/| ) )(?P<id>[0-9]+)''' _GEO_COUNTRIES = ['SE'] _TESTS = [ { 'url': 'http://www.tv4.se/kalla-fakta/klipp/kalla-fakta-5-english-subtitles-2491650', 'md5': 'cb837212f342d77cec06e6dad190e96d', 'info_dict': { 'id': '2491650', 'ext': 'mp4', 'title': 'Kalla Fakta 5 (english subtitles)', 'thumbnail': r're:^https?://.*\.jpg$', 'timestamp': int, 'upload_date': '20131125', }, }, { 'url': 'http://www.tv4play.se/iframe/video/3054113', 'md5': 'cb837212f342d77cec06e6dad190e96d', 'info_dict': { 'id': '3054113', 'ext': 'mp4', 'title': 'Så här jobbar ficktjuvarna - se avslöjande bilder', 'thumbnail': r're:^https?://.*\.jpg$', 'description': 'Unika bilder avslöjar hur turisternas fickor vittjas mitt på Stockholms central. Två experter på ficktjuvarna avslöjar knepen du ska se upp för.', 'timestamp': int, 'upload_date': '20150130', }, }, { 'url': 'http://www.tv4play.se/sport/3060959', 'only_matching': True, }, { 'url': 'http://www.tv4play.se/film/2378136', 'only_matching': True, }, { 'url': 'http://www.tv4play.se/barn/looney-tunes?video_id=3062412', 'only_matching': True, }, { 'url': 'http://www.tv4play.se/program/farang/3922081', 'only_matching': True, }, { 'url': 'https://www.tv4play.se/program/nyheterna/avsnitt/13315940', 'only_matching': True, } ] def _real_extract(self, url): video_id = self._match_id(url) info = self._download_json( 'https://playback-api.b17g.net/asset/%s' % video_id, video_id, 'Downloading video info JSON', query={ 'service': 'tv4', 'device': 'browser', 'protocol': 'hls,dash', 'drm': 'widevine', })['metadata'] title = info['title'] manifest_url = self._download_json( 'https://playback-api.b17g.net/media/' + video_id, video_id, query={ 'service': 'tv4', 'device': 'browser', 'protocol': 'hls', })['playbackItem']['manifestUrl'] formats = self._extract_m3u8_formats( manifest_url, video_id, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False) formats.extend(self._extract_mpd_formats( manifest_url.replace('.m3u8', '.mpd'), video_id, mpd_id='dash', fatal=False)) formats.extend(self._extract_f4m_formats( manifest_url.replace('.m3u8', '.f4m'), video_id, f4m_id='hds', fatal=False)) formats.extend(self._extract_ism_formats( re.sub(r'\.ism/.*?\.m3u8', r'.ism/Manifest', manifest_url), video_id, ism_id='mss', fatal=False)) if not formats and info.get('is_geo_restricted'): self.raise_geo_restricted(countries=self._GEO_COUNTRIES) self._sort_formats(formats) return { 'id': video_id, 'title': title, 'formats': formats, # 'subtitles': subtitles, 'description': info.get('description'), 'timestamp': parse_iso8601(info.get('broadcast_date_time')), 'duration': int_or_none(info.get('duration')), 'thumbnail': info.get('image'), 'is_live': info.get('isLive') is True, 'series': info.get('seriesTitle'), 'season_number': int_or_none(info.get('seasonNumber')), 'episode': info.get('episodeTitle'), 'episode_number': int_or_none(info.get('episodeNumber')), }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/aenetworks.py
youtube_dl/extractor/aenetworks.py
# coding: utf-8 from __future__ import unicode_literals import re from .theplatform import ThePlatformIE from ..utils import ( ExtractorError, GeoRestrictedError, int_or_none, remove_start, traverse_obj, update_url_query, urlencode_postdata, ) class AENetworksBaseIE(ThePlatformIE): _BASE_URL_REGEX = r'''(?x)https?:// (?:(?:www|play|watch)\.)? (?P<domain> (?:history(?:vault)?|aetv|mylifetime|lifetimemovieclub)\.com| fyi\.tv )/''' _THEPLATFORM_KEY = '43jXaGRQud' _THEPLATFORM_SECRET = 'S10BPXHMlb' _DOMAIN_MAP = { 'history.com': ('HISTORY', 'history'), 'aetv.com': ('AETV', 'aetv'), 'mylifetime.com': ('LIFETIME', 'lifetime'), 'lifetimemovieclub.com': ('LIFETIMEMOVIECLUB', 'lmc'), 'fyi.tv': ('FYI', 'fyi'), 'historyvault.com': (None, 'historyvault'), 'biography.com': (None, 'biography'), } def _extract_aen_smil(self, smil_url, video_id, auth=None): query = { 'mbr': 'true', 'formats': 'M3U+none,MPEG-DASH+none,MPEG4,MP3', } if auth: query['auth'] = auth TP_SMIL_QUERY = [{ 'assetTypes': 'high_video_ak', 'switch': 'hls_high_ak', }, { 'assetTypes': 'high_video_s3', }, { 'assetTypes': 'high_video_s3', 'switch': 'hls_high_fastly', }] formats = [] subtitles = {} last_e = None for q in TP_SMIL_QUERY: q.update(query) m_url = update_url_query(smil_url, q) m_url = self._sign_url(m_url, self._THEPLATFORM_KEY, self._THEPLATFORM_SECRET) try: tp_formats, tp_subtitles = self._extract_theplatform_smil( m_url, video_id, 'Downloading %s SMIL data' % (q.get('switch') or q['assetTypes'])) except ExtractorError as e: if isinstance(e, GeoRestrictedError): raise last_e = e continue formats.extend(tp_formats) subtitles = self._merge_subtitles(subtitles, tp_subtitles) if last_e and not formats: raise last_e self._sort_formats(formats) return { 'id': video_id, 'formats': formats, 'subtitles': subtitles, } def _extract_aetn_info(self, domain, filter_key, filter_value, url): requestor_id, brand = self._DOMAIN_MAP[domain] result = self._download_json( 'https://feeds.video.aetnd.com/api/v2/%s/videos' % brand, filter_value, query={'filter[%s]' % filter_key: filter_value}) result = traverse_obj( result, ('results', lambda k, v: k == 0 and v[filter_key] == filter_value), get_all=False) if not result: raise ExtractorError('Show not found in A&E feed (too new?)', expected=True, video_id=remove_start(filter_value, '/')) title = result['title'] video_id = result['id'] media_url = result['publicUrl'] theplatform_metadata = self._download_theplatform_metadata(self._search_regex( r'https?://link\.theplatform\.com/s/([^?]+)', media_url, 'theplatform_path'), video_id) info = self._parse_theplatform_metadata(theplatform_metadata) auth = None if theplatform_metadata.get('AETN$isBehindWall'): resource = self._get_mvpd_resource( requestor_id, theplatform_metadata['title'], theplatform_metadata.get('AETN$PPL_pplProgramId') or theplatform_metadata.get('AETN$PPL_pplProgramId_OLD'), theplatform_metadata['ratings'][0]['rating']) auth = self._extract_mvpd_auth( url, video_id, requestor_id, resource) info.update(self._extract_aen_smil(media_url, video_id, auth)) info.update({ 'title': title, 'series': result.get('seriesName'), 'season_number': int_or_none(result.get('tvSeasonNumber')), 'episode_number': int_or_none(result.get('tvSeasonEpisodeNumber')), }) return info class AENetworksIE(AENetworksBaseIE): IE_NAME = 'aenetworks' IE_DESC = 'A+E Networks: A&E, Lifetime, History.com, FYI Network and History Vault' _VALID_URL = AENetworksBaseIE._BASE_URL_REGEX + r'''(?P<id> shows/[^/]+/season-\d+/episode-\d+| (?: (?:movie|special)s/[^/]+| (?:shows/[^/]+/)?videos )/[^/?#&]+ )''' _TESTS = [{ 'url': 'http://www.history.com/shows/mountain-men/season-1/episode-1', 'info_dict': { 'id': '22253814', 'ext': 'mp4', 'title': 'Winter is Coming', 'description': 'md5:641f424b7a19d8e24f26dea22cf59d74', 'timestamp': 1338306241, 'upload_date': '20120529', 'uploader': 'AENE-NEW', }, 'params': { # m3u8 download 'skip_download': True, }, 'add_ie': ['ThePlatform'], 'skip': 'Geo-restricted - This content is not available in your location.' }, { 'url': 'http://www.aetv.com/shows/duck-dynasty/season-9/episode-1', 'info_dict': { 'id': '600587331957', 'ext': 'mp4', 'title': 'Inlawful Entry', 'description': 'md5:57c12115a2b384d883fe64ca50529e08', 'timestamp': 1452634428, 'upload_date': '20160112', 'uploader': 'AENE-NEW', }, 'params': { # m3u8 download 'skip_download': True, }, 'add_ie': ['ThePlatform'], 'skip': 'This video is only available for users of participating TV providers.', }, { 'url': 'http://www.fyi.tv/shows/tiny-house-nation/season-1/episode-8', 'only_matching': True }, { 'url': 'http://www.mylifetime.com/shows/project-runway-junior/season-1/episode-6', 'only_matching': True }, { 'url': 'http://www.mylifetime.com/movies/center-stage-on-pointe/full-movie', 'only_matching': True }, { 'url': 'https://watch.lifetimemovieclub.com/movies/10-year-reunion/full-movie', 'only_matching': True }, { 'url': 'http://www.history.com/specials/sniper-into-the-kill-zone/full-special', 'only_matching': True }, { 'url': 'https://www.aetv.com/specials/hunting-jonbenets-killer-the-untold-story/preview-hunting-jonbenets-killer-the-untold-story', 'only_matching': True }, { 'url': 'http://www.history.com/videos/history-of-valentines-day', 'only_matching': True }, { 'url': 'https://play.aetv.com/shows/duck-dynasty/videos/best-of-duck-dynasty-getting-quack-in-shape', 'only_matching': True }] def _real_extract(self, url): domain, canonical = re.match(self._VALID_URL, url).groups() return self._extract_aetn_info(domain, 'canonical', '/' + canonical, url) class AENetworksListBaseIE(AENetworksBaseIE): def _call_api(self, resource, slug, brand, fields): return self._download_json( 'https://yoga.appsvcs.aetnd.com/graphql', slug, query={'brand': brand}, data=urlencode_postdata({ 'query': '''{ %s(slug: "%s") { %s } }''' % (resource, slug, fields), }))['data'][resource] def _real_extract(self, url): domain, slug = re.match(self._VALID_URL, url).groups() _, brand = self._DOMAIN_MAP[domain] playlist = self._call_api(self._RESOURCE, slug, brand, self._FIELDS) base_url = 'http://watch.%s' % domain entries = [] for item in (playlist.get(self._ITEMS_KEY) or []): doc = self._get_doc(item) canonical = doc.get('canonical') if not canonical: continue entries.append(self.url_result( base_url + canonical, AENetworksIE.ie_key(), doc.get('id'))) description = None if self._PLAYLIST_DESCRIPTION_KEY: description = playlist.get(self._PLAYLIST_DESCRIPTION_KEY) return self.playlist_result( entries, playlist.get('id'), playlist.get(self._PLAYLIST_TITLE_KEY), description) class AENetworksCollectionIE(AENetworksListBaseIE): IE_NAME = 'aenetworks:collection' _VALID_URL = AENetworksBaseIE._BASE_URL_REGEX + r'(?:[^/]+/)*(?:list|collections)/(?P<id>[^/?#&]+)/?(?:[?#&]|$)' _TESTS = [{ 'url': 'https://watch.historyvault.com/list/america-the-story-of-us', 'info_dict': { 'id': '282', 'title': 'America The Story of Us', }, 'playlist_mincount': 12, }, { 'url': 'https://watch.historyvault.com/shows/america-the-story-of-us-2/season-1/list/america-the-story-of-us', 'only_matching': True }, { 'url': 'https://www.historyvault.com/collections/mysteryquest', 'only_matching': True }] _RESOURCE = 'list' _ITEMS_KEY = 'items' _PLAYLIST_TITLE_KEY = 'display_title' _PLAYLIST_DESCRIPTION_KEY = None _FIELDS = '''id display_title items { ... on ListVideoItem { doc { canonical id } } }''' def _get_doc(self, item): return item.get('doc') or {} class AENetworksShowIE(AENetworksListBaseIE): IE_NAME = 'aenetworks:show' _VALID_URL = AENetworksBaseIE._BASE_URL_REGEX + r'shows/(?P<id>[^/?#&]+)/?(?:[?#&]|$)' _TESTS = [{ 'url': 'http://www.history.com/shows/ancient-aliens', 'info_dict': { 'id': 'SERIES1574', 'title': 'Ancient Aliens', 'description': 'md5:3f6d74daf2672ff3ae29ed732e37ea7f', }, 'playlist_mincount': 150, }] _RESOURCE = 'series' _ITEMS_KEY = 'episodes' _PLAYLIST_TITLE_KEY = 'title' _PLAYLIST_DESCRIPTION_KEY = 'description' _FIELDS = '''description id title episodes { canonical id }''' def _get_doc(self, item): return item class HistoryTopicIE(AENetworksBaseIE): IE_NAME = 'history:topic' IE_DESC = 'History.com Topic' _VALID_URL = r'https?://(?:www\.)?history\.com/topics/[^/]+/(?P<id>[\w+-]+?)-video' _TESTS = [{ 'url': 'https://www.history.com/topics/valentines-day/history-of-valentines-day-video', 'info_dict': { 'id': '40700995724', 'ext': 'mp4', 'title': "History of Valentine’s Day", 'description': 'md5:7b57ea4829b391995b405fa60bd7b5f7', 'timestamp': 1375819729, 'upload_date': '20130806', 'uploader': 'AENE-NEW', }, 'params': { # m3u8 download 'skip_download': True, }, 'add_ie': ['ThePlatform'], }] def _real_extract(self, url): display_id = self._match_id(url) return self.url_result( 'http://www.history.com/videos/' + display_id, AENetworksIE.ie_key()) class HistoryPlayerIE(AENetworksBaseIE): IE_NAME = 'history:player' _VALID_URL = r'https?://(?:www\.)?(?P<domain>(?:history|biography)\.com)/player/(?P<id>\d+)' _TESTS = [] def _real_extract(self, url): domain, video_id = re.match(self._VALID_URL, url).groups() return self._extract_aetn_info(domain, 'id', video_id, url) class BiographyIE(AENetworksBaseIE): _VALID_URL = r'https?://(?:www\.)?biography\.com/video/(?P<id>[^/?#&]+)' _TESTS = [{ 'url': 'https://www.biography.com/video/vincent-van-gogh-full-episode-2075049808', 'info_dict': { 'id': '30322987', 'ext': 'mp4', 'title': 'Vincent Van Gogh - Full Episode', 'description': 'A full biography about the most influential 20th century painter, Vincent Van Gogh.', 'timestamp': 1311970571, 'upload_date': '20110729', 'uploader': 'AENE-NEW', }, 'params': { # m3u8 download 'skip_download': True, }, 'add_ie': ['ThePlatform'], }] def _real_extract(self, url): display_id = self._match_id(url) webpage = self._download_webpage(url, display_id) player_url = self._search_regex( r'<phoenix-iframe[^>]+src="(%s)' % HistoryPlayerIE._VALID_URL, webpage, 'player URL') return self.url_result(player_url, HistoryPlayerIE.ie_key())
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/zattoo.py
youtube_dl/extractor/zattoo.py
# coding: utf-8 from __future__ import unicode_literals import re from uuid import uuid4 from .common import InfoExtractor from ..compat import ( compat_HTTPError, compat_str, ) from ..utils import ( ExtractorError, int_or_none, try_get, url_or_none, urlencode_postdata, ) class ZattooPlatformBaseIE(InfoExtractor): _power_guide_hash = None def _host_url(self): return 'https://%s' % (self._API_HOST if hasattr(self, '_API_HOST') else self._HOST) def _login(self): username, password = self._get_login_info() if not username or not password: self.raise_login_required( 'A valid %s account is needed to access this media.' % self._NETRC_MACHINE) try: data = self._download_json( '%s/zapi/v2/account/login' % self._host_url(), None, 'Logging in', data=urlencode_postdata({ 'login': username, 'password': password, 'remember': 'true', }), headers={ 'Referer': '%s/login' % self._host_url(), 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', }) except ExtractorError as e: if isinstance(e.cause, compat_HTTPError) and e.cause.code == 400: raise ExtractorError( 'Unable to login: incorrect username and/or password', expected=True) raise self._power_guide_hash = data['session']['power_guide_hash'] def _real_initialize(self): webpage = self._download_webpage( self._host_url(), None, 'Downloading app token') app_token = self._html_search_regex( r'appToken\s*=\s*(["\'])(?P<token>(?:(?!\1).)+?)\1', webpage, 'app token', group='token') app_version = self._html_search_regex( r'<!--\w+-(.+?)-', webpage, 'app version', default='2.8.2') # Will setup appropriate cookies self._request_webpage( '%s/zapi/v2/session/hello' % self._host_url(), None, 'Opening session', data=urlencode_postdata({ 'client_app_token': app_token, 'uuid': compat_str(uuid4()), 'lang': 'en', 'app_version': app_version, 'format': 'json', })) self._login() def _extract_cid(self, video_id, channel_name): channel_groups = self._download_json( '%s/zapi/v2/cached/channels/%s' % (self._host_url(), self._power_guide_hash), video_id, 'Downloading channel list', query={'details': False})['channel_groups'] channel_list = [] for chgrp in channel_groups: channel_list.extend(chgrp['channels']) try: return next( chan['cid'] for chan in channel_list if chan.get('cid') and ( chan.get('display_alias') == channel_name or chan.get('cid') == channel_name)) except StopIteration: raise ExtractorError('Could not extract channel id') def _extract_cid_and_video_info(self, video_id): data = self._download_json( '%s/zapi/v2/cached/program/power_details/%s' % ( self._host_url(), self._power_guide_hash), video_id, 'Downloading video information', query={ 'program_ids': video_id, 'complete': True, }) p = data['programs'][0] cid = p['cid'] info_dict = { 'id': video_id, 'title': p.get('t') or p['et'], 'description': p.get('d'), 'thumbnail': p.get('i_url'), 'creator': p.get('channel_name'), 'episode': p.get('et'), 'episode_number': int_or_none(p.get('e_no')), 'season_number': int_or_none(p.get('s_no')), 'release_year': int_or_none(p.get('year')), 'categories': try_get(p, lambda x: x['c'], list), 'tags': try_get(p, lambda x: x['g'], list) } return cid, info_dict def _extract_formats(self, cid, video_id, record_id=None, is_live=False): postdata_common = { 'https_watch_urls': True, } if is_live: postdata_common.update({'timeshift': 10800}) url = '%s/zapi/watch/live/%s' % (self._host_url(), cid) elif record_id: url = '%s/zapi/watch/recording/%s' % (self._host_url(), record_id) else: url = '%s/zapi/watch/recall/%s/%s' % (self._host_url(), cid, video_id) formats = [] for stream_type in ('dash', 'hls', 'hls5', 'hds'): postdata = postdata_common.copy() postdata['stream_type'] = stream_type data = self._download_json( url, video_id, 'Downloading %s formats' % stream_type.upper(), data=urlencode_postdata(postdata), fatal=False) if not data: continue watch_urls = try_get( data, lambda x: x['stream']['watch_urls'], list) if not watch_urls: continue for watch in watch_urls: if not isinstance(watch, dict): continue watch_url = url_or_none(watch.get('url')) if not watch_url: continue format_id_list = [stream_type] maxrate = watch.get('maxrate') if maxrate: format_id_list.append(compat_str(maxrate)) audio_channel = watch.get('audio_channel') if audio_channel: format_id_list.append(compat_str(audio_channel)) preference = 1 if audio_channel == 'A' else None format_id = '-'.join(format_id_list) if stream_type in ('dash', 'dash_widevine', 'dash_playready'): this_formats = self._extract_mpd_formats( watch_url, video_id, mpd_id=format_id, fatal=False) elif stream_type in ('hls', 'hls5', 'hls5_fairplay'): this_formats = self._extract_m3u8_formats( watch_url, video_id, 'mp4', entry_protocol='m3u8_native', m3u8_id=format_id, fatal=False) elif stream_type == 'hds': this_formats = self._extract_f4m_formats( watch_url, video_id, f4m_id=format_id, fatal=False) elif stream_type == 'smooth_playready': this_formats = self._extract_ism_formats( watch_url, video_id, ism_id=format_id, fatal=False) else: assert False for this_format in this_formats: this_format['preference'] = preference formats.extend(this_formats) self._sort_formats(formats) return formats def _extract_video(self, channel_name, video_id, record_id=None, is_live=False): if is_live: cid = self._extract_cid(video_id, channel_name) info_dict = { 'id': channel_name, 'title': self._live_title(channel_name), 'is_live': True, } else: cid, info_dict = self._extract_cid_and_video_info(video_id) formats = self._extract_formats( cid, video_id, record_id=record_id, is_live=is_live) info_dict['formats'] = formats return info_dict class QuicklineBaseIE(ZattooPlatformBaseIE): _NETRC_MACHINE = 'quickline' _HOST = 'mobiltv.quickline.com' class QuicklineIE(QuicklineBaseIE): _VALID_URL = r'https?://(?:www\.)?%s/watch/(?P<channel>[^/]+)/(?P<id>[0-9]+)' % re.escape(QuicklineBaseIE._HOST) _TEST = { 'url': 'https://mobiltv.quickline.com/watch/prosieben/130671867-maze-runner-die-auserwaehlten-in-der-brandwueste', 'only_matching': True, } def _real_extract(self, url): channel_name, video_id = re.match(self._VALID_URL, url).groups() return self._extract_video(channel_name, video_id) class QuicklineLiveIE(QuicklineBaseIE): _VALID_URL = r'https?://(?:www\.)?%s/watch/(?P<id>[^/]+)' % re.escape(QuicklineBaseIE._HOST) _TEST = { 'url': 'https://mobiltv.quickline.com/watch/srf1', 'only_matching': True, } @classmethod def suitable(cls, url): return False if QuicklineIE.suitable(url) else super(QuicklineLiveIE, cls).suitable(url) def _real_extract(self, url): channel_name = video_id = self._match_id(url) return self._extract_video(channel_name, video_id, is_live=True) class ZattooBaseIE(ZattooPlatformBaseIE): _NETRC_MACHINE = 'zattoo' _HOST = 'zattoo.com' def _make_valid_url(tmpl, host): return tmpl % re.escape(host) class ZattooIE(ZattooBaseIE): _VALID_URL_TEMPLATE = r'https?://(?:www\.)?%s/watch/(?P<channel>[^/]+?)/(?P<id>[0-9]+)[^/]+(?:/(?P<recid>[0-9]+))?' _VALID_URL = _make_valid_url(_VALID_URL_TEMPLATE, ZattooBaseIE._HOST) # Since regular videos are only available for 7 days and recorded videos # are only available for a specific user, we cannot have detailed tests. _TESTS = [{ 'url': 'https://zattoo.com/watch/prosieben/130671867-maze-runner-die-auserwaehlten-in-der-brandwueste', 'only_matching': True, }, { 'url': 'https://zattoo.com/watch/srf_zwei/132905652-eishockey-spengler-cup/102791477/1512211800000/1514433500000/92000', 'only_matching': True, }] def _real_extract(self, url): channel_name, video_id, record_id = re.match(self._VALID_URL, url).groups() return self._extract_video(channel_name, video_id, record_id) class ZattooLiveIE(ZattooBaseIE): _VALID_URL = r'https?://(?:www\.)?zattoo\.com/watch/(?P<id>[^/]+)' _TEST = { 'url': 'https://zattoo.com/watch/srf1', 'only_matching': True, } @classmethod def suitable(cls, url): return False if ZattooIE.suitable(url) else super(ZattooLiveIE, cls).suitable(url) def _real_extract(self, url): channel_name = video_id = self._match_id(url) return self._extract_video(channel_name, video_id, is_live=True) class NetPlusIE(ZattooIE): _NETRC_MACHINE = 'netplus' _HOST = 'netplus.tv' _API_HOST = 'www.%s' % _HOST _VALID_URL = _make_valid_url(ZattooIE._VALID_URL_TEMPLATE, _HOST) _TESTS = [{ 'url': 'https://www.netplus.tv/watch/abc/123-abc', 'only_matching': True, }] class MNetTVIE(ZattooIE): _NETRC_MACHINE = 'mnettv' _HOST = 'tvplus.m-net.de' _VALID_URL = _make_valid_url(ZattooIE._VALID_URL_TEMPLATE, _HOST) _TESTS = [{ 'url': 'https://tvplus.m-net.de/watch/abc/123-abc', 'only_matching': True, }] class WalyTVIE(ZattooIE): _NETRC_MACHINE = 'walytv' _HOST = 'player.waly.tv' _VALID_URL = _make_valid_url(ZattooIE._VALID_URL_TEMPLATE, _HOST) _TESTS = [{ 'url': 'https://player.waly.tv/watch/abc/123-abc', 'only_matching': True, }] class BBVTVIE(ZattooIE): _NETRC_MACHINE = 'bbvtv' _HOST = 'bbv-tv.net' _API_HOST = 'www.%s' % _HOST _VALID_URL = _make_valid_url(ZattooIE._VALID_URL_TEMPLATE, _HOST) _TESTS = [{ 'url': 'https://www.bbv-tv.net/watch/abc/123-abc', 'only_matching': True, }] class VTXTVIE(ZattooIE): _NETRC_MACHINE = 'vtxtv' _HOST = 'vtxtv.ch' _API_HOST = 'www.%s' % _HOST _VALID_URL = _make_valid_url(ZattooIE._VALID_URL_TEMPLATE, _HOST) _TESTS = [{ 'url': 'https://www.vtxtv.ch/watch/abc/123-abc', 'only_matching': True, }] class MyVisionTVIE(ZattooIE): _NETRC_MACHINE = 'myvisiontv' _HOST = 'myvisiontv.ch' _API_HOST = 'www.%s' % _HOST _VALID_URL = _make_valid_url(ZattooIE._VALID_URL_TEMPLATE, _HOST) _TESTS = [{ 'url': 'https://www.myvisiontv.ch/watch/abc/123-abc', 'only_matching': True, }] class GlattvisionTVIE(ZattooIE): _NETRC_MACHINE = 'glattvisiontv' _HOST = 'iptv.glattvision.ch' _VALID_URL = _make_valid_url(ZattooIE._VALID_URL_TEMPLATE, _HOST) _TESTS = [{ 'url': 'https://iptv.glattvision.ch/watch/abc/123-abc', 'only_matching': True, }] class SAKTVIE(ZattooIE): _NETRC_MACHINE = 'saktv' _HOST = 'saktv.ch' _API_HOST = 'www.%s' % _HOST _VALID_URL = _make_valid_url(ZattooIE._VALID_URL_TEMPLATE, _HOST) _TESTS = [{ 'url': 'https://www.saktv.ch/watch/abc/123-abc', 'only_matching': True, }] class EWETVIE(ZattooIE): _NETRC_MACHINE = 'ewetv' _HOST = 'tvonline.ewe.de' _VALID_URL = _make_valid_url(ZattooIE._VALID_URL_TEMPLATE, _HOST) _TESTS = [{ 'url': 'https://tvonline.ewe.de/watch/abc/123-abc', 'only_matching': True, }] class QuantumTVIE(ZattooIE): _NETRC_MACHINE = 'quantumtv' _HOST = 'quantum-tv.com' _API_HOST = 'www.%s' % _HOST _VALID_URL = _make_valid_url(ZattooIE._VALID_URL_TEMPLATE, _HOST) _TESTS = [{ 'url': 'https://www.quantum-tv.com/watch/abc/123-abc', 'only_matching': True, }] class OsnatelTVIE(ZattooIE): _NETRC_MACHINE = 'osnateltv' _HOST = 'tvonline.osnatel.de' _VALID_URL = _make_valid_url(ZattooIE._VALID_URL_TEMPLATE, _HOST) _TESTS = [{ 'url': 'https://tvonline.osnatel.de/watch/abc/123-abc', 'only_matching': True, }] class EinsUndEinsTVIE(ZattooIE): _NETRC_MACHINE = '1und1tv' _HOST = '1und1.tv' _API_HOST = 'www.%s' % _HOST _VALID_URL = _make_valid_url(ZattooIE._VALID_URL_TEMPLATE, _HOST) _TESTS = [{ 'url': 'https://www.1und1.tv/watch/abc/123-abc', 'only_matching': True, }] class SaltTVIE(ZattooIE): _NETRC_MACHINE = 'salttv' _HOST = 'tv.salt.ch' _VALID_URL = _make_valid_url(ZattooIE._VALID_URL_TEMPLATE, _HOST) _TESTS = [{ 'url': 'https://tv.salt.ch/watch/abc/123-abc', 'only_matching': True, }]
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/sport5.py
youtube_dl/extractor/sport5.py
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import ExtractorError class Sport5IE(InfoExtractor): _VALID_URL = r'https?://(?:www|vod)?\.sport5\.co\.il/.*\b(?:Vi|docID)=(?P<id>\d+)' _TESTS = [ { 'url': 'http://vod.sport5.co.il/?Vc=147&Vi=176331&Page=1', 'info_dict': { 'id': 's5-Y59xx1-GUh2', 'ext': 'mp4', 'title': 'ולנסיה-קורדובה 0:3', 'description': 'אלקאסר, גאייה ופגולי סידרו לקבוצה של נונו ניצחון על קורדובה ואת המקום הראשון בליגה', 'duration': 228, 'categories': list, }, 'skip': 'Blocked outside of Israel', }, { 'url': 'http://www.sport5.co.il/articles.aspx?FolderID=3075&docID=176372&lang=HE', 'info_dict': { 'id': 's5-SiXxx1-hKh2', 'ext': 'mp4', 'title': 'GOALS_CELTIC_270914.mp4', 'description': '', 'duration': 87, 'categories': list, }, 'skip': 'Blocked outside of Israel', } ] def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) media_id = mobj.group('id') webpage = self._download_webpage(url, media_id) video_id = self._html_search_regex(r'clipId=([\w-]+)', webpage, 'video id') metadata = self._download_xml( 'http://sport5-metadata-rr-d.nsacdn.com/vod/vod/%s/HDS/metadata.xml' % video_id, video_id) error = metadata.find('./Error') if error is not None: raise ExtractorError( '%s returned error: %s - %s' % ( self.IE_NAME, error.find('./Name').text, error.find('./Description').text), expected=True) title = metadata.find('./Title').text description = metadata.find('./Description').text duration = int(metadata.find('./Duration').text) posters_el = metadata.find('./PosterLinks') thumbnails = [{ 'url': thumbnail.text, 'width': int(thumbnail.get('width')), 'height': int(thumbnail.get('height')), } for thumbnail in posters_el.findall('./PosterIMG')] if posters_el is not None else [] categories_el = metadata.find('./Categories') categories = [ cat.get('name') for cat in categories_el.findall('./Category') ] if categories_el is not None else [] formats = [{ 'url': fmt.text, 'ext': 'mp4', 'vbr': int(fmt.get('bitrate')), 'width': int(fmt.get('width')), 'height': int(fmt.get('height')), } for fmt in metadata.findall('./PlaybackLinks/FileURL')] self._sort_formats(formats) return { 'id': video_id, 'title': title, 'description': description, 'thumbnails': thumbnails, 'duration': duration, 'categories': categories, 'formats': formats, }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/adultswim.py
youtube_dl/extractor/adultswim.py
# coding: utf-8 from __future__ import unicode_literals import json import re from .turner import TurnerBaseIE from ..utils import ( determine_ext, float_or_none, int_or_none, mimetype2ext, parse_age_limit, parse_iso8601, strip_or_none, try_get, ) class AdultSwimIE(TurnerBaseIE): _VALID_URL = r'https?://(?:www\.)?adultswim\.com/videos/(?P<show_path>[^/?#]+)(?:/(?P<episode_path>[^/?#]+))?' _TESTS = [{ 'url': 'http://adultswim.com/videos/rick-and-morty/pilot', 'info_dict': { 'id': 'rQxZvXQ4ROaSOqq-or2Mow', 'ext': 'mp4', 'title': 'Rick and Morty - Pilot', 'description': 'Rick moves in with his daughter\'s family and establishes himself as a bad influence on his grandson, Morty.', 'timestamp': 1543294800, 'upload_date': '20181127', }, 'params': { # m3u8 download 'skip_download': True, }, 'expected_warnings': ['Unable to download f4m manifest'], }, { 'url': 'http://www.adultswim.com/videos/tim-and-eric-awesome-show-great-job/dr-steve-brule-for-your-wine/', 'info_dict': { 'id': 'sY3cMUR_TbuE4YmdjzbIcQ', 'ext': 'mp4', 'title': 'Tim and Eric Awesome Show Great Job! - Dr. Steve Brule, For Your Wine', 'description': 'Dr. Brule reports live from Wine Country with a special report on wines. \nWatch Tim and Eric Awesome Show Great Job! episode #20, "Embarrassed" on Adult Swim.', 'upload_date': '20080124', 'timestamp': 1201150800, }, 'params': { # m3u8 download 'skip_download': True, }, 'skip': '404 Not Found', }, { 'url': 'http://www.adultswim.com/videos/decker/inside-decker-a-new-hero/', 'info_dict': { 'id': 'I0LQFQkaSUaFp8PnAWHhoQ', 'ext': 'mp4', 'title': 'Decker - Inside Decker: A New Hero', 'description': 'The guys recap the conclusion of the season. They announce a new hero, take a peek into the Victorville Film Archive and welcome back the talented James Dean.', 'timestamp': 1469480460, 'upload_date': '20160725', }, 'params': { # m3u8 download 'skip_download': True, }, 'expected_warnings': ['Unable to download f4m manifest'], }, { 'url': 'http://www.adultswim.com/videos/attack-on-titan', 'info_dict': { 'id': 'attack-on-titan', 'title': 'Attack on Titan', 'description': 'md5:41caa9416906d90711e31dc00cb7db7e', }, 'playlist_mincount': 12, }, { 'url': 'http://www.adultswim.com/videos/streams/williams-stream', 'info_dict': { 'id': 'd8DEBj7QRfetLsRgFnGEyg', 'ext': 'mp4', 'title': r're:^Williams Stream \d{4}-\d{2}-\d{2} \d{2}:\d{2}$', 'description': 'original programming', }, 'params': { # m3u8 download 'skip_download': True, }, 'skip': '404 Not Found', }] def _real_extract(self, url): show_path, episode_path = re.match(self._VALID_URL, url).groups() display_id = episode_path or show_path query = '''query { getShowBySlug(slug:"%s") { %%s } }''' % show_path if episode_path: query = query % '''title getVideoBySlug(slug:"%s") { _id auth description duration episodeNumber launchDate mediaID seasonNumber poster title tvRating }''' % episode_path ['getVideoBySlug'] else: query = query % '''metaDescription title videos(first:1000,sort:["episode_number"]) { edges { node { _id slug } } }''' show_data = self._download_json( 'https://www.adultswim.com/api/search', display_id, data=json.dumps({'query': query}).encode(), headers={'Content-Type': 'application/json'})['data']['getShowBySlug'] if episode_path: video_data = show_data['getVideoBySlug'] video_id = video_data['_id'] episode_title = title = video_data['title'] series = show_data.get('title') if series: title = '%s - %s' % (series, title) info = { 'id': video_id, 'title': title, 'description': strip_or_none(video_data.get('description')), 'duration': float_or_none(video_data.get('duration')), 'formats': [], 'subtitles': {}, 'age_limit': parse_age_limit(video_data.get('tvRating')), 'thumbnail': video_data.get('poster'), 'timestamp': parse_iso8601(video_data.get('launchDate')), 'series': series, 'season_number': int_or_none(video_data.get('seasonNumber')), 'episode': episode_title, 'episode_number': int_or_none(video_data.get('episodeNumber')), } auth = video_data.get('auth') media_id = video_data.get('mediaID') if media_id: info.update(self._extract_ngtv_info(media_id, { # CDN_TOKEN_APP_ID from: # https://d2gg02c3xr550i.cloudfront.net/assets/asvp.e9c8bef24322d060ef87.bundle.js 'appId': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6ImFzLXR2ZS1kZXNrdG9wLXB0enQ2bSIsInByb2R1Y3QiOiJ0dmUiLCJuZXR3b3JrIjoiYXMiLCJwbGF0Zm9ybSI6ImRlc2t0b3AiLCJpYXQiOjE1MzI3MDIyNzl9.BzSCk-WYOZ2GMCIaeVb8zWnzhlgnXuJTCu0jGp_VaZE', }, { 'url': url, 'site_name': 'AdultSwim', 'auth_required': auth, })) if not auth: extract_data = self._download_json( 'https://www.adultswim.com/api/shows/v1/videos/' + video_id, video_id, query={'fields': 'stream'}, fatal=False) or {} assets = try_get(extract_data, lambda x: x['data']['video']['stream']['assets'], list) or [] for asset in assets: asset_url = asset.get('url') if not asset_url: continue ext = determine_ext(asset_url, mimetype2ext(asset.get('mime_type'))) if ext == 'm3u8': info['formats'].extend(self._extract_m3u8_formats( asset_url, video_id, 'mp4', m3u8_id='hls', fatal=False)) elif ext == 'f4m': continue # info['formats'].extend(self._extract_f4m_formats( # asset_url, video_id, f4m_id='hds', fatal=False)) elif ext in ('scc', 'ttml', 'vtt'): info['subtitles'].setdefault('en', []).append({ 'url': asset_url, }) self._sort_formats(info['formats']) return info else: entries = [] for edge in show_data.get('videos', {}).get('edges', []): video = edge.get('node') or {} slug = video.get('slug') if not slug: continue entries.append(self.url_result( 'http://adultswim.com/videos/%s/%s' % (show_path, slug), 'AdultSwim', video.get('_id'))) return self.playlist_result( entries, show_path, show_data.get('title'), strip_or_none(show_data.get('metaDescription')))
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/filmweb.py
youtube_dl/extractor/filmweb.py
from __future__ import unicode_literals import re from .common import InfoExtractor class FilmwebIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?filmweb\.no/(?P<type>trailere|filmnytt)/article(?P<id>\d+)\.ece' _TEST = { 'url': 'http://www.filmweb.no/trailere/article1264921.ece', 'md5': 'e353f47df98e557d67edaceda9dece89', 'info_dict': { 'id': '13033574', 'ext': 'mp4', 'title': 'Det som en gang var', 'upload_date': '20160316', 'timestamp': 1458140101, 'uploader_id': '12639966', 'uploader': 'Live Roaldset', } } def _real_extract(self, url): article_type, article_id = re.match(self._VALID_URL, url).groups() if article_type == 'filmnytt': webpage = self._download_webpage(url, article_id) article_id = self._search_regex(r'data-videoid="(\d+)"', webpage, 'article id') embed_code = self._download_json( 'https://www.filmweb.no/template_v2/ajax/json_trailerEmbed.jsp', article_id, query={ 'articleId': article_id, })['embedCode'] iframe_url = self._proto_relative_url(self._search_regex( r'<iframe[^>]+src="([^"]+)', embed_code, 'iframe url')) return { '_type': 'url_transparent', 'id': article_id, 'url': iframe_url, 'ie_key': 'TwentyThreeVideo', }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/playtvak.py
youtube_dl/extractor/playtvak.py
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..compat import ( compat_urlparse, compat_urllib_parse_urlencode, ) from ..utils import ( ExtractorError, int_or_none, parse_iso8601, qualities, ) class PlaytvakIE(InfoExtractor): IE_DESC = 'Playtvak.cz, iDNES.cz and Lidovky.cz' _VALID_URL = r'https?://(?:.+?\.)?(?:playtvak|idnes|lidovky|metro)\.cz/.*\?(?:c|idvideo)=(?P<id>[^&]+)' _TESTS = [{ 'url': 'http://www.playtvak.cz/vyzente-vosy-a-srsne-ze-zahrady-dn5-/hodinovy-manzel.aspx?c=A150730_150323_hodinovy-manzel_kuko', 'md5': '4525ae312c324b4be2f4603cc78ceb4a', 'info_dict': { 'id': 'A150730_150323_hodinovy-manzel_kuko', 'ext': 'mp4', 'title': 'Vyžeňte vosy a sršně ze zahrady', 'description': 'md5:4436e61b7df227a093778efb7e373571', 'thumbnail': r're:(?i)^https?://.*\.(?:jpg|png)$', 'duration': 279, 'timestamp': 1438732860, 'upload_date': '20150805', 'is_live': False, } }, { # live video test 'url': 'http://slowtv.playtvak.cz/planespotting-0pr-/planespotting.aspx?c=A150624_164934_planespotting_cat', 'info_dict': { 'id': 'A150624_164934_planespotting_cat', 'ext': 'flv', 'title': 're:^Planespotting [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$', 'description': 'Sledujte provoz na ranveji Letiště Václava Havla v Praze', 'is_live': True, }, 'params': { 'skip_download': True, # requires rtmpdump }, }, { # another live stream, this one without Misc.videoFLV 'url': 'https://slowtv.playtvak.cz/zive-sledujte-vlaky-v-primem-prenosu-dwi-/hlavni-nadrazi.aspx?c=A151218_145728_hlavni-nadrazi_plap', 'info_dict': { 'id': 'A151218_145728_hlavni-nadrazi_plap', 'ext': 'flv', 'title': 're:^Hlavní nádraží [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$', 'is_live': True, }, 'params': { 'skip_download': True, # requires rtmpdump }, }, { # idnes.cz 'url': 'http://zpravy.idnes.cz/pes-zavreny-v-aute-rozbijeni-okynek-v-aute-fj5-/domaci.aspx?c=A150809_104116_domaci_pku', 'md5': '819832ba33cd7016e58a6658577fe289', 'info_dict': { 'id': 'A150809_104116_domaci_pku', 'ext': 'mp4', 'title': 'Zavřeli jsme mraženou pizzu do auta. Upekla se', 'description': 'md5:01e73f02329e2e5760bd5eed4d42e3c2', 'thumbnail': r're:(?i)^https?://.*\.(?:jpg|png)$', 'duration': 39, 'timestamp': 1438969140, 'upload_date': '20150807', 'is_live': False, } }, { # lidovky.cz 'url': 'http://www.lidovky.cz/dalsi-demonstrace-v-praze-o-migraci-duq-/video.aspx?c=A150808_214044_ln-video_ELE', 'md5': 'c7209ac4ba9d234d4ad5bab7485bcee8', 'info_dict': { 'id': 'A150808_214044_ln-video_ELE', 'ext': 'mp4', 'title': 'Táhni! Demonstrace proti imigrantům budila emoce', 'description': 'md5:97c81d589a9491fbfa323c9fa3cca72c', 'thumbnail': r're:(?i)^https?://.*\.(?:jpg|png)$', 'timestamp': 1439052180, 'upload_date': '20150808', 'is_live': False, } }, { # metro.cz 'url': 'http://www.metro.cz/video-pod-billboardem-se-na-vltavske-roztocil-kolotoc-deti-vozil-jen-par-hodin-1hx-/metro-extra.aspx?c=A141111_173251_metro-extra_row', 'md5': '84fc1deedcac37b7d4a6ccae7c716668', 'info_dict': { 'id': 'A141111_173251_metro-extra_row', 'ext': 'mp4', 'title': 'Recesisté udělali z billboardu kolotoč', 'description': 'md5:7369926049588c3989a66c9c1a043c4c', 'thumbnail': r're:(?i)^https?://.*\.(?:jpg|png)$', 'timestamp': 1415725500, 'upload_date': '20141111', 'is_live': False, } }, { 'url': 'http://www.playtvak.cz/embed.aspx?idvideo=V150729_141549_play-porad_kuko', 'only_matching': True, }] def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) info_url = self._html_search_regex( r'Misc\.video(?:FLV)?\(\s*{\s*data\s*:\s*"([^"]+)"', webpage, 'info url') parsed_url = compat_urlparse.urlparse(info_url) qs = compat_urlparse.parse_qs(parsed_url.query) qs.update({ 'reklama': ['0'], 'type': ['js'], }) info_url = compat_urlparse.urlunparse( parsed_url._replace(query=compat_urllib_parse_urlencode(qs, True))) json_info = self._download_json( info_url, video_id, transform_source=lambda s: s[s.index('{'):s.rindex('}') + 1]) item = None for i in json_info['items']: if i.get('type') == 'video' or i.get('type') == 'stream': item = i break if not item: raise ExtractorError('No suitable stream found') quality = qualities(('low', 'middle', 'high')) formats = [] for fmt in item['video']: video_url = fmt.get('file') if not video_url: continue format_ = fmt['format'] format_id = '%s_%s' % (format_, fmt['quality']) preference = None if format_ in ('mp4', 'webm'): ext = format_ elif format_ == 'rtmp': ext = 'flv' elif format_ == 'apple': ext = 'mp4' # Some streams have mp3 audio which does not play # well with ffmpeg filter aac_adtstoasc preference = -1 elif format_ == 'adobe': # f4m manifest fails with 404 in 80% of requests continue else: # Other formats not supported yet continue formats.append({ 'url': video_url, 'ext': ext, 'format_id': format_id, 'quality': quality(fmt.get('quality')), 'preference': preference, }) self._sort_formats(formats) title = item['title'] is_live = item['type'] == 'stream' if is_live: title = self._live_title(title) description = self._og_search_description(webpage, default=None) or self._html_search_meta( 'description', webpage, 'description', default=None) timestamp = None duration = None if not is_live: duration = int_or_none(item.get('length')) timestamp = item.get('published') if timestamp: timestamp = parse_iso8601(timestamp[:-5]) return { 'id': video_id, 'title': title, 'description': description, 'thumbnail': item.get('image'), 'duration': duration, 'timestamp': timestamp, 'is_live': is_live, 'formats': formats, }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/nbc.py
youtube_dl/extractor/nbc.py
from __future__ import unicode_literals import base64 import json import re from .common import InfoExtractor from .theplatform import ThePlatformIE from .adobepass import AdobePassIE from ..compat import compat_urllib_parse_unquote from ..utils import ( int_or_none, parse_duration, smuggle_url, try_get, unified_timestamp, update_url_query, ) class NBCIE(AdobePassIE): _VALID_URL = r'https?(?P<permalink>://(?:www\.)?nbc\.com/(?:classic-tv/)?[^/]+/video/[^/]+/(?P<id>n?\d+))' _TESTS = [ { 'url': 'http://www.nbc.com/the-tonight-show/video/jimmy-fallon-surprises-fans-at-ben-jerrys/2848237', 'info_dict': { 'id': '2848237', 'ext': 'mp4', 'title': 'Jimmy Fallon Surprises Fans at Ben & Jerry\'s', 'description': 'Jimmy gives out free scoops of his new "Tonight Dough" ice cream flavor by surprising customers at the Ben & Jerry\'s scoop shop.', 'timestamp': 1424246400, 'upload_date': '20150218', 'uploader': 'NBCU-COM', }, 'params': { # m3u8 download 'skip_download': True, }, }, { 'url': 'http://www.nbc.com/saturday-night-live/video/star-wars-teaser/2832821', 'info_dict': { 'id': '2832821', 'ext': 'mp4', 'title': 'Star Wars Teaser', 'description': 'md5:0b40f9cbde5b671a7ff62fceccc4f442', 'timestamp': 1417852800, 'upload_date': '20141206', 'uploader': 'NBCU-COM', }, 'params': { # m3u8 download 'skip_download': True, }, 'skip': 'Only works from US', }, { # HLS streams requires the 'hdnea3' cookie 'url': 'http://www.nbc.com/Kings/video/goliath/n1806', 'info_dict': { 'id': '101528f5a9e8127b107e98c5e6ce4638', 'ext': 'mp4', 'title': 'Goliath', 'description': 'When an unknown soldier saves the life of the King\'s son in battle, he\'s thrust into the limelight and politics of the kingdom.', 'timestamp': 1237100400, 'upload_date': '20090315', 'uploader': 'NBCU-COM', }, 'params': { 'skip_download': True, }, 'skip': 'Only works from US', }, { 'url': 'https://www.nbc.com/classic-tv/charles-in-charge/video/charles-in-charge-pilot/n3310', 'only_matching': True, }, { # Percent escaped url 'url': 'https://www.nbc.com/up-all-night/video/day-after-valentine%27s-day/n2189', 'only_matching': True, } ] def _real_extract(self, url): permalink, video_id = re.match(self._VALID_URL, url).groups() permalink = 'http' + compat_urllib_parse_unquote(permalink) video_data = self._download_json( 'https://friendship.nbc.co/v2/graphql', video_id, query={ 'query': '''query bonanzaPage( $app: NBCUBrands! = nbc $name: String! $oneApp: Boolean $platform: SupportedPlatforms! = web $type: EntityPageType! = VIDEO $userId: String! ) { bonanzaPage( app: $app name: $name oneApp: $oneApp platform: $platform type: $type userId: $userId ) { metadata { ... on VideoPageData { description episodeNumber keywords locked mpxAccountId mpxGuid rating resourceId seasonNumber secondaryTitle seriesShortTitle } } } }''', 'variables': json.dumps({ 'name': permalink, 'oneApp': True, 'userId': '0', }), })['data']['bonanzaPage']['metadata'] query = { 'mbr': 'true', 'manifest': 'm3u', } video_id = video_data['mpxGuid'] title = video_data['secondaryTitle'] if video_data.get('locked'): resource = self._get_mvpd_resource( video_data.get('resourceId') or 'nbcentertainment', title, video_id, video_data.get('rating')) query['auth'] = self._extract_mvpd_auth( url, video_id, 'nbcentertainment', resource) theplatform_url = smuggle_url(update_url_query( 'http://link.theplatform.com/s/NnzsPC/media/guid/%s/%s' % (video_data.get('mpxAccountId') or '2410887629', video_id), query), {'force_smil_url': True}) return { '_type': 'url_transparent', 'id': video_id, 'title': title, 'url': theplatform_url, 'description': video_data.get('description'), 'tags': video_data.get('keywords'), 'season_number': int_or_none(video_data.get('seasonNumber')), 'episode_number': int_or_none(video_data.get('episodeNumber')), 'episode': title, 'series': video_data.get('seriesShortTitle'), 'ie_key': 'ThePlatform', } class NBCSportsVPlayerIE(InfoExtractor): _VALID_URL_BASE = r'https?://(?:vplayer\.nbcsports\.com|(?:www\.)?nbcsports\.com/vplayer)/' _VALID_URL = _VALID_URL_BASE + r'(?:[^/]+/)+(?P<id>[0-9a-zA-Z_]+)' _TESTS = [{ 'url': 'https://vplayer.nbcsports.com/p/BxmELC/nbcsports_embed/select/9CsDKds0kvHI', 'info_dict': { 'id': '9CsDKds0kvHI', 'ext': 'mp4', 'description': 'md5:df390f70a9ba7c95ff1daace988f0d8d', 'title': 'Tyler Kalinoski hits buzzer-beater to lift Davidson', 'timestamp': 1426270238, 'upload_date': '20150313', 'uploader': 'NBCU-SPORTS', } }, { 'url': 'https://vplayer.nbcsports.com/p/BxmELC/nbcsports_embed/select/media/_hqLjQ95yx8Z', 'only_matching': True, }, { 'url': 'https://www.nbcsports.com/vplayer/p/BxmELC/nbcsports/select/PHJSaFWbrTY9?form=html&autoPlay=true', 'only_matching': True, }] @staticmethod def _extract_url(webpage): iframe_m = re.search( r'<(?:iframe[^>]+|div[^>]+data-(?:mpx-)?)src="(?P<url>%s[^"]+)"' % NBCSportsVPlayerIE._VALID_URL_BASE, webpage) if iframe_m: return iframe_m.group('url') def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) theplatform_url = self._og_search_video_url(webpage).replace( 'vplayer.nbcsports.com', 'player.theplatform.com') return self.url_result(theplatform_url, 'ThePlatform') class NBCSportsIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?nbcsports\.com//?(?!vplayer/)(?:[^/]+/)+(?P<id>[0-9a-z-]+)' _TESTS = [{ # iframe src 'url': 'http://www.nbcsports.com//college-basketball/ncaab/tom-izzo-michigan-st-has-so-much-respect-duke', 'info_dict': { 'id': 'PHJSaFWbrTY9', 'ext': 'mp4', 'title': 'Tom Izzo, Michigan St. has \'so much respect\' for Duke', 'description': 'md5:ecb459c9d59e0766ac9c7d5d0eda8113', 'uploader': 'NBCU-SPORTS', 'upload_date': '20150330', 'timestamp': 1427726529, } }, { # data-mpx-src 'url': 'https://www.nbcsports.com/philadelphia/philadelphia-phillies/bruce-bochy-hector-neris-hes-idiot', 'only_matching': True, }, { # data-src 'url': 'https://www.nbcsports.com/boston/video/report-card-pats-secondary-no-match-josh-allen', 'only_matching': True, }] def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) return self.url_result( NBCSportsVPlayerIE._extract_url(webpage), 'NBCSportsVPlayer') class NBCSportsStreamIE(AdobePassIE): _VALID_URL = r'https?://stream\.nbcsports\.com/.+?\bpid=(?P<id>\d+)' _TEST = { 'url': 'http://stream.nbcsports.com/nbcsn/generic?pid=206559', 'info_dict': { 'id': '206559', 'ext': 'mp4', 'title': 'Amgen Tour of California Women\'s Recap', 'description': 'md5:66520066b3b5281ada7698d0ea2aa894', }, 'params': { # m3u8 download 'skip_download': True, }, 'skip': 'Requires Adobe Pass Authentication', } def _real_extract(self, url): video_id = self._match_id(url) live_source = self._download_json( 'http://stream.nbcsports.com/data/live_sources_%s.json' % video_id, video_id) video_source = live_source['videoSources'][0] title = video_source['title'] source_url = None for k in ('source', 'msl4source', 'iossource', 'hlsv4'): sk = k + 'Url' source_url = video_source.get(sk) or video_source.get(sk + 'Alt') if source_url: break else: source_url = video_source['ottStreamUrl'] is_live = video_source.get('type') == 'live' or video_source.get('status') == 'Live' resource = self._get_mvpd_resource('nbcsports', title, video_id, '') token = self._extract_mvpd_auth(url, video_id, 'nbcsports', resource) tokenized_url = self._download_json( 'https://token.playmakerservices.com/cdn', video_id, data=json.dumps({ 'requestorId': 'nbcsports', 'pid': video_id, 'application': 'NBCSports', 'version': 'v1', 'platform': 'desktop', 'cdn': 'akamai', 'url': video_source['sourceUrl'], 'token': base64.b64encode(token.encode()).decode(), 'resourceId': base64.b64encode(resource.encode()).decode(), }).encode())['tokenizedUrl'] formats = self._extract_m3u8_formats(tokenized_url, video_id, 'mp4') self._sort_formats(formats) return { 'id': video_id, 'title': self._live_title(title) if is_live else title, 'description': live_source.get('description'), 'formats': formats, 'is_live': is_live, } class NBCNewsIE(ThePlatformIE): _VALID_URL = r'(?x)https?://(?:www\.)?(?:nbcnews|today|msnbc)\.com/([^/]+/)*(?:.*-)?(?P<id>[^/?]+)' _TESTS = [ { 'url': 'http://www.nbcnews.com/watch/nbcnews-com/how-twitter-reacted-to-the-snowden-interview-269389891880', 'md5': 'cf4bc9e6ce0130f00f545d80ecedd4bf', 'info_dict': { 'id': '269389891880', 'ext': 'mp4', 'title': 'How Twitter Reacted To The Snowden Interview', 'description': 'md5:65a0bd5d76fe114f3c2727aa3a81fe64', 'timestamp': 1401363060, 'upload_date': '20140529', }, }, { 'url': 'http://www.nbcnews.com/feature/dateline-full-episodes/full-episode-family-business-n285156', 'md5': 'fdbf39ab73a72df5896b6234ff98518a', 'info_dict': { 'id': '529953347624', 'ext': 'mp4', 'title': 'FULL EPISODE: Family Business', 'description': 'md5:757988edbaae9d7be1d585eb5d55cc04', }, 'skip': 'This page is unavailable.', }, { 'url': 'http://www.nbcnews.com/nightly-news/video/nightly-news-with-brian-williams-full-broadcast-february-4-394064451844', 'md5': '8eb831eca25bfa7d25ddd83e85946548', 'info_dict': { 'id': '394064451844', 'ext': 'mp4', 'title': 'Nightly News with Brian Williams Full Broadcast (February 4)', 'description': 'md5:1c10c1eccbe84a26e5debb4381e2d3c5', 'timestamp': 1423104900, 'upload_date': '20150205', }, }, { 'url': 'http://www.nbcnews.com/business/autos/volkswagen-11-million-vehicles-could-have-suspect-software-emissions-scandal-n431456', 'md5': '4a8c4cec9e1ded51060bdda36ff0a5c0', 'info_dict': { 'id': 'n431456', 'ext': 'mp4', 'title': "Volkswagen U.S. Chief: We 'Totally Screwed Up'", 'description': 'md5:d22d1281a24f22ea0880741bb4dd6301', 'upload_date': '20150922', 'timestamp': 1442917800, }, }, { 'url': 'http://www.today.com/video/see-the-aurora-borealis-from-space-in-stunning-new-nasa-video-669831235788', 'md5': '118d7ca3f0bea6534f119c68ef539f71', 'info_dict': { 'id': '669831235788', 'ext': 'mp4', 'title': 'See the aurora borealis from space in stunning new NASA video', 'description': 'md5:74752b7358afb99939c5f8bb2d1d04b1', 'upload_date': '20160420', 'timestamp': 1461152093, }, }, { 'url': 'http://www.msnbc.com/all-in-with-chris-hayes/watch/the-chaotic-gop-immigration-vote-314487875924', 'md5': '6d236bf4f3dddc226633ce6e2c3f814d', 'info_dict': { 'id': '314487875924', 'ext': 'mp4', 'title': 'The chaotic GOP immigration vote', 'description': 'The Republican House votes on a border bill that has no chance of getting through the Senate or signed by the President and is drawing criticism from all sides.', 'thumbnail': r're:^https?://.*\.jpg$', 'timestamp': 1406937606, 'upload_date': '20140802', }, }, { 'url': 'http://www.nbcnews.com/watch/dateline/full-episode--deadly-betrayal-386250819952', 'only_matching': True, }, { # From http://www.vulture.com/2016/06/letterman-couldnt-care-less-about-late-night.html 'url': 'http://www.nbcnews.com/widget/video-embed/701714499682', 'only_matching': True, }, ] def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) data = self._parse_json(self._search_regex( r'<script[^>]+id="__NEXT_DATA__"[^>]*>({.+?})</script>', webpage, 'bootstrap json'), video_id)['props']['initialState'] video_data = try_get(data, lambda x: x['video']['current'], dict) if not video_data: video_data = data['article']['content'][0]['primaryMedia']['video'] title = video_data['headline']['primary'] formats = [] for va in video_data.get('videoAssets', []): public_url = va.get('publicUrl') if not public_url: continue if '://link.theplatform.com/' in public_url: public_url = update_url_query(public_url, {'format': 'redirect'}) format_id = va.get('format') if format_id == 'M3U': formats.extend(self._extract_m3u8_formats( public_url, video_id, 'mp4', 'm3u8_native', m3u8_id=format_id, fatal=False)) continue tbr = int_or_none(va.get('bitrate'), 1000) if tbr: format_id += '-%d' % tbr formats.append({ 'format_id': format_id, 'url': public_url, 'width': int_or_none(va.get('width')), 'height': int_or_none(va.get('height')), 'tbr': tbr, 'ext': 'mp4', }) self._sort_formats(formats) subtitles = {} closed_captioning = video_data.get('closedCaptioning') if closed_captioning: for cc_url in closed_captioning.values(): if not cc_url: continue subtitles.setdefault('en', []).append({ 'url': cc_url, }) return { 'id': video_id, 'title': title, 'description': try_get(video_data, lambda x: x['description']['primary']), 'thumbnail': try_get(video_data, lambda x: x['primaryImage']['url']['primary']), 'duration': parse_duration(video_data.get('duration')), 'timestamp': unified_timestamp(video_data.get('datePublished')), 'formats': formats, 'subtitles': subtitles, } class NBCOlympicsIE(InfoExtractor): IE_NAME = 'nbcolympics' _VALID_URL = r'https?://www\.nbcolympics\.com/video/(?P<id>[a-z-]+)' _TEST = { # Geo-restricted to US 'url': 'http://www.nbcolympics.com/video/justin-roses-son-leo-was-tears-after-his-dad-won-gold', 'md5': '54fecf846d05429fbaa18af557ee523a', 'info_dict': { 'id': 'WjTBzDXx5AUq', 'display_id': 'justin-roses-son-leo-was-tears-after-his-dad-won-gold', 'ext': 'mp4', 'title': 'Rose\'s son Leo was in tears after his dad won gold', 'description': 'Olympic gold medalist Justin Rose gets emotional talking to the impact his win in men\'s golf has already had on his children.', 'timestamp': 1471274964, 'upload_date': '20160815', 'uploader': 'NBCU-SPORTS', }, } def _real_extract(self, url): display_id = self._match_id(url) webpage = self._download_webpage(url, display_id) drupal_settings = self._parse_json(self._search_regex( r'jQuery\.extend\(Drupal\.settings\s*,\s*({.+?})\);', webpage, 'drupal settings'), display_id) iframe_url = drupal_settings['vod']['iframe_url'] theplatform_url = iframe_url.replace( 'vplayer.nbcolympics.com', 'player.theplatform.com') return { '_type': 'url_transparent', 'url': theplatform_url, 'ie_key': ThePlatformIE.ie_key(), 'display_id': display_id, } class NBCOlympicsStreamIE(AdobePassIE): IE_NAME = 'nbcolympics:stream' _VALID_URL = r'https?://stream\.nbcolympics\.com/(?P<id>[0-9a-z-]+)' _TEST = { 'url': 'http://stream.nbcolympics.com/2018-winter-olympics-nbcsn-evening-feb-8', 'info_dict': { 'id': '203493', 'ext': 'mp4', 'title': 're:Curling, Alpine, Luge [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$', }, 'params': { # m3u8 download 'skip_download': True, }, } _DATA_URL_TEMPLATE = 'http://stream.nbcolympics.com/data/%s_%s.json' def _real_extract(self, url): display_id = self._match_id(url) webpage = self._download_webpage(url, display_id) pid = self._search_regex(r'pid\s*=\s*(\d+);', webpage, 'pid') resource = self._search_regex( r"resource\s*=\s*'(.+)';", webpage, 'resource').replace("' + pid + '", pid) event_config = self._download_json( self._DATA_URL_TEMPLATE % ('event_config', pid), pid)['eventConfig'] title = self._live_title(event_config['eventTitle']) source_url = self._download_json( self._DATA_URL_TEMPLATE % ('live_sources', pid), pid)['videoSources'][0]['sourceUrl'] media_token = self._extract_mvpd_auth( url, pid, event_config.get('requestorId', 'NBCOlympics'), resource) formats = self._extract_m3u8_formats(self._download_webpage( 'http://sp.auth.adobe.com/tvs/v1/sign', pid, query={ 'cdn': 'akamai', 'mediaToken': base64.b64encode(media_token.encode()), 'resource': base64.b64encode(resource.encode()), 'url': source_url, }), pid, 'mp4') self._sort_formats(formats) return { 'id': pid, 'display_id': display_id, 'title': title, 'formats': formats, 'is_live': True, }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/yourporn.py
youtube_dl/extractor/yourporn.py
from __future__ import unicode_literals from .common import InfoExtractor from ..compat import compat_str from ..utils import ( parse_duration, urljoin, ) class YourPornIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?sxyprn\.com/post/(?P<id>[^/?#&.]+)' _TESTS = [{ 'url': 'https://sxyprn.com/post/57ffcb2e1179b.html', 'md5': '6f8682b6464033d87acaa7a8ff0c092e', 'info_dict': { 'id': '57ffcb2e1179b', 'ext': 'mp4', 'title': 'md5:c9f43630bd968267672651ba905a7d35', 'thumbnail': r're:^https?://.*\.jpg$', 'duration': 165, 'age_limit': 18, }, 'params': { 'skip_download': True, }, }, { 'url': 'https://sxyprn.com/post/57ffcb2e1179b.html', 'only_matching': True, }] def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) parts = self._parse_json( self._search_regex( r'data-vnfo=(["\'])(?P<data>{.+?})\1', webpage, 'data info', group='data'), video_id)[video_id].split('/') num = 0 for c in parts[6] + parts[7]: if c.isnumeric(): num += int(c) parts[5] = compat_str(int(parts[5]) - num) parts[1] += '8' video_url = urljoin(url, '/'.join(parts)) title = (self._search_regex( r'<[^>]+\bclass=["\']PostEditTA[^>]+>([^<]+)', webpage, 'title', default=None) or self._og_search_description(webpage)).strip() thumbnail = self._og_search_thumbnail(webpage) duration = parse_duration(self._search_regex( r'duration\s*:\s*<[^>]+>([\d:]+)', webpage, 'duration', default=None)) return { 'id': video_id, 'url': video_url, 'title': title, 'thumbnail': thumbnail, 'duration': duration, 'age_limit': 18, 'ext': 'mp4', }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/ketnet.py
youtube_dl/extractor/ketnet.py
from __future__ import unicode_literals from .canvas import CanvasIE from .common import InfoExtractor from ..compat import compat_urllib_parse_unquote from ..utils import ( int_or_none, parse_iso8601, ) class KetnetIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?ketnet\.be/(?P<id>(?:[^/]+/)*[^/?#&]+)' _TESTS = [{ 'url': 'https://www.ketnet.be/kijken/n/nachtwacht/3/nachtwacht-s3a1-de-greystook', 'md5': '37b2b7bb9b3dcaa05b67058dc3a714a9', 'info_dict': { 'id': 'pbs-pub-aef8b526-115e-4006-aa24-e59ff6c6ef6f$vid-ddb815bf-c8e7-467b-8879-6bad7a32cebd', 'ext': 'mp4', 'title': 'Nachtwacht - Reeks 3: Aflevering 1', 'description': 'De Nachtwacht krijgt te maken met een parasiet', 'thumbnail': r're:^https?://.*\.jpg$', 'duration': 1468.02, 'timestamp': 1609225200, 'upload_date': '20201229', 'series': 'Nachtwacht', 'season': 'Reeks 3', 'episode': 'De Greystook', 'episode_number': 1, }, 'expected_warnings': ['is not a supported codec', 'Unknown MIME type'], }, { 'url': 'https://www.ketnet.be/themas/karrewiet/jaaroverzicht-20200/karrewiet-het-jaar-van-black-mamba', 'only_matching': True, }] def _real_extract(self, url): display_id = self._match_id(url) video = self._download_json( 'https://senior-bff.ketnet.be/graphql', display_id, query={ 'query': '''{ video(id: "content/ketnet/nl/%s.model.json") { description episodeNr imageUrl mediaReference programTitle publicationDate seasonTitle subtitleVideodetail titleVideodetail } }''' % display_id, })['data']['video'] mz_id = compat_urllib_parse_unquote(video['mediaReference']) return { '_type': 'url_transparent', 'id': mz_id, 'title': video['titleVideodetail'], 'url': 'https://mediazone.vrt.be/api/v1/ketnet/assets/' + mz_id, 'thumbnail': video.get('imageUrl'), 'description': video.get('description'), 'timestamp': parse_iso8601(video.get('publicationDate')), 'series': video.get('programTitle'), 'season': video.get('seasonTitle'), 'episode': video.get('subtitleVideodetail'), 'episode_number': int_or_none(video.get('episodeNr')), 'ie_key': CanvasIE.ie_key(), }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/freespeech.py
youtube_dl/extractor/freespeech.py
from __future__ import unicode_literals from .common import InfoExtractor from .youtube import YoutubeIE class FreespeechIE(InfoExtractor): IE_NAME = 'freespeech.org' _VALID_URL = r'https?://(?:www\.)?freespeech\.org/stories/(?P<id>.+)' _TEST = { 'add_ie': ['Youtube'], 'url': 'http://www.freespeech.org/stories/fcc-announces-net-neutrality-rollback-whats-stake/', 'info_dict': { 'id': 'waRk6IPqyWM', 'ext': 'mp4', 'title': 'What\'s At Stake - Net Neutrality Special', 'description': 'Presented by MNN and FSTV', 'upload_date': '20170728', 'uploader_id': 'freespeechtv', 'uploader': 'freespeechtv', }, } def _real_extract(self, url): display_id = self._match_id(url) webpage = self._download_webpage(url, display_id) youtube_url = self._search_regex( r'data-video-url="([^"]+)"', webpage, 'youtube url') return self.url_result(youtube_url, YoutubeIE.ie_key())
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/rtp.py
youtube_dl/extractor/rtp.py
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..utils import ( determine_ext, js_to_json, ) class RTPIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?rtp\.pt/play/p(?P<program_id>[0-9]+)/(?P<id>[^/?#]+)/?' _TESTS = [{ 'url': 'http://www.rtp.pt/play/p405/e174042/paixoes-cruzadas', 'md5': 'e736ce0c665e459ddb818546220b4ef8', 'info_dict': { 'id': 'e174042', 'ext': 'mp3', 'title': 'Paixões Cruzadas', 'description': 'As paixões musicais de António Cartaxo e António Macedo', 'thumbnail': r're:^https?://.*\.jpg', }, }, { 'url': 'http://www.rtp.pt/play/p831/a-quimica-das-coisas', 'only_matching': True, }] def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) title = self._html_search_meta( 'twitter:title', webpage, display_name='title', fatal=True) config = self._parse_json(self._search_regex( r'(?s)RTPPlayer\(({.+?})\);', webpage, 'player config'), video_id, js_to_json) file_url = config['file'] ext = determine_ext(file_url) if ext == 'm3u8': file_key = config.get('fileKey') formats = self._extract_m3u8_formats( file_url, video_id, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=file_key) if file_key: formats.append({ 'url': 'https://cdn-ondemand.rtp.pt' + file_key, 'preference': 1, }) self._sort_formats(formats) else: formats = [{ 'url': file_url, 'ext': ext, }] if config.get('mediaType') == 'audio': for f in formats: f['vcodec'] = 'none' return { 'id': video_id, 'title': title, 'formats': formats, 'description': self._html_search_meta(['description', 'twitter:description'], webpage), 'thumbnail': config.get('poster') or self._og_search_thumbnail(webpage), }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/wsj.py
youtube_dl/extractor/wsj.py
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..utils import ( int_or_none, float_or_none, unified_strdate, ) class WSJIE(InfoExtractor): _VALID_URL = r'''(?x) (?: https?://video-api\.wsj\.com/api-video/player/iframe\.html\?.*?\bguid=| https?://(?:www\.)?(?:wsj|barrons)\.com/video/(?:[^/]+/)+| wsj: ) (?P<id>[a-fA-F0-9-]{36}) ''' IE_DESC = 'Wall Street Journal' _TESTS = [{ 'url': 'http://video-api.wsj.com/api-video/player/iframe.html?guid=1BD01A4C-BFE8-40A5-A42F-8A8AF9898B1A', 'md5': 'e230a5bb249075e40793b655a54a02e4', 'info_dict': { 'id': '1BD01A4C-BFE8-40A5-A42F-8A8AF9898B1A', 'ext': 'mp4', 'upload_date': '20150202', 'uploader_id': 'jdesai', 'creator': 'jdesai', 'categories': list, # a long list 'duration': 90, 'title': 'Bills Coach Rex Ryan Updates His Old Jets Tattoo', }, }, { 'url': 'http://www.wsj.com/video/can-alphabet-build-a-smarter-city/359DDAA8-9AC1-489C-82E6-0429C1E430E0.html', 'only_matching': True, }, { 'url': 'http://www.barrons.com/video/capitalism-deserves-more-respect-from-millennials/F301217E-6F46-43AE-B8D2-B7180D642EE9.html', 'only_matching': True, }, { 'url': 'https://www.wsj.com/video/series/a-brief-history-of/the-modern-cell-carrier-how-we-got-here/980E2187-401D-48A1-B82B-1486CEE06CB9', 'only_matching': True, }] def _real_extract(self, url): video_id = self._match_id(url) info = self._download_json( 'http://video-api.wsj.com/api-video/find_all_videos.asp', video_id, query={ 'type': 'guid', 'count': 1, 'query': video_id, 'fields': ','.join(( 'type', 'hls', 'videoMP4List', 'thumbnailList', 'author', 'description', 'name', 'duration', 'videoURL', 'titletag', 'formattedCreationDate', 'keywords', 'editor')), })['items'][0] title = info.get('name', info.get('titletag')) formats = [] f4m_url = info.get('videoURL') if f4m_url: formats.extend(self._extract_f4m_formats( f4m_url, video_id, f4m_id='hds', fatal=False)) m3u8_url = info.get('hls') if m3u8_url: formats.extend(self._extract_m3u8_formats( info['hls'], video_id, ext='mp4', entry_protocol='m3u8_native', m3u8_id='hls', fatal=False)) for v in info.get('videoMP4List', []): mp4_url = v.get('url') if not mp4_url: continue tbr = int_or_none(v.get('bitrate')) formats.append({ 'url': mp4_url, 'format_id': 'http' + ('-%d' % tbr if tbr else ''), 'tbr': tbr, 'width': int_or_none(v.get('width')), 'height': int_or_none(v.get('height')), 'fps': float_or_none(v.get('fps')), }) self._sort_formats(formats) return { 'id': video_id, 'formats': formats, # Thumbnails are conveniently in the correct format already 'thumbnails': info.get('thumbnailList'), 'creator': info.get('author'), 'uploader_id': info.get('editor'), 'duration': int_or_none(info.get('duration')), 'upload_date': unified_strdate(info.get( 'formattedCreationDate'), day_first=False), 'title': title, 'categories': info.get('keywords'), } class WSJArticleIE(InfoExtractor): _VALID_URL = r'(?i)https?://(?:www\.)?wsj\.com/articles/(?P<id>[^/?#&]+)' _TEST = { 'url': 'https://www.wsj.com/articles/dont-like-china-no-pandas-for-you-1490366939?', 'info_dict': { 'id': '4B13FA62-1D8C-45DB-8EA1-4105CB20B362', 'ext': 'mp4', 'upload_date': '20170221', 'uploader_id': 'ralcaraz', 'title': 'Bao Bao the Panda Leaves for China', } } def _real_extract(self, url): article_id = self._match_id(url) webpage = self._download_webpage(url, article_id) video_id = self._search_regex( r'data-src=["\']([a-fA-F0-9-]{36})', webpage, 'video id') return self.url_result('wsj:%s' % video_id, WSJIE.ie_key(), video_id)
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/archiveorg.py
youtube_dl/extractor/archiveorg.py
from __future__ import unicode_literals from .common import InfoExtractor from ..utils import ( clean_html, extract_attributes, unified_strdate, unified_timestamp, ) class ArchiveOrgIE(InfoExtractor): IE_NAME = 'archive.org' IE_DESC = 'archive.org videos' _VALID_URL = r'https?://(?:www\.)?archive\.org/(?:details|embed)/(?P<id>[^/?#&]+)' _TESTS = [{ 'url': 'http://archive.org/details/XD300-23_68HighlightsAResearchCntAugHumanIntellect', 'md5': '8af1d4cf447933ed3c7f4871162602db', 'info_dict': { 'id': 'XD300-23_68HighlightsAResearchCntAugHumanIntellect', 'ext': 'ogg', 'title': '1968 Demo - FJCC Conference Presentation Reel #1', 'description': 'md5:da45c349df039f1cc8075268eb1b5c25', 'creator': 'SRI International', 'release_date': '19681210', 'uploader': 'SRI International', 'timestamp': 1268695290, 'upload_date': '20100315', } }, { 'url': 'https://archive.org/details/Cops1922', 'md5': '0869000b4ce265e8ca62738b336b268a', 'info_dict': { 'id': 'Cops1922', 'ext': 'mp4', 'title': 'Buster Keaton\'s "Cops" (1922)', 'description': 'md5:43a603fd6c5b4b90d12a96b921212b9c', 'timestamp': 1387699629, 'upload_date': '20131222', } }, { 'url': 'http://archive.org/embed/XD300-23_68HighlightsAResearchCntAugHumanIntellect', 'only_matching': True, }, { 'url': 'https://archive.org/details/MSNBCW_20131125_040000_To_Catch_a_Predator/', 'only_matching': True, }] def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage( 'http://archive.org/embed/' + video_id, video_id) playlist = None play8 = self._search_regex( r'(<[^>]+\bclass=["\']js-play8-playlist[^>]+>)', webpage, 'playlist', default=None) if play8: attrs = extract_attributes(play8) playlist = attrs.get('value') if not playlist: # Old jwplayer fallback playlist = self._search_regex( r"(?s)Play\('[^']+'\s*,\s*(\[.+\])\s*,\s*{.*?}\)", webpage, 'jwplayer playlist', default='[]') jwplayer_playlist = self._parse_json(playlist, video_id, fatal=False) if jwplayer_playlist: info = self._parse_jwplayer_data( {'playlist': jwplayer_playlist}, video_id, base_url=url) else: # HTML5 media fallback info = self._parse_html5_media_entries(url, webpage, video_id)[0] info['id'] = video_id def get_optional(metadata, field): return metadata.get(field, [None])[0] metadata = self._download_json( 'http://archive.org/details/' + video_id, video_id, query={ 'output': 'json', })['metadata'] info.update({ 'title': get_optional(metadata, 'title') or info.get('title'), 'description': clean_html(get_optional(metadata, 'description')), }) if info.get('_type') != 'playlist': creator = get_optional(metadata, 'creator') info.update({ 'creator': creator, 'release_date': unified_strdate(get_optional(metadata, 'date')), 'uploader': get_optional(metadata, 'publisher') or creator, 'timestamp': unified_timestamp(get_optional(metadata, 'publicdate')), 'language': get_optional(metadata, 'language'), }) return info
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/audimedia.py
youtube_dl/extractor/audimedia.py
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..utils import ( int_or_none, parse_iso8601, ) class AudiMediaIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?audi-mediacenter\.com/(?:en|de)/audimediatv/(?:video/)?(?P<id>[^/?#]+)' _TESTS = [{ 'url': 'https://www.audi-mediacenter.com/en/audimediatv/60-seconds-of-audi-sport-104-2015-wec-bahrain-rookie-test-1467', 'md5': '79a8b71c46d49042609795ab59779b66', 'info_dict': { 'id': '1565', 'ext': 'mp4', 'title': '60 Seconds of Audi Sport 104/2015 - WEC Bahrain, Rookie Test', 'description': 'md5:60e5d30a78ced725f7b8d34370762941', 'upload_date': '20151124', 'timestamp': 1448354940, 'duration': 74022, 'view_count': int, } }, { 'url': 'https://www.audi-mediacenter.com/en/audimediatv/video/60-seconds-of-audi-sport-104-2015-wec-bahrain-rookie-test-2991', 'only_matching': True, }] def _real_extract(self, url): display_id = self._match_id(url) webpage = self._download_webpage(url, display_id) raw_payload = self._search_regex([ r'class="amtv-embed"[^>]+id="([0-9a-z-]+)"', r'id="([0-9a-z-]+)"[^>]+class="amtv-embed"', r'class=\\"amtv-embed\\"[^>]+id=\\"([0-9a-z-]+)\\"', r'id=\\"([0-9a-z-]+)\\"[^>]+class=\\"amtv-embed\\"', r'id=(?:\\)?"(amtve-[a-z]-\d+-[a-z]{2})', ], webpage, 'raw payload') _, stage_mode, video_id, _ = raw_payload.split('-') # TODO: handle s and e stage_mode (live streams and ended live streams) if stage_mode not in ('s', 'e'): video_data = self._download_json( 'https://www.audimedia.tv/api/video/v1/videos/' + video_id, video_id, query={ 'embed[]': ['video_versions', 'thumbnail_image'], })['results'] formats = [] stream_url_hls = video_data.get('stream_url_hls') if stream_url_hls: formats.extend(self._extract_m3u8_formats( stream_url_hls, video_id, 'mp4', entry_protocol='m3u8_native', m3u8_id='hls', fatal=False)) stream_url_hds = video_data.get('stream_url_hds') if stream_url_hds: formats.extend(self._extract_f4m_formats( stream_url_hds + '?hdcore=3.4.0', video_id, f4m_id='hds', fatal=False)) for video_version in video_data.get('video_versions', []): video_version_url = video_version.get('download_url') or video_version.get('stream_url') if not video_version_url: continue f = { 'url': video_version_url, 'width': int_or_none(video_version.get('width')), 'height': int_or_none(video_version.get('height')), 'abr': int_or_none(video_version.get('audio_bitrate')), 'vbr': int_or_none(video_version.get('video_bitrate')), } bitrate = self._search_regex(r'(\d+)k', video_version_url, 'bitrate', default=None) if bitrate: f.update({ 'format_id': 'http-%s' % bitrate, }) formats.append(f) self._sort_formats(formats) return { 'id': video_id, 'title': video_data['title'], 'description': video_data.get('subtitle'), 'thumbnail': video_data.get('thumbnail_image', {}).get('file'), 'timestamp': parse_iso8601(video_data.get('publication_date')), 'duration': int_or_none(video_data.get('duration')), 'view_count': int_or_none(video_data.get('view_count')), 'formats': formats, }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/videofyme.py
youtube_dl/extractor/videofyme.py
from __future__ import unicode_literals from .common import InfoExtractor from ..utils import ( int_or_none, parse_iso8601, ) class VideofyMeIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.videofy\.me/.+?|p\.videofy\.me/v)/(?P<id>\d+)(&|#|$)' IE_NAME = 'videofy.me' _TEST = { 'url': 'http://www.videofy.me/thisisvideofyme/1100701', 'md5': 'c77d700bdc16ae2e9f3c26019bd96143', 'info_dict': { 'id': '1100701', 'ext': 'mp4', 'title': 'This is VideofyMe', 'description': '', 'upload_date': '20130326', 'timestamp': 1364288959, 'uploader': 'VideofyMe', 'uploader_id': 'thisisvideofyme', 'view_count': int, 'likes': int, 'comment_count': int, }, } def _real_extract(self, url): video_id = self._match_id(url) config = self._download_json('http://vf-player-info-loader.herokuapp.com/%s.json' % video_id, video_id)['videoinfo'] video = config.get('video') blog = config.get('blog', {}) return { 'id': video_id, 'title': video['title'], 'url': video['sources']['source']['url'], 'thumbnail': video.get('thumb'), 'description': video.get('description'), 'timestamp': parse_iso8601(video.get('date')), 'uploader': blog.get('name'), 'uploader_id': blog.get('identifier'), 'view_count': int_or_none(self._search_regex(r'([0-9]+)', video.get('views'), 'view count', fatal=False)), 'likes': int_or_none(video.get('likes')), 'comment_count': int_or_none(video.get('nrOfComments')), }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/vbox7.py
youtube_dl/extractor/vbox7.py
# coding: utf-8 from __future__ import unicode_literals import re import time from .common import InfoExtractor from ..compat import compat_kwargs from ..utils import ( base_url, determine_ext, ExtractorError, float_or_none, merge_dicts, T, traverse_obj, txt_or_none, url_basename, url_or_none, ) class Vbox7IE(InfoExtractor): _VALID_URL = r'''(?x) https?:// (?:[^/]+\.)?vbox7\.com/ (?: play:| (?: emb/external\.php| player/ext\.swf )\?.*?\bvid= ) (?P<id>[\da-fA-F]+) ''' _EMBED_REGEX = [r'<iframe[^>]+src=(?P<q>["\'])(?P<url>(?:https?:)?//vbox7\.com/emb/external\.php.+?)(?P=q)'] _GEO_COUNTRIES = ['BG'] _TESTS = [{ # the http: URL just redirects here 'url': 'https://vbox7.com/play:0946fff23c', 'md5': '50ca1f78345a9c15391af47d8062d074', 'info_dict': { 'id': '0946fff23c', 'ext': 'mp4', 'title': 'Борисов: Притеснен съм за бъдещето на България', 'description': 'По думите му е опасно страната ни да бъде обявена за "сигурна"', 'timestamp': 1470982814, 'upload_date': '20160812', 'uploader': 'zdraveibulgaria', 'thumbnail': r're:^https?://.*\.jpg$', 'view_count': int, 'duration': 2640, }, 'expected_warnings': [ 'Unable to download webpage', ], }, { 'url': 'http://vbox7.com/play:249bb972c2', 'md5': '99f65c0c9ef9b682b97313e052734c3f', 'info_dict': { 'id': '249bb972c2', 'ext': 'mp4', 'title': 'Смях! Чудо - чист за секунди - Скрита камера', 'description': 'Смях! Чудо - чист за секунди - Скрита камера', 'timestamp': 1360215023, 'upload_date': '20130207', 'uploader': 'svideteliat_ot_varshava', 'thumbnail': 'https://i49.vbox7.com/o/249/249bb972c20.jpg', 'view_count': int, 'duration': 83, }, 'expected_warnings': ['Failed to download m3u8 information'], }, { 'url': 'http://vbox7.com/emb/external.php?vid=a240d20f9c&autoplay=1', 'only_matching': True, }, { 'url': 'http://i49.vbox7.com/player/ext.swf?vid=0946fff23c&autoplay=1', 'only_matching': True, }] @classmethod def _extract_url(cls, webpage): mobj = re.search(cls._EMBED_REGEX[0], webpage) if mobj: return mobj.group('url') # specialisation to transform what looks like ld+json that # may contain invalid character combinations # transform_source=None, fatal=True def _parse_json(self, json_string, video_id, *args, **kwargs): if '"@context"' in json_string[:30]: # this is ld+json, or that's the way to bet transform_source = args[0] if len(args) > 0 else kwargs.get('transform_source') if not transform_source: def fix_chars(src): # fix malformed ld+json: replace raw CRLFs with escaped LFs return re.sub( r'"[^"]+"', lambda m: re.sub(r'\r?\n', r'\\n', m.group(0)), src) if len(args) > 0: args = (fix_chars,) + args[1:] else: kwargs['transform_source'] = fix_chars kwargs = compat_kwargs(kwargs) return super(Vbox7IE, self)._parse_json( json_string, video_id, *args, **kwargs) def _real_extract(self, url): video_id = self._match_id(url) url = 'https://vbox7.com/play:%s' % (video_id,) now = time.time() response = self._download_json( 'https://www.vbox7.com/aj/player/item/options', video_id, query={'vid': video_id}, headers={'Referer': url}) # estimate time to which possible `ago` member is relative now = now + 0.5 * (time.time() - now) if traverse_obj(response, 'error'): raise ExtractorError( '%s said: %s' % (self.IE_NAME, response['error']), expected=True) src_url = traverse_obj(response, ('options', 'src', T(url_or_none))) or '' fmt_base = url_basename(src_url).rsplit('.', 1)[0].rsplit('_', 1)[0] if fmt_base in ('na', 'vn'): self.raise_geo_restricted(countries=self._GEO_COUNTRIES) ext = determine_ext(src_url) if ext == 'mpd': # extract MPD try: formats, subtitles = self._extract_mpd_formats_and_subtitles( src_url, video_id, 'dash', fatal=False) except KeyError: # fatal doesn't catch this self.report_warning('Failed to parse MPD manifest') formats, subtitles = [], {} elif ext != 'm3u8': formats = [{ 'url': src_url, }] if src_url else [] subtitles = {} if src_url: # possibly extract HLS, based on https://github.com/yt-dlp/yt-dlp/pull/9100 fmt_base = base_url(src_url) + fmt_base # prepare for _extract_m3u8_formats_and_subtitles() # hls_formats, hls_subs = self._extract_m3u8_formats_and_subtitles( hls_formats = self._extract_m3u8_formats( '{0}.m3u8'.format(fmt_base), video_id, m3u8_id='hls', fatal=False) formats.extend(hls_formats) # self._merge_subtitles(hls_subs, target=subtitles) # In case MPD/HLS cannot be parsed, or anyway, get mp4 combined # formats usually provided to Safari, iOS, and old Windows video = response['options'] resolutions = (1080, 720, 480, 240, 144) highest_res = traverse_obj(video, ( 'highestRes', T(int))) or resolutions[0] resolutions = traverse_obj(video, ( 'resolutions', lambda _, r: highest_res >= int(r) > 0)) or resolutions mp4_formats = traverse_obj(resolutions, ( Ellipsis, T(lambda res: { 'url': '{0}_{1}.mp4'.format(fmt_base, res), 'format_id': 'http-{0}'.format(res), 'height': res, }))) # if above formats are flaky, enable the line below # self._check_formats(mp4_formats, video_id) formats.extend(mp4_formats) self._sort_formats(formats) webpage = self._download_webpage(url, video_id, fatal=False) or '' info = self._search_json_ld( webpage.replace('"/*@context"', '"@context"'), video_id, fatal=False) if webpage else {} if not info.get('title'): info['title'] = traverse_obj(response, ( 'options', 'title', T(txt_or_none))) or self._og_search_title(webpage) def if_missing(k): return lambda x: None if k in info else x info = merge_dicts(info, { 'id': video_id, 'formats': formats, 'subtitles': subtitles or None, }, info, traverse_obj(response, ('options', { 'uploader': ('uploader', T(txt_or_none)), 'timestamp': ('ago', T(if_missing('timestamp')), T(lambda t: int(round((now - t) / 60.0)) * 60)), 'duration': ('duration', T(if_missing('duration')), T(float_or_none)), }))) if 'thumbnail' not in info: info['thumbnail'] = self._proto_relative_url( info.get('thumbnail') or self._og_search_thumbnail(webpage), 'https:'), return info
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/movingimage.py
youtube_dl/extractor/movingimage.py
from __future__ import unicode_literals from .common import InfoExtractor from ..utils import ( unescapeHTML, parse_duration, ) class MovingImageIE(InfoExtractor): _VALID_URL = r'https?://movingimage\.nls\.uk/film/(?P<id>\d+)' _TEST = { 'url': 'http://movingimage.nls.uk/film/3561', 'md5': '4caa05c2b38453e6f862197571a7be2f', 'info_dict': { 'id': '3561', 'ext': 'mp4', 'title': 'SHETLAND WOOL', 'description': 'md5:c5afca6871ad59b4271e7704fe50ab04', 'duration': 900, 'thumbnail': r're:^https?://.*\.jpg$', }, } def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) formats = self._extract_m3u8_formats( self._html_search_regex(r'file\s*:\s*"([^"]+)"', webpage, 'm3u8 manifest URL'), video_id, ext='mp4', entry_protocol='m3u8_native') def search_field(field_name, fatal=False): return self._search_regex( r'<span\s+class="field_title">%s:</span>\s*<span\s+class="field_content">([^<]+)</span>' % field_name, webpage, 'title', fatal=fatal) title = unescapeHTML(search_field('Title', fatal=True)).strip('()[]') description = unescapeHTML(search_field('Description')) duration = parse_duration(search_field('Running time')) thumbnail = self._search_regex( r"image\s*:\s*'([^']+)'", webpage, 'thumbnail', fatal=False) return { 'id': video_id, 'formats': formats, 'title': title, 'description': description, 'duration': duration, 'thumbnail': thumbnail, }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/usanetwork.py
youtube_dl/extractor/usanetwork.py
# coding: utf-8 from __future__ import unicode_literals from .nbc import NBCIE class USANetworkIE(NBCIE): _VALID_URL = r'https?(?P<permalink>://(?:www\.)?usanetwork\.com/[^/]+/video/[^/]+/(?P<id>\d+))' _TESTS = [{ 'url': 'https://www.usanetwork.com/peacock-trailers/video/intelligence-trailer/4185302', 'info_dict': { 'id': '4185302', 'ext': 'mp4', 'title': 'Intelligence (Trailer)', 'description': 'A maverick NSA agent enlists the help of a junior systems analyst in a workplace power grab.', 'upload_date': '20200715', 'timestamp': 1594785600, 'uploader': 'NBCU-MPAT', }, 'params': { # m3u8 download 'skip_download': True, }, }]
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/buzzfeed.py
youtube_dl/extractor/buzzfeed.py
# coding: utf-8 from __future__ import unicode_literals import json import re from .common import InfoExtractor from .facebook import FacebookIE class BuzzFeedIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?buzzfeed\.com/[^?#]*?/(?P<id>[^?#]+)' _TESTS = [{ 'url': 'http://www.buzzfeed.com/abagg/this-angry-ram-destroys-a-punching-bag-like-a-boss?utm_term=4ldqpia', 'info_dict': { 'id': 'this-angry-ram-destroys-a-punching-bag-like-a-boss', 'title': 'This Angry Ram Destroys A Punching Bag Like A Boss', 'description': 'Rambro!', }, 'playlist': [{ 'info_dict': { 'id': 'aVCR29aE_OQ', 'ext': 'mp4', 'title': 'Angry Ram destroys a punching bag..', 'description': 'md5:c59533190ef23fd4458a5e8c8c872345', 'upload_date': '20141024', 'uploader_id': 'Buddhanz1', 'uploader': 'Angry Ram', } }] }, { 'url': 'http://www.buzzfeed.com/sheridanwatson/look-at-this-cute-dog-omg?utm_term=4ldqpia', 'params': { 'skip_download': True, # Got enough YouTube download tests }, 'info_dict': { 'id': 'look-at-this-cute-dog-omg', 'description': 're:Munchkin the Teddy Bear is back ?!', 'title': 'You Need To Stop What You\'re Doing And Watching This Dog Walk On A Treadmill', }, 'playlist': [{ 'info_dict': { 'id': 'mVmBL8B-In0', 'ext': 'mp4', 'title': 're:Munchkin the Teddy Bear gets her exercise', 'description': 'md5:28faab95cda6e361bcff06ec12fc21d8', 'upload_date': '20141124', 'uploader_id': 'CindysMunchkin', 'uploader': 're:^Munchkin the', }, }] }, { 'url': 'http://www.buzzfeed.com/craigsilverman/the-most-adorable-crash-landing-ever#.eq7pX0BAmK', 'info_dict': { 'id': 'the-most-adorable-crash-landing-ever', 'title': 'Watch This Baby Goose Make The Most Adorable Crash Landing', 'description': 'This gosling knows how to stick a landing.', }, 'playlist': [{ 'md5': '763ca415512f91ca62e4621086900a23', 'info_dict': { 'id': '971793786185728', 'ext': 'mp4', 'title': 'We set up crash pads so that the goslings on our roof would have a safe landi...', 'uploader': 'Calgary Outdoor Centre-University of Calgary', }, }], 'add_ie': ['Facebook'], }] def _real_extract(self, url): playlist_id = self._match_id(url) webpage = self._download_webpage(url, playlist_id) all_buckets = re.findall( r'(?s)<div class="video-embed[^"]*"..*?rel:bf_bucket_data=\'([^\']+)\'', webpage) entries = [] for bd_json in all_buckets: bd = json.loads(bd_json) video = bd.get('video') or bd.get('progload_video') if not video: continue entries.append(self.url_result(video['url'])) facebook_urls = FacebookIE._extract_urls(webpage) entries.extend([ self.url_result(facebook_url) for facebook_url in facebook_urls]) return { '_type': 'playlist', 'id': playlist_id, 'title': self._og_search_title(webpage), 'description': self._og_search_description(webpage), 'entries': entries, }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/deezer.py
youtube_dl/extractor/deezer.py
from __future__ import unicode_literals import json import re from .common import InfoExtractor from ..utils import ( ExtractorError, int_or_none, orderedSet, ) class DeezerPlaylistIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?deezer\.com/playlist/(?P<id>[0-9]+)' _TEST = { 'url': 'http://www.deezer.com/playlist/176747451', 'info_dict': { 'id': '176747451', 'title': 'Best!', 'uploader': 'Anonymous', 'thumbnail': r're:^https?://cdn-images\.deezer\.com/images/cover/.*\.jpg$', }, 'playlist_count': 30, 'skip': 'Only available in .de', } def _real_extract(self, url): if 'test' not in self._downloader.params: self._downloader.report_warning('For now, this extractor only supports the 30 second previews. Patches welcome!') mobj = re.match(self._VALID_URL, url) playlist_id = mobj.group('id') webpage = self._download_webpage(url, playlist_id) geoblocking_msg = self._html_search_regex( r'<p class="soon-txt">(.*?)</p>', webpage, 'geoblocking message', default=None) if geoblocking_msg is not None: raise ExtractorError( 'Deezer said: %s' % geoblocking_msg, expected=True) data_json = self._search_regex( (r'__DZR_APP_STATE__\s*=\s*({.+?})\s*</script>', r'naboo\.display\(\'[^\']+\',\s*(.*?)\);\n'), webpage, 'data JSON') data = json.loads(data_json) playlist_title = data.get('DATA', {}).get('TITLE') playlist_uploader = data.get('DATA', {}).get('PARENT_USERNAME') playlist_thumbnail = self._search_regex( r'<img id="naboo_playlist_image".*?src="([^"]+)"', webpage, 'playlist thumbnail') preview_pattern = self._search_regex( r"var SOUND_PREVIEW_GATEWAY\s*=\s*'([^']+)';", webpage, 'preview URL pattern', fatal=False) entries = [] for s in data['SONGS']['data']: puid = s['MD5_ORIGIN'] preview_video_url = preview_pattern.\ replace('{0}', puid[0]).\ replace('{1}', puid).\ replace('{2}', s['MEDIA_VERSION']) formats = [{ 'format_id': 'preview', 'url': preview_video_url, 'preference': -100, # Only the first 30 seconds 'ext': 'mp3', }] self._sort_formats(formats) artists = ', '.join( orderedSet(a['ART_NAME'] for a in s['ARTISTS'])) entries.append({ 'id': s['SNG_ID'], 'duration': int_or_none(s.get('DURATION')), 'title': '%s - %s' % (artists, s['SNG_TITLE']), 'uploader': s['ART_NAME'], 'uploader_id': s['ART_ID'], 'age_limit': 16 if s.get('EXPLICIT_LYRICS') == '1' else 0, 'formats': formats, }) return { '_type': 'playlist', 'id': playlist_id, 'title': playlist_title, 'uploader': playlist_uploader, 'thumbnail': playlist_thumbnail, 'entries': entries, }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/tvplayer.py
youtube_dl/extractor/tvplayer.py
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..compat import ( compat_HTTPError, compat_str, ) from ..utils import ( extract_attributes, try_get, urlencode_postdata, ExtractorError, ) class TVPlayerIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?tvplayer\.com/watch/(?P<id>[^/?#]+)' _TEST = { 'url': 'http://tvplayer.com/watch/bbcone', 'info_dict': { 'id': '89', 'ext': 'mp4', 'title': r're:^BBC One [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$', }, 'params': { # m3u8 download 'skip_download': True, } } def _real_extract(self, url): display_id = self._match_id(url) webpage = self._download_webpage(url, display_id) current_channel = extract_attributes(self._search_regex( r'(<div[^>]+class="[^"]*current-channel[^"]*"[^>]*>)', webpage, 'channel element')) title = current_channel['data-name'] resource_id = current_channel['data-id'] token = self._search_regex( r'data-token=(["\'])(?P<token>(?!\1).+)\1', webpage, 'token', group='token') context = self._download_json( 'https://tvplayer.com/watch/context', display_id, 'Downloading JSON context', query={ 'resource': resource_id, 'gen': token, }) validate = context['validate'] platform = try_get( context, lambda x: x['platform']['key'], compat_str) or 'firefox' try: response = self._download_json( 'http://api.tvplayer.com/api/v2/stream/live', display_id, 'Downloading JSON stream', headers={ 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', }, data=urlencode_postdata({ 'id': resource_id, 'service': 1, 'platform': platform, 'validate': validate, }))['tvplayer']['response'] except ExtractorError as e: if isinstance(e.cause, compat_HTTPError): response = self._parse_json( e.cause.read().decode(), resource_id)['tvplayer']['response'] raise ExtractorError( '%s said: %s' % (self.IE_NAME, response['error']), expected=True) raise formats = self._extract_m3u8_formats(response['stream'], display_id, 'mp4') self._sort_formats(formats) return { 'id': resource_id, 'display_id': display_id, 'title': self._live_title(title), 'formats': formats, 'is_live': True, }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/tvigle.py
youtube_dl/extractor/tvigle.py
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import ( ExtractorError, float_or_none, int_or_none, parse_age_limit, try_get, url_or_none, ) class TvigleIE(InfoExtractor): IE_NAME = 'tvigle' IE_DESC = 'Интернет-телевидение Tvigle.ru' _VALID_URL = r'https?://(?:www\.)?(?:tvigle\.ru/(?:[^/]+/)+(?P<display_id>[^/]+)/$|cloud\.tvigle\.ru/video/(?P<id>\d+))' _GEO_BYPASS = False _GEO_COUNTRIES = ['RU'] _TESTS = [ { 'url': 'http://www.tvigle.ru/video/sokrat/', 'info_dict': { 'id': '1848932', 'display_id': 'sokrat', 'ext': 'mp4', 'title': 'Сократ', 'description': 'md5:d6b92ffb7217b4b8ebad2e7665253c17', 'duration': 6586, 'age_limit': 12, }, 'skip': 'georestricted', }, { 'url': 'http://www.tvigle.ru/video/vladimir-vysotskii/vedushchii-teleprogrammy-60-minut-ssha-o-vladimire-vysotskom/', 'info_dict': { 'id': '5142516', 'ext': 'flv', 'title': 'Ведущий телепрограммы «60 минут» (США) о Владимире Высоцком', 'description': 'md5:027f7dc872948f14c96d19b4178428a4', 'duration': 186.080, 'age_limit': 0, }, 'skip': 'georestricted', }, { 'url': 'https://cloud.tvigle.ru/video/5267604/', 'only_matching': True, } ] def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) video_id = mobj.group('id') display_id = mobj.group('display_id') if not video_id: webpage = self._download_webpage(url, display_id) video_id = self._html_search_regex( (r'<div[^>]+class=["\']player["\'][^>]+id=["\'](\d+)', r'cloudId\s*=\s*["\'](\d+)', r'class="video-preview current_playing" id="(\d+)"'), webpage, 'video id') video_data = self._download_json( 'http://cloud.tvigle.ru/api/play/video/%s/' % video_id, display_id) item = video_data['playlist']['items'][0] videos = item.get('videos') error_message = item.get('errorMessage') if not videos and error_message: if item.get('isGeoBlocked') is True: self.raise_geo_restricted( msg=error_message, countries=self._GEO_COUNTRIES) else: raise ExtractorError( '%s returned error: %s' % (self.IE_NAME, error_message), expected=True) title = item['title'] description = item.get('description') thumbnail = item.get('thumbnail') duration = float_or_none(item.get('durationMilliseconds'), 1000) age_limit = parse_age_limit(item.get('ageRestrictions')) formats = [] for vcodec, url_or_fmts in item['videos'].items(): if vcodec == 'hls': m3u8_url = url_or_none(url_or_fmts) if not m3u8_url: continue formats.extend(self._extract_m3u8_formats( m3u8_url, video_id, ext='mp4', entry_protocol='m3u8_native', m3u8_id='hls', fatal=False)) elif vcodec == 'dash': mpd_url = url_or_none(url_or_fmts) if not mpd_url: continue formats.extend(self._extract_mpd_formats( mpd_url, video_id, mpd_id='dash', fatal=False)) else: if not isinstance(url_or_fmts, dict): continue for format_id, video_url in url_or_fmts.items(): if format_id == 'm3u8': continue video_url = url_or_none(video_url) if not video_url: continue height = self._search_regex( r'^(\d+)[pP]$', format_id, 'height', default=None) filesize = int_or_none(try_get( item, lambda x: x['video_files_size'][vcodec][format_id])) formats.append({ 'url': video_url, 'format_id': '%s-%s' % (vcodec, format_id), 'vcodec': vcodec, 'height': int_or_none(height), 'filesize': filesize, }) self._sort_formats(formats) return { 'id': video_id, 'display_id': display_id, 'title': title, 'description': description, 'thumbnail': thumbnail, 'duration': duration, 'age_limit': age_limit, 'formats': formats, }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/amp.py
youtube_dl/extractor/amp.py
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..utils import ( determine_ext, ExtractorError, int_or_none, mimetype2ext, parse_iso8601, unified_timestamp, url_or_none, ) class AMPIE(InfoExtractor): # parse Akamai Adaptive Media Player feed def _extract_feed_info(self, url): feed = self._download_json( url, None, 'Downloading Akamai AMP feed', 'Unable to download Akamai AMP feed') item = feed.get('channel', {}).get('item') if not item: raise ExtractorError('%s said: %s' % (self.IE_NAME, feed['error'])) video_id = item['guid'] def get_media_node(name, default=None): media_name = 'media-%s' % name media_group = item.get('media-group') or item return media_group.get(media_name) or item.get(media_name) or item.get(name, default) thumbnails = [] media_thumbnail = get_media_node('thumbnail') if media_thumbnail: if isinstance(media_thumbnail, dict): media_thumbnail = [media_thumbnail] for thumbnail_data in media_thumbnail: thumbnail = thumbnail_data.get('@attributes', {}) thumbnail_url = url_or_none(thumbnail.get('url')) if not thumbnail_url: continue thumbnails.append({ 'url': self._proto_relative_url(thumbnail_url, 'http:'), 'width': int_or_none(thumbnail.get('width')), 'height': int_or_none(thumbnail.get('height')), }) subtitles = {} media_subtitle = get_media_node('subTitle') if media_subtitle: if isinstance(media_subtitle, dict): media_subtitle = [media_subtitle] for subtitle_data in media_subtitle: subtitle = subtitle_data.get('@attributes', {}) subtitle_href = url_or_none(subtitle.get('href')) if not subtitle_href: continue subtitles.setdefault(subtitle.get('lang') or 'en', []).append({ 'url': subtitle_href, 'ext': mimetype2ext(subtitle.get('type')) or determine_ext(subtitle_href), }) formats = [] media_content = get_media_node('content') if isinstance(media_content, dict): media_content = [media_content] for media_data in media_content: media = media_data.get('@attributes', {}) media_url = url_or_none(media.get('url')) if not media_url: continue ext = mimetype2ext(media.get('type')) or determine_ext(media_url) if ext == 'f4m': formats.extend(self._extract_f4m_formats( media_url + '?hdcore=3.4.0&plugin=aasp-3.4.0.132.124', video_id, f4m_id='hds', fatal=False)) elif ext == 'm3u8': formats.extend(self._extract_m3u8_formats( media_url, video_id, 'mp4', m3u8_id='hls', fatal=False)) else: formats.append({ 'format_id': media_data.get('media-category', {}).get('@attributes', {}).get('label'), 'url': media_url, 'tbr': int_or_none(media.get('bitrate')), 'filesize': int_or_none(media.get('fileSize')), 'ext': ext, }) self._sort_formats(formats) timestamp = unified_timestamp(item.get('pubDate'), ' ') or parse_iso8601(item.get('dc-date')) return { 'id': video_id, 'title': get_media_node('title'), 'description': get_media_node('description'), 'thumbnails': thumbnails, 'timestamp': timestamp, 'duration': int_or_none(media_content[0].get('@attributes', {}).get('duration')), 'subtitles': subtitles, 'formats': formats, }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/zhihu.py
youtube_dl/extractor/zhihu.py
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..utils import float_or_none, int_or_none class ZhihuIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?zhihu\.com/zvideo/(?P<id>[0-9]+)' _TEST = { 'url': 'https://www.zhihu.com/zvideo/1342930761977176064', 'md5': 'c8d4c9cd72dd58e6f9bc9c2c84266464', 'info_dict': { 'id': '1342930761977176064', 'ext': 'mp4', 'title': '写春联也太难了吧!', 'thumbnail': r're:^https?://.*\.jpg', 'uploader': '桥半舫', 'timestamp': 1612959715, 'upload_date': '20210210', 'uploader_id': '244ecb13b0fd7daf92235288c8ca3365', 'duration': 146.333, 'view_count': int, 'like_count': int, 'comment_count': int, } } def _real_extract(self, url): video_id = self._match_id(url) zvideo = self._download_json( 'https://www.zhihu.com/api/v4/zvideos/' + video_id, video_id) title = zvideo['title'] video = zvideo.get('video') or {} formats = [] for format_id, q in (video.get('playlist') or {}).items(): play_url = q.get('url') or q.get('play_url') if not play_url: continue formats.append({ 'asr': int_or_none(q.get('sample_rate')), 'filesize': int_or_none(q.get('size')), 'format_id': format_id, 'fps': int_or_none(q.get('fps')), 'height': int_or_none(q.get('height')), 'tbr': float_or_none(q.get('bitrate')), 'url': play_url, 'width': int_or_none(q.get('width')), }) self._sort_formats(formats) author = zvideo.get('author') or {} url_token = author.get('url_token') return { 'id': video_id, 'title': title, 'formats': formats, 'thumbnail': video.get('thumbnail') or zvideo.get('image_url'), 'uploader': author.get('name'), 'timestamp': int_or_none(zvideo.get('published_at')), 'uploader_id': author.get('id'), 'uploader_url': 'https://www.zhihu.com/people/' + url_token if url_token else None, 'duration': float_or_none(video.get('duration')), 'view_count': int_or_none(zvideo.get('play_count')), 'like_count': int_or_none(zvideo.get('liked_count')), 'comment_count': int_or_none(zvideo.get('comment_count')), }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/ruv.py
youtube_dl/extractor/ruv.py
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..utils import ( determine_ext, unified_timestamp, ) class RuvIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?ruv\.is/(?:sarpurinn/[^/]+|node)/(?P<id>[^/]+(?:/\d+)?)' _TESTS = [{ # m3u8 'url': 'http://ruv.is/sarpurinn/ruv-aukaras/fh-valur/20170516', 'md5': '66347652f4e13e71936817102acc1724', 'info_dict': { 'id': '1144499', 'display_id': 'fh-valur/20170516', 'ext': 'mp4', 'title': 'FH - Valur', 'description': 'Bein útsending frá 3. leik FH og Vals í úrslitum Olísdeildar karla í handbolta.', 'timestamp': 1494963600, 'upload_date': '20170516', }, }, { # mp3 'url': 'http://ruv.is/sarpurinn/ras-2/morgunutvarpid/20170619', 'md5': '395ea250c8a13e5fdb39d4670ef85378', 'info_dict': { 'id': '1153630', 'display_id': 'morgunutvarpid/20170619', 'ext': 'mp3', 'title': 'Morgunútvarpið', 'description': 'md5:a4cf1202c0a1645ca096b06525915418', 'timestamp': 1497855000, 'upload_date': '20170619', }, }, { 'url': 'http://ruv.is/sarpurinn/ruv/frettir/20170614', 'only_matching': True, }, { 'url': 'http://www.ruv.is/node/1151854', 'only_matching': True, }, { 'url': 'http://ruv.is/sarpurinn/klippa/secret-soltice-hefst-a-morgun', 'only_matching': True, }, { 'url': 'http://ruv.is/sarpurinn/ras-1/morgunvaktin/20170619', 'only_matching': True, }] def _real_extract(self, url): display_id = self._match_id(url) webpage = self._download_webpage(url, display_id) title = self._og_search_title(webpage) FIELD_RE = r'video\.%s\s*=\s*(["\'])(?P<url>(?:(?!\1).)+)\1' media_url = self._html_search_regex( FIELD_RE % 'src', webpage, 'video URL', group='url') video_id = self._search_regex( r'<link\b[^>]+\bhref=["\']https?://www\.ruv\.is/node/(\d+)', webpage, 'video id', default=display_id) ext = determine_ext(media_url) if ext == 'm3u8': formats = self._extract_m3u8_formats( media_url, video_id, 'mp4', entry_protocol='m3u8_native', m3u8_id='hls') elif ext == 'mp3': formats = [{ 'format_id': 'mp3', 'url': media_url, 'vcodec': 'none', }] else: formats = [{ 'url': media_url, }] description = self._og_search_description(webpage, default=None) thumbnail = self._og_search_thumbnail( webpage, default=None) or self._search_regex( FIELD_RE % 'poster', webpage, 'thumbnail', fatal=False) timestamp = unified_timestamp(self._html_search_meta( 'article:published_time', webpage, 'timestamp', fatal=False)) return { 'id': video_id, 'display_id': display_id, 'title': title, 'description': description, 'thumbnail': thumbnail, 'timestamp': timestamp, 'formats': formats, }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/tnaflix.py
youtube_dl/extractor/tnaflix.py
from __future__ import unicode_literals import re from .common import InfoExtractor from ..compat import compat_str from ..utils import ( fix_xml_ampersands, float_or_none, int_or_none, parse_duration, str_to_int, unescapeHTML, xpath_text, ) class TNAFlixNetworkBaseIE(InfoExtractor): # May be overridden in descendants if necessary _CONFIG_REGEX = [ r'flashvars\.config\s*=\s*escape\("(?P<url>[^"]+)"', r'<input[^>]+name="config\d?" value="(?P<url>[^"]+)"', r'config\s*=\s*(["\'])(?P<url>(?:https?:)?//(?:(?!\1).)+)\1', ] _HOST = 'tna' _VKEY_SUFFIX = '' _TITLE_REGEX = r'<input[^>]+name="title" value="([^"]+)"' _DESCRIPTION_REGEX = r'<input[^>]+name="description" value="([^"]+)"' _UPLOADER_REGEX = r'<input[^>]+name="username" value="([^"]+)"' _VIEW_COUNT_REGEX = None _COMMENT_COUNT_REGEX = None _AVERAGE_RATING_REGEX = None _CATEGORIES_REGEX = r'<li[^>]*>\s*<span[^>]+class="infoTitle"[^>]*>Categories:</span>\s*<span[^>]+class="listView"[^>]*>(.+?)</span>\s*</li>' def _extract_thumbnails(self, flix_xml): def get_child(elem, names): for name in names: child = elem.find(name) if child is not None: return child timeline = get_child(flix_xml, ['timeline', 'rolloverBarImage']) if timeline is None: return pattern_el = get_child(timeline, ['imagePattern', 'pattern']) if pattern_el is None or not pattern_el.text: return first_el = get_child(timeline, ['imageFirst', 'first']) last_el = get_child(timeline, ['imageLast', 'last']) if first_el is None or last_el is None: return first_text = first_el.text last_text = last_el.text if not first_text.isdigit() or not last_text.isdigit(): return first = int(first_text) last = int(last_text) if first > last: return width = int_or_none(xpath_text(timeline, './imageWidth', 'thumbnail width')) height = int_or_none(xpath_text(timeline, './imageHeight', 'thumbnail height')) return [{ 'url': self._proto_relative_url(pattern_el.text.replace('#', compat_str(i)), 'http:'), 'width': width, 'height': height, } for i in range(first, last + 1)] def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) video_id = mobj.group('id') for display_id_key in ('display_id', 'display_id_2'): if display_id_key in mobj.groupdict(): display_id = mobj.group(display_id_key) if display_id: break else: display_id = video_id webpage = self._download_webpage(url, display_id) cfg_url = self._proto_relative_url(self._html_search_regex( self._CONFIG_REGEX, webpage, 'flashvars.config', default=None, group='url'), 'http:') if not cfg_url: inputs = self._hidden_inputs(webpage) cfg_url = ('https://cdn-fck.%sflix.com/%sflix/%s%s.fid?key=%s&VID=%s&premium=1&vip=1&alpha' % (self._HOST, self._HOST, inputs['vkey'], self._VKEY_SUFFIX, inputs['nkey'], video_id)) cfg_xml = self._download_xml( cfg_url, display_id, 'Downloading metadata', transform_source=fix_xml_ampersands, headers={'Referer': url}) formats = [] def extract_video_url(vl): # Any URL modification now results in HTTP Error 403: Forbidden return unescapeHTML(vl.text) video_link = cfg_xml.find('./videoLink') if video_link is not None: formats.append({ 'url': extract_video_url(video_link), 'ext': xpath_text(cfg_xml, './videoConfig/type', 'type', default='flv'), }) for item in cfg_xml.findall('./quality/item'): video_link = item.find('./videoLink') if video_link is None: continue res = item.find('res') format_id = None if res is None else res.text height = int_or_none(self._search_regex( r'^(\d+)[pP]', format_id, 'height', default=None)) formats.append({ 'url': self._proto_relative_url(extract_video_url(video_link), 'http:'), 'format_id': format_id, 'height': height, }) self._sort_formats(formats) thumbnail = self._proto_relative_url( xpath_text(cfg_xml, './startThumb', 'thumbnail'), 'http:') thumbnails = self._extract_thumbnails(cfg_xml) title = None if self._TITLE_REGEX: title = self._html_search_regex( self._TITLE_REGEX, webpage, 'title', default=None) if not title: title = self._og_search_title(webpage) age_limit = self._rta_search(webpage) or 18 duration = parse_duration(self._html_search_meta( 'duration', webpage, 'duration', default=None)) def extract_field(pattern, name): return self._html_search_regex(pattern, webpage, name, default=None) if pattern else None description = extract_field(self._DESCRIPTION_REGEX, 'description') uploader = extract_field(self._UPLOADER_REGEX, 'uploader') view_count = str_to_int(extract_field(self._VIEW_COUNT_REGEX, 'view count')) comment_count = str_to_int(extract_field(self._COMMENT_COUNT_REGEX, 'comment count')) average_rating = float_or_none(extract_field(self._AVERAGE_RATING_REGEX, 'average rating')) categories_str = extract_field(self._CATEGORIES_REGEX, 'categories') categories = [c.strip() for c in categories_str.split(',')] if categories_str is not None else [] return { 'id': video_id, 'display_id': display_id, 'title': title, 'description': description, 'thumbnail': thumbnail, 'thumbnails': thumbnails, 'duration': duration, 'age_limit': age_limit, 'uploader': uploader, 'view_count': view_count, 'comment_count': comment_count, 'average_rating': average_rating, 'categories': categories, 'formats': formats, } class TNAFlixNetworkEmbedIE(TNAFlixNetworkBaseIE): _VALID_URL = r'https?://player\.(?:tna|emp)flix\.com/video/(?P<id>\d+)' _TITLE_REGEX = r'<title>([^<]+)</title>' _TESTS = [{ 'url': 'https://player.tnaflix.com/video/6538', 'info_dict': { 'id': '6538', 'display_id': '6538', 'ext': 'mp4', 'title': 'Educational xxx video', 'thumbnail': r're:https?://.*\.jpg$', 'age_limit': 18, }, 'params': { 'skip_download': True, }, }, { 'url': 'https://player.empflix.com/video/33051', 'only_matching': True, }] @staticmethod def _extract_urls(webpage): return [url for _, url in re.findall( r'<iframe[^>]+?src=(["\'])(?P<url>(?:https?:)?//player\.(?:tna|emp)flix\.com/video/\d+)\1', webpage)] class TNAEMPFlixBaseIE(TNAFlixNetworkBaseIE): _DESCRIPTION_REGEX = r'(?s)>Description:</[^>]+>(.+?)<' _UPLOADER_REGEX = r'<span>by\s*<a[^>]+\bhref=["\']/profile/[^>]+>([^<]+)<' _CATEGORIES_REGEX = r'(?s)<span[^>]*>Categories:</span>(.+?)</div>' class TNAFlixIE(TNAEMPFlixBaseIE): _VALID_URL = r'https?://(?:www\.)?tnaflix\.com/[^/]+/(?P<display_id>[^/]+)/video(?P<id>\d+)' _TITLE_REGEX = r'<title>(.+?) - (?:TNAFlix Porn Videos|TNAFlix\.com)</title>' _TESTS = [{ # anonymous uploader, no categories 'url': 'http://www.tnaflix.com/porn-stars/Carmella-Decesare-striptease/video553878', 'md5': '7e569419fe6d69543d01e6be22f5f7c4', 'info_dict': { 'id': '553878', 'display_id': 'Carmella-Decesare-striptease', 'ext': 'mp4', 'title': 'Carmella Decesare - striptease', 'thumbnail': r're:https?://.*\.jpg$', 'duration': 91, 'age_limit': 18, 'categories': ['Porn Stars'], } }, { # non-anonymous uploader, categories 'url': 'https://www.tnaflix.com/teen-porn/Educational-xxx-video/video6538', 'md5': '0f5d4d490dbfd117b8607054248a07c0', 'info_dict': { 'id': '6538', 'display_id': 'Educational-xxx-video', 'ext': 'mp4', 'title': 'Educational xxx video', 'description': 'md5:b4fab8f88a8621c8fabd361a173fe5b8', 'thumbnail': r're:https?://.*\.jpg$', 'duration': 164, 'age_limit': 18, 'uploader': 'bobwhite39', 'categories': list, } }, { 'url': 'https://www.tnaflix.com/amateur-porn/bunzHD-Ms.Donk/video358632', 'only_matching': True, }] class EMPFlixIE(TNAEMPFlixBaseIE): _VALID_URL = r'https?://(?:www\.)?empflix\.com/(?:videos/(?P<display_id>.+?)-|[^/]+/(?P<display_id_2>[^/]+)/video)(?P<id>[0-9]+)' _HOST = 'emp' _VKEY_SUFFIX = '-1' _TESTS = [{ 'url': 'http://www.empflix.com/videos/Amateur-Finger-Fuck-33051.html', 'md5': 'bc30d48b91a7179448a0bda465114676', 'info_dict': { 'id': '33051', 'display_id': 'Amateur-Finger-Fuck', 'ext': 'mp4', 'title': 'Amateur Finger Fuck', 'description': 'Amateur solo finger fucking.', 'thumbnail': r're:https?://.*\.jpg$', 'duration': 83, 'age_limit': 18, 'uploader': 'cwbike', 'categories': ['Amateur', 'Anal', 'Fisting', 'Home made', 'Solo'], } }, { 'url': 'http://www.empflix.com/videos/[AROMA][ARMD-718]-Aoi-Yoshino-Sawa-25826.html', 'only_matching': True, }, { 'url': 'https://www.empflix.com/amateur-porn/Amateur-Finger-Fuck/video33051', 'only_matching': True, }] class MovieFapIE(TNAFlixNetworkBaseIE): _VALID_URL = r'https?://(?:www\.)?moviefap\.com/videos/(?P<id>[0-9a-f]+)/(?P<display_id>[^/]+)\.html' _VIEW_COUNT_REGEX = r'<br>Views\s*<strong>([\d,.]+)</strong>' _COMMENT_COUNT_REGEX = r'<span[^>]+id="comCount"[^>]*>([\d,.]+)</span>' _AVERAGE_RATING_REGEX = r'Current Rating\s*<br>\s*<strong>([\d.]+)</strong>' _CATEGORIES_REGEX = r'(?s)<div[^>]+id="vid_info"[^>]*>\s*<div[^>]*>.+?</div>(.*?)<br>' _TESTS = [{ # normal, multi-format video 'url': 'http://www.moviefap.com/videos/be9867c9416c19f54a4a/experienced-milf-amazing-handjob.html', 'md5': '26624b4e2523051b550067d547615906', 'info_dict': { 'id': 'be9867c9416c19f54a4a', 'display_id': 'experienced-milf-amazing-handjob', 'ext': 'mp4', 'title': 'Experienced MILF Amazing Handjob', 'description': 'Experienced MILF giving an Amazing Handjob', 'thumbnail': r're:https?://.*\.jpg$', 'age_limit': 18, 'uploader': 'darvinfred06', 'view_count': int, 'comment_count': int, 'average_rating': float, 'categories': ['Amateur', 'Masturbation', 'Mature', 'Flashing'], } }, { # quirky single-format case where the extension is given as fid, but the video is really an flv 'url': 'http://www.moviefap.com/videos/e5da0d3edce5404418f5/jeune-couple-russe.html', 'md5': 'fa56683e291fc80635907168a743c9ad', 'info_dict': { 'id': 'e5da0d3edce5404418f5', 'display_id': 'jeune-couple-russe', 'ext': 'flv', 'title': 'Jeune Couple Russe', 'description': 'Amateur', 'thumbnail': r're:https?://.*\.jpg$', 'age_limit': 18, 'uploader': 'whiskeyjar', 'view_count': int, 'comment_count': int, 'average_rating': float, 'categories': ['Amateur', 'Teen'], } }]
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/urort.py
youtube_dl/extractor/urort.py
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..compat import ( compat_urllib_parse, ) from ..utils import ( unified_strdate, ) class UrortIE(InfoExtractor): IE_DESC = 'NRK P3 Urørt' _VALID_URL = r'https?://(?:www\.)?urort\.p3\.no/#!/Band/(?P<id>[^/]+)$' _TEST = { 'url': 'https://urort.p3.no/#!/Band/Gerilja', 'md5': '5ed31a924be8a05e47812678a86e127b', 'info_dict': { 'id': '33124-24', 'ext': 'mp3', 'title': 'The Bomb', 'thumbnail': r're:^https?://.+\.jpg', 'uploader': 'Gerilja', 'uploader_id': 'Gerilja', 'upload_date': '20100323', }, 'params': { 'matchtitle': '^The Bomb$', # To test, we want just one video } } def _real_extract(self, url): playlist_id = self._match_id(url) fstr = compat_urllib_parse.quote("InternalBandUrl eq '%s'" % playlist_id) json_url = 'http://urort.p3.no/breeze/urort/TrackDTOViews?$filter=%s&$orderby=Released%%20desc&$expand=Tags%%2CFiles' % fstr songs = self._download_json(json_url, playlist_id) entries = [] for s in songs: formats = [{ 'tbr': f.get('Quality'), 'ext': f['FileType'], 'format_id': '%s-%s' % (f['FileType'], f.get('Quality', '')), 'url': 'http://p3urort.blob.core.windows.net/tracks/%s' % f['FileRef'], 'preference': 3 if f['FileType'] == 'mp3' else 2, } for f in s['Files']] self._sort_formats(formats) e = { 'id': '%d-%s' % (s['BandId'], s['$id']), 'title': s['Title'], 'uploader_id': playlist_id, 'uploader': s.get('BandName', playlist_id), 'thumbnail': 'http://urort.p3.no/cloud/images/%s' % s['Image'], 'upload_date': unified_strdate(s.get('Released')), 'formats': formats, } entries.append(e) return { '_type': 'playlist', 'id': playlist_id, 'title': playlist_id, 'entries': entries, }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/odatv.py
youtube_dl/extractor/odatv.py
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..utils import ( ExtractorError, NO_DEFAULT, remove_start ) class OdaTVIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?odatv\.com/(?:mob|vid)_video\.php\?.*\bid=(?P<id>[^&]+)' _TESTS = [{ 'url': 'http://odatv.com/vid_video.php?id=8E388', 'md5': 'dc61d052f205c9bf2da3545691485154', 'info_dict': { 'id': '8E388', 'ext': 'mp4', 'title': 'Artık Davutoğlu ile devam edemeyiz' } }, { # mobile URL 'url': 'http://odatv.com/mob_video.php?id=8E388', 'only_matching': True, }, { # no video 'url': 'http://odatv.com/mob_video.php?id=8E900', 'only_matching': True, }] def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) no_video = 'NO VIDEO!' in webpage video_url = self._search_regex( r'mp4\s*:\s*(["\'])(?P<url>http.+?)\1', webpage, 'video url', default=None if no_video else NO_DEFAULT, group='url') if no_video: raise ExtractorError('Video %s does not exist' % video_id, expected=True) return { 'id': video_id, 'url': video_url, 'title': remove_start(self._og_search_title(webpage), 'Video: '), 'thumbnail': self._og_search_thumbnail(webpage), }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/teachertube.py
youtube_dl/extractor/teachertube.py
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import ( determine_ext, ExtractorError, qualities, ) class TeacherTubeIE(InfoExtractor): IE_NAME = 'teachertube' IE_DESC = 'teachertube.com videos' _VALID_URL = r'https?://(?:www\.)?teachertube\.com/(viewVideo\.php\?video_id=|music\.php\?music_id=|video/(?:[\da-z-]+-)?|audio/)(?P<id>\d+)' _TESTS = [{ # flowplayer 'url': 'http://www.teachertube.com/viewVideo.php?video_id=339997', 'md5': 'f9434ef992fd65936d72999951ee254c', 'info_dict': { 'id': '339997', 'ext': 'mp4', 'title': 'Measures of dispersion from a frequency table', 'description': 'Measures of dispersion from a frequency table', 'thumbnail': r're:https?://.*\.(?:jpg|png)', }, }, { # jwplayer 'url': 'http://www.teachertube.com/music.php?music_id=8805', 'md5': '01e8352006c65757caf7b961f6050e21', 'info_dict': { 'id': '8805', 'ext': 'mp3', 'title': 'PER ASPERA AD ASTRA', 'description': 'RADIJSKA EMISIJA ZRAKOPLOVNE TEHNI?KE ?KOLE P', }, }, { # unavailable video 'url': 'http://www.teachertube.com/video/intro-video-schleicher-297790', 'only_matching': True, }] def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) error = self._search_regex( r'<div\b[^>]+\bclass=["\']msgBox error[^>]+>([^<]+)', webpage, 'error', default=None) if error: raise ExtractorError('%s said: %s' % (self.IE_NAME, error), expected=True) title = self._html_search_meta('title', webpage, 'title', fatal=True) TITLE_SUFFIX = ' - TeacherTube' if title.endswith(TITLE_SUFFIX): title = title[:-len(TITLE_SUFFIX)].strip() description = self._html_search_meta('description', webpage, 'description') if description: description = description.strip() quality = qualities(['mp3', 'flv', 'mp4']) media_urls = re.findall(r'data-contenturl="([^"]+)"', webpage) media_urls.extend(re.findall(r'var\s+filePath\s*=\s*"([^"]+)"', webpage)) media_urls.extend(re.findall(r'\'file\'\s*:\s*["\']([^"\']+)["\'],', webpage)) formats = [ { 'url': media_url, 'quality': quality(determine_ext(media_url)) } for media_url in set(media_urls) ] self._sort_formats(formats) thumbnail = self._og_search_thumbnail( webpage, default=None) or self._html_search_meta( 'thumbnail', webpage) return { 'id': video_id, 'title': title, 'description': description, 'thumbnail': thumbnail, 'formats': formats, } class TeacherTubeUserIE(InfoExtractor): IE_NAME = 'teachertube:user:collection' IE_DESC = 'teachertube.com user and collection videos' _VALID_URL = r'https?://(?:www\.)?teachertube\.com/(user/profile|collection)/(?P<user>[0-9a-zA-Z]+)/?' _MEDIA_RE = r'''(?sx) class="?sidebar_thumb_time"?>[0-9:]+</div> \s* <a\s+href="(https?://(?:www\.)?teachertube\.com/(?:video|audio)/[^"]+)" ''' _TEST = { 'url': 'http://www.teachertube.com/user/profile/rbhagwati2', 'info_dict': { 'id': 'rbhagwati2' }, 'playlist_mincount': 179, } def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) user_id = mobj.group('user') urls = [] webpage = self._download_webpage(url, user_id) urls.extend(re.findall(self._MEDIA_RE, webpage)) pages = re.findall(r'/ajax-user/user-videos/%s\?page=([0-9]+)' % user_id, webpage)[:-1] for p in pages: more = 'http://www.teachertube.com/ajax-user/user-videos/%s?page=%s' % (user_id, p) webpage = self._download_webpage(more, user_id, 'Downloading page %s/%s' % (p, len(pages))) video_urls = re.findall(self._MEDIA_RE, webpage) urls.extend(video_urls) entries = [self.url_result(vurl, 'TeacherTube') for vurl in urls] return self.playlist_result(entries, user_id)
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/nosvideo.py
youtube_dl/extractor/nosvideo.py
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import ( ExtractorError, sanitized_Request, urlencode_postdata, xpath_text, xpath_with_ns, ) _x = lambda p: xpath_with_ns(p, {'xspf': 'http://xspf.org/ns/0/'}) class NosVideoIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?nosvideo\.com/' + \ r'(?:embed/|\?v=)(?P<id>[A-Za-z0-9]{12})/?' _PLAYLIST_URL = 'http://nosvideo.com/xml/{xml_id:s}.xml' _FILE_DELETED_REGEX = r'<b>File Not Found</b>' _TEST = { 'url': 'http://nosvideo.com/?v=mu8fle7g7rpq', 'md5': '6124ed47130d8be3eacae635b071e6b6', 'info_dict': { 'id': 'mu8fle7g7rpq', 'ext': 'mp4', 'title': 'big_buck_bunny_480p_surround-fix.avi.mp4', 'thumbnail': r're:^https?://.*\.jpg$', } } def _real_extract(self, url): video_id = self._match_id(url) fields = { 'id': video_id, 'op': 'download1', 'method_free': 'Continue to Video', } req = sanitized_Request(url, urlencode_postdata(fields)) req.add_header('Content-type', 'application/x-www-form-urlencoded') webpage = self._download_webpage(req, video_id, 'Downloading download page') if re.search(self._FILE_DELETED_REGEX, webpage) is not None: raise ExtractorError('Video %s does not exist' % video_id, expected=True) xml_id = self._search_regex(r'php\|([^\|]+)\|', webpage, 'XML ID') playlist_url = self._PLAYLIST_URL.format(xml_id=xml_id) playlist = self._download_xml(playlist_url, video_id) track = playlist.find(_x('.//xspf:track')) if track is None: raise ExtractorError( 'XML playlist is missing the \'track\' element', expected=True) title = xpath_text(track, _x('./xspf:title'), 'title') url = xpath_text(track, _x('./xspf:file'), 'URL', fatal=True) thumbnail = xpath_text(track, _x('./xspf:image'), 'thumbnail') if title is not None: title = title.strip() formats = [{ 'format_id': 'sd', 'url': url, }] return { 'id': video_id, 'title': title, 'thumbnail': thumbnail, 'formats': formats, }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/tubitv.py
youtube_dl/extractor/tubitv.py
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import ( ExtractorError, int_or_none, sanitized_Request, urlencode_postdata, ) class TubiTvIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?tubitv\.com/(?:video|movies|tv-shows)/(?P<id>[0-9]+)' _LOGIN_URL = 'http://tubitv.com/login' _NETRC_MACHINE = 'tubitv' _GEO_COUNTRIES = ['US'] _TESTS = [{ 'url': 'http://tubitv.com/video/283829/the_comedian_at_the_friday', 'md5': '43ac06be9326f41912dc64ccf7a80320', 'info_dict': { 'id': '283829', 'ext': 'mp4', 'title': 'The Comedian at The Friday', 'description': 'A stand up comedian is forced to look at the decisions in his life while on a one week trip to the west coast.', 'uploader_id': 'bc168bee0d18dd1cb3b86c68706ab434', }, }, { 'url': 'http://tubitv.com/tv-shows/321886/s01_e01_on_nom_stories', 'only_matching': True, }, { 'url': 'http://tubitv.com/movies/383676/tracker', 'only_matching': True, }, { 'url': 'https://tubitv.com/movies/560057/penitentiary?start=true', 'info_dict': { 'id': '560057', 'ext': 'mp4', 'title': 'Penitentiary', 'description': 'md5:8d2fc793a93cc1575ff426fdcb8dd3f9', 'uploader_id': 'd8fed30d4f24fcb22ec294421b9defc2', 'release_year': 1979, }, 'params': { 'skip_download': True, }, }] def _login(self): username, password = self._get_login_info() if username is None: return self.report_login() form_data = { 'username': username, 'password': password, } payload = urlencode_postdata(form_data) request = sanitized_Request(self._LOGIN_URL, payload) request.add_header('Content-Type', 'application/x-www-form-urlencoded') login_page = self._download_webpage( request, None, False, 'Wrong login info') if not re.search(r'id="tubi-logout"', login_page): raise ExtractorError( 'Login failed (invalid username/password)', expected=True) def _real_initialize(self): self._login() def _real_extract(self, url): video_id = self._match_id(url) video_data = self._download_json( 'http://tubitv.com/oz/videos/%s/content' % video_id, video_id) title = video_data['title'] formats = self._extract_m3u8_formats( self._proto_relative_url(video_data['url']), video_id, 'mp4', 'm3u8_native') self._sort_formats(formats) thumbnails = [] for thumbnail_url in video_data.get('thumbnails', []): if not thumbnail_url: continue thumbnails.append({ 'url': self._proto_relative_url(thumbnail_url), }) subtitles = {} for sub in video_data.get('subtitles', []): sub_url = sub.get('url') if not sub_url: continue subtitles.setdefault(sub.get('lang', 'English'), []).append({ 'url': self._proto_relative_url(sub_url), }) return { 'id': video_id, 'title': title, 'formats': formats, 'subtitles': subtitles, 'thumbnails': thumbnails, 'description': video_data.get('description'), 'duration': int_or_none(video_data.get('duration')), 'uploader_id': video_data.get('publisher_id'), 'release_year': int_or_none(video_data.get('year')), }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/ondemandkorea.py
youtube_dl/extractor/ondemandkorea.py
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..utils import ( ExtractorError, js_to_json, ) class OnDemandKoreaIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?ondemandkorea\.com/(?P<id>[^/]+)\.html' _GEO_COUNTRIES = ['US', 'CA'] _TEST = { 'url': 'http://www.ondemandkorea.com/ask-us-anything-e43.html', 'info_dict': { 'id': 'ask-us-anything-e43', 'ext': 'mp4', 'title': 'Ask Us Anything : E43', 'thumbnail': r're:^https?://.*\.jpg$', }, 'params': { 'skip_download': 'm3u8 download' } } def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id, fatal=False) if not webpage: # Page sometimes returns captcha page with HTTP 403 raise ExtractorError( 'Unable to access page. You may have been blocked.', expected=True) if 'msg_block_01.png' in webpage: self.raise_geo_restricted( msg='This content is not available in your region', countries=self._GEO_COUNTRIES) if 'This video is only available to ODK PLUS members.' in webpage: raise ExtractorError( 'This video is only available to ODK PLUS members.', expected=True) title = self._og_search_title(webpage) jw_config = self._parse_json( self._search_regex( r'(?s)jwplayer\(([\'"])(?:(?!\1).)+\1\)\.setup\s*\((?P<options>.+?)\);', webpage, 'jw config', group='options'), video_id, transform_source=js_to_json) info = self._parse_jwplayer_data( jw_config, video_id, require_title=False, m3u8_id='hls', base_url=url) info.update({ 'title': title, 'thumbnail': self._og_search_thumbnail(webpage), }) return info
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/bigflix.py
youtube_dl/extractor/bigflix.py
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor from ..compat import ( compat_b64decode, compat_urllib_parse_unquote, ) class BigflixIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?bigflix\.com/.+/(?P<id>[0-9]+)' _TESTS = [{ # 2 formats 'url': 'http://www.bigflix.com/Tamil-movies/Drama-movies/Madarasapatinam/16070', 'info_dict': { 'id': '16070', 'ext': 'mp4', 'title': 'Madarasapatinam', 'description': 'md5:9f0470b26a4ba8e824c823b5d95c2f6b', 'formats': 'mincount:2', }, 'params': { 'skip_download': True, } }, { # multiple formats 'url': 'http://www.bigflix.com/Malayalam-movies/Drama-movies/Indian-Rupee/15967', 'only_matching': True, }] def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) title = self._html_search_regex( r'<div[^>]+class=["\']pagetitle["\'][^>]*>(.+?)</div>', webpage, 'title') def decode_url(quoted_b64_url): return compat_b64decode(compat_urllib_parse_unquote( quoted_b64_url)).decode('utf-8') formats = [] for height, encoded_url in re.findall( r'ContentURL_(\d{3,4})[pP][^=]+=([^&]+)', webpage): video_url = decode_url(encoded_url) f = { 'url': video_url, 'format_id': '%sp' % height, 'height': int(height), } if video_url.startswith('rtmp'): f['ext'] = 'flv' formats.append(f) file_url = self._search_regex( r'file=([^&]+)', webpage, 'video url', default=None) if file_url: video_url = decode_url(file_url) if all(f['url'] != video_url for f in formats): formats.append({ 'url': decode_url(file_url), }) self._sort_formats(formats) description = self._html_search_meta('description', webpage) return { 'id': video_id, 'title': title, 'description': description, 'formats': formats }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/nobelprize.py
youtube_dl/extractor/nobelprize.py
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..utils import ( js_to_json, mimetype2ext, determine_ext, update_url_query, get_element_by_attribute, int_or_none, ) class NobelPrizeIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?nobelprize\.org/mediaplayer.*?\bid=(?P<id>\d+)' _TEST = { 'url': 'http://www.nobelprize.org/mediaplayer/?id=2636', 'md5': '04c81e5714bb36cc4e2232fee1d8157f', 'info_dict': { 'id': '2636', 'ext': 'mp4', 'title': 'Announcement of the 2016 Nobel Prize in Physics', 'description': 'md5:05beba57f4f5a4bbd4cf2ef28fcff739', } } def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) media = self._parse_json(self._search_regex( r'(?s)var\s*config\s*=\s*({.+?});', webpage, 'config'), video_id, js_to_json)['media'] title = media['title'] formats = [] for source in media.get('source', []): source_src = source.get('src') if not source_src: continue ext = mimetype2ext(source.get('type')) or determine_ext(source_src) if ext == 'm3u8': formats.extend(self._extract_m3u8_formats( source_src, video_id, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False)) elif ext == 'f4m': formats.extend(self._extract_f4m_formats( update_url_query(source_src, {'hdcore': '3.7.0'}), video_id, f4m_id='hds', fatal=False)) else: formats.append({ 'url': source_src, }) self._sort_formats(formats) return { 'id': video_id, 'title': title, 'description': get_element_by_attribute('itemprop', 'description', webpage), 'duration': int_or_none(media.get('duration')), 'formats': formats, }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/puhutv.py
youtube_dl/extractor/puhutv.py
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..compat import ( compat_HTTPError, compat_str, ) from ..utils import ( ExtractorError, int_or_none, float_or_none, parse_resolution, str_or_none, try_get, unified_timestamp, url_or_none, urljoin, ) class PuhuTVIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?puhutv\.com/(?P<id>[^/?#&]+)-izle' IE_NAME = 'puhutv' _TESTS = [{ # film 'url': 'https://puhutv.com/sut-kardesler-izle', 'md5': 'a347470371d56e1585d1b2c8dab01c96', 'info_dict': { 'id': '5085', 'display_id': 'sut-kardesler', 'ext': 'mp4', 'title': 'Süt Kardeşler', 'description': 'md5:ca09da25b7e57cbb5a9280d6e48d17aa', 'thumbnail': r're:^https?://.*\.jpg$', 'duration': 4832.44, 'creator': 'Arzu Film', 'timestamp': 1561062602, 'upload_date': '20190620', 'release_year': 1976, 'view_count': int, 'tags': list, }, }, { # episode, geo restricted, bypassable with --geo-verification-proxy 'url': 'https://puhutv.com/jet-sosyete-1-bolum-izle', 'only_matching': True, }, { # 4k, with subtitles 'url': 'https://puhutv.com/dip-1-bolum-izle', 'only_matching': True, }] _SUBTITLE_LANGS = { 'English': 'en', 'Deutsch': 'de', 'عربى': 'ar' } def _real_extract(self, url): display_id = self._match_id(url) info = self._download_json( urljoin(url, '/api/slug/%s-izle' % display_id), display_id)['data'] video_id = compat_str(info['id']) show = info.get('title') or {} title = info.get('name') or show['name'] if info.get('display_name'): title = '%s %s' % (title, info['display_name']) try: videos = self._download_json( 'https://puhutv.com/api/assets/%s/videos' % video_id, display_id, 'Downloading video JSON', headers=self.geo_verification_headers()) except ExtractorError as e: if isinstance(e.cause, compat_HTTPError) and e.cause.code == 403: self.raise_geo_restricted() raise urls = [] formats = [] for video in videos['data']['videos']: media_url = url_or_none(video.get('url')) if not media_url or media_url in urls: continue urls.append(media_url) playlist = video.get('is_playlist') if (video.get('stream_type') == 'hls' and playlist is True) or 'playlist.m3u8' in media_url: formats.extend(self._extract_m3u8_formats( media_url, video_id, 'mp4', entry_protocol='m3u8_native', m3u8_id='hls', fatal=False)) continue quality = int_or_none(video.get('quality')) f = { 'url': media_url, 'ext': 'mp4', 'height': quality } video_format = video.get('video_format') is_hls = (video_format == 'hls' or '/hls/' in media_url or '/chunklist.m3u8' in media_url) and playlist is False if is_hls: format_id = 'hls' f['protocol'] = 'm3u8_native' elif video_format == 'mp4': format_id = 'http' else: continue if quality: format_id += '-%sp' % quality f['format_id'] = format_id formats.append(f) self._sort_formats(formats) creator = try_get( show, lambda x: x['producer']['name'], compat_str) content = info.get('content') or {} images = try_get( content, lambda x: x['images']['wide'], dict) or {} thumbnails = [] for image_id, image_url in images.items(): if not isinstance(image_url, compat_str): continue if not image_url.startswith(('http', '//')): image_url = 'https://%s' % image_url t = parse_resolution(image_id) t.update({ 'id': image_id, 'url': image_url }) thumbnails.append(t) tags = [] for genre in show.get('genres') or []: if not isinstance(genre, dict): continue genre_name = genre.get('name') if genre_name and isinstance(genre_name, compat_str): tags.append(genre_name) subtitles = {} for subtitle in content.get('subtitles') or []: if not isinstance(subtitle, dict): continue lang = subtitle.get('language') sub_url = url_or_none(subtitle.get('url') or subtitle.get('file')) if not lang or not isinstance(lang, compat_str) or not sub_url: continue subtitles[self._SUBTITLE_LANGS.get(lang, lang)] = [{ 'url': sub_url }] return { 'id': video_id, 'display_id': display_id, 'title': title, 'description': info.get('description') or show.get('description'), 'season_id': str_or_none(info.get('season_id')), 'season_number': int_or_none(info.get('season_number')), 'episode_number': int_or_none(info.get('episode_number')), 'release_year': int_or_none(show.get('released_at')), 'timestamp': unified_timestamp(info.get('created_at')), 'creator': creator, 'view_count': int_or_none(content.get('watch_count')), 'duration': float_or_none(content.get('duration_in_ms'), 1000), 'tags': tags, 'subtitles': subtitles, 'thumbnails': thumbnails, 'formats': formats } class PuhuTVSerieIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?puhutv\.com/(?P<id>[^/?#&]+)-detay' IE_NAME = 'puhutv:serie' _TESTS = [{ 'url': 'https://puhutv.com/deniz-yildizi-detay', 'info_dict': { 'title': 'Deniz Yıldızı', 'id': 'deniz-yildizi', }, 'playlist_mincount': 205, }, { # a film detail page which is using same url with serie page 'url': 'https://puhutv.com/kaybedenler-kulubu-detay', 'only_matching': True, }] def _extract_entries(self, seasons): for season in seasons: season_id = season.get('id') if not season_id: continue page = 1 has_more = True while has_more is True: season = self._download_json( 'https://galadriel.puhutv.com/seasons/%s' % season_id, season_id, 'Downloading page %s' % page, query={ 'page': page, 'per': 40, }) episodes = season.get('episodes') if isinstance(episodes, list): for ep in episodes: slug_path = str_or_none(ep.get('slugPath')) if not slug_path: continue video_id = str_or_none(int_or_none(ep.get('id'))) yield self.url_result( 'https://puhutv.com/%s' % slug_path, ie=PuhuTVIE.ie_key(), video_id=video_id, video_title=ep.get('name') or ep.get('eventLabel')) page += 1 has_more = season.get('hasMore') def _real_extract(self, url): playlist_id = self._match_id(url) info = self._download_json( urljoin(url, '/api/slug/%s-detay' % playlist_id), playlist_id)['data'] seasons = info.get('seasons') if seasons: return self.playlist_result( self._extract_entries(seasons), playlist_id, info.get('name')) # For films, these are using same url with series video_id = info.get('slug') or info['assets'][0]['slug'] return self.url_result( 'https://puhutv.com/%s-izle' % video_id, PuhuTVIE.ie_key(), video_id)
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/minoto.py
youtube_dl/extractor/minoto.py
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import ( int_or_none, parse_codecs, ) class MinotoIE(InfoExtractor): _VALID_URL = r'(?:minoto:|https?://(?:play|iframe|embed)\.minoto-video\.com/(?P<player_id>[0-9]+)/)(?P<id>[a-zA-Z0-9]+)' def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) player_id = mobj.group('player_id') or '1' video_id = mobj.group('id') video_data = self._download_json('http://play.minoto-video.com/%s/%s.js' % (player_id, video_id), video_id) video_metadata = video_data['video-metadata'] formats = [] for fmt in video_data['video-files']: fmt_url = fmt.get('url') if not fmt_url: continue container = fmt.get('container') if container == 'hls': formats.extend(fmt_url, video_id, 'mp4', m3u8_id='hls', fatal=False) else: fmt_profile = fmt.get('profile') or {} formats.append({ 'format_id': fmt_profile.get('name-short'), 'format_note': fmt_profile.get('name'), 'url': fmt_url, 'container': container, 'tbr': int_or_none(fmt.get('bitrate')), 'filesize': int_or_none(fmt.get('filesize')), 'width': int_or_none(fmt.get('width')), 'height': int_or_none(fmt.get('height')), 'codecs': parse_codecs(fmt.get('codecs')), }) self._sort_formats(formats) return { 'id': video_id, 'title': video_metadata['title'], 'description': video_metadata.get('description'), 'thumbnail': video_metadata.get('video-poster', {}).get('url'), 'formats': formats, }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/spike.py
youtube_dl/extractor/spike.py
from __future__ import unicode_literals from .mtv import MTVServicesInfoExtractor class BellatorIE(MTVServicesInfoExtractor): _VALID_URL = r'https?://(?:www\.)?bellator\.com/[^/]+/[\da-z]{6}(?:[/?#&]|$)' _TESTS = [{ 'url': 'http://www.bellator.com/fight/atwr7k/bellator-158-michael-page-vs-evangelista-cyborg', 'info_dict': { 'title': 'Michael Page vs. Evangelista Cyborg', 'description': 'md5:0d917fc00ffd72dd92814963fc6cbb05', }, 'playlist_count': 3, }, { 'url': 'http://www.bellator.com/video-clips/bw6k7n/bellator-158-foundations-michael-venom-page', 'only_matching': True, }] _FEED_URL = 'http://www.bellator.com/feeds/mrss/' _GEO_COUNTRIES = ['US'] class ParamountNetworkIE(MTVServicesInfoExtractor): _VALID_URL = r'https?://(?:www\.)?paramountnetwork\.com/[^/]+/[\da-z]{6}(?:[/?#&]|$)' _TESTS = [{ 'url': 'http://www.paramountnetwork.com/episodes/j830qm/lip-sync-battle-joel-mchale-vs-jim-rash-season-2-ep-13', 'info_dict': { 'id': '37ace3a8-1df6-48be-85b8-38df8229e241', 'ext': 'mp4', 'title': 'Lip Sync Battle|April 28, 2016|2|209|Joel McHale Vs. Jim Rash|Act 1', 'description': 'md5:a739ca8f978a7802f67f8016d27ce114', }, 'params': { # m3u8 download 'skip_download': True, }, }] _FEED_URL = 'http://feeds.mtvnservices.com/od/feed/intl-mrss-player-feed' _GEO_COUNTRIES = ['US'] def _get_feed_query(self, uri): return { 'arcEp': 'paramountnetwork.com', 'imageEp': 'paramountnetwork.com', 'mgid': uri, }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/thestar.py
youtube_dl/extractor/thestar.py
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor class TheStarIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?thestar\.com/(?:[^/]+/)*(?P<id>.+)\.html' _TEST = { 'url': 'http://www.thestar.com/life/2016/02/01/mankind-why-this-woman-started-a-men-s-skincare-line.html', 'md5': '2c62dd4db2027e35579fefb97a8b6554', 'info_dict': { 'id': '4732393888001', 'ext': 'mp4', 'title': 'Mankind: Why this woman started a men\'s skin care line', 'description': 'Robert Cribb talks to Young Lee, the founder of Uncle Peter\'s MAN.', 'uploader_id': '794267642001', 'timestamp': 1454353482, 'upload_date': '20160201', }, 'params': { # m3u8 download 'skip_download': True, } } BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/794267642001/default_default/index.html?videoId=%s' def _real_extract(self, url): display_id = self._match_id(url) webpage = self._download_webpage(url, display_id) brightcove_id = self._search_regex( r'mainartBrightcoveVideoId["\']?\s*:\s*["\']?(\d+)', webpage, 'brightcove id') return self.url_result( self.BRIGHTCOVE_URL_TEMPLATE % brightcove_id, 'BrightcoveNew', brightcove_id)
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/metacritic.py
youtube_dl/extractor/metacritic.py
from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import ( fix_xml_ampersands, ) class MetacriticIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?metacritic\.com/.+?/trailers/(?P<id>\d+)' _TESTS = [{ 'url': 'http://www.metacritic.com/game/playstation-4/infamous-second-son/trailers/3698222', 'info_dict': { 'id': '3698222', 'ext': 'mp4', 'title': 'inFamous: Second Son - inSide Sucker Punch: Smoke & Mirrors', 'description': 'Take a peak behind-the-scenes to see how Sucker Punch brings smoke into the universe of inFAMOUS Second Son on the PS4.', 'duration': 221, }, 'skip': 'Not providing trailers anymore', }, { 'url': 'http://www.metacritic.com/game/playstation-4/tales-from-the-borderlands-a-telltale-game-series/trailers/5740315', 'info_dict': { 'id': '5740315', 'ext': 'mp4', 'title': 'Tales from the Borderlands - Finale: The Vault of the Traveler', 'description': 'In the final episode of the season, all hell breaks loose. Jack is now in control of Helios\' systems, and he\'s ready to reclaim his rightful place as king of Hyperion (with or without you).', 'duration': 114, }, }] def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) video_id = mobj.group('id') webpage = self._download_webpage(url, video_id) # The xml is not well formatted, there are raw '&' info = self._download_xml('http://www.metacritic.com/video_data?video=' + video_id, video_id, 'Downloading info xml', transform_source=fix_xml_ampersands) clip = next(c for c in info.findall('playList/clip') if c.find('id').text == video_id) formats = [] for videoFile in clip.findall('httpURI/videoFile'): rate_str = videoFile.find('rate').text video_url = videoFile.find('filePath').text formats.append({ 'url': video_url, 'ext': 'mp4', 'format_id': rate_str, 'tbr': int(rate_str), }) self._sort_formats(formats) description = self._html_search_regex(r'<b>Description:</b>(.*?)</p>', webpage, 'description', flags=re.DOTALL) return { 'id': video_id, 'title': clip.find('title').text, 'formats': formats, 'description': description, 'duration': int(clip.find('duration').text), }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/savefrom.py
youtube_dl/extractor/savefrom.py
# coding: utf-8 from __future__ import unicode_literals import os.path import re from .common import InfoExtractor class SaveFromIE(InfoExtractor): IE_NAME = 'savefrom.net' _VALID_URL = r'https?://[^.]+\.savefrom\.net/\#url=(?P<url>.*)$' _TEST = { 'url': 'http://en.savefrom.net/#url=http://youtube.com/watch?v=UlVRAPW2WJY&utm_source=youtube.com&utm_medium=short_domains&utm_campaign=ssyoutube.com', 'info_dict': { 'id': 'UlVRAPW2WJY', 'ext': 'mp4', 'title': 'About Team Radical MMA | MMA Fighting', 'upload_date': '20120816', 'uploader': 'Howcast', 'uploader_id': 'Howcast', 'description': r're:(?s).* Hi, my name is Rene Dreifuss\. And I\'m here to show you some MMA.*', }, 'params': { 'skip_download': True } } def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) video_id = os.path.splitext(url.split('/')[-1])[0] return self.url_result(mobj.group('url'), video_id=video_id)
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/twentyfourvideo.py
youtube_dl/extractor/twentyfourvideo.py
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import ( parse_iso8601, int_or_none, xpath_attr, xpath_element, ) class TwentyFourVideoIE(InfoExtractor): IE_NAME = '24video' _VALID_URL = r'''(?x) https?:// (?P<host> (?:(?:www|porno?)\.)?24video\. (?:net|me|xxx|sexy?|tube|adult|site|vip) )/ (?: video/(?:(?:view|xml)/)?| player/new24_play\.swf\?id= ) (?P<id>\d+) ''' _TESTS = [{ 'url': 'http://www.24video.net/video/view/1044982', 'md5': 'e09fc0901d9eaeedac872f154931deeb', 'info_dict': { 'id': '1044982', 'ext': 'mp4', 'title': 'Эротика каменного века', 'description': 'Как смотрели порно в каменном веке.', 'thumbnail': r're:^https?://.*\.jpg$', 'uploader': 'SUPERTELO', 'duration': 31, 'timestamp': 1275937857, 'upload_date': '20100607', 'age_limit': 18, 'like_count': int, 'dislike_count': int, }, }, { 'url': 'http://www.24video.net/player/new24_play.swf?id=1044982', 'only_matching': True, }, { 'url': 'http://www.24video.me/video/view/1044982', 'only_matching': True, }, { 'url': 'http://www.24video.tube/video/view/2363750', 'only_matching': True, }, { 'url': 'https://www.24video.site/video/view/2640421', 'only_matching': True, }, { 'url': 'https://porno.24video.net/video/2640421-vsya-takaya-gibkaya-i-v-masle', 'only_matching': True, }, { 'url': 'https://www.24video.vip/video/view/1044982', 'only_matching': True, }, { 'url': 'https://porn.24video.net/video/2640421-vsya-takay', 'only_matching': True, }] def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) video_id = mobj.group('id') host = mobj.group('host') webpage = self._download_webpage( 'http://%s/video/view/%s' % (host, video_id), video_id) title = self._og_search_title(webpage) description = self._html_search_regex( r'<(p|span)[^>]+itemprop="description"[^>]*>(?P<description>[^<]+)</\1>', webpage, 'description', fatal=False, group='description') thumbnail = self._og_search_thumbnail(webpage) duration = int_or_none(self._og_search_property( 'duration', webpage, 'duration', fatal=False)) timestamp = parse_iso8601(self._search_regex( r'<time[^>]+\bdatetime="([^"]+)"[^>]+itemprop="uploadDate"', webpage, 'upload date', fatal=False)) uploader = self._html_search_regex( r'class="video-uploaded"[^>]*>\s*<a href="/jsecUser/movies/[^"]+"[^>]*>([^<]+)</a>', webpage, 'uploader', fatal=False) view_count = int_or_none(self._html_search_regex( r'<span class="video-views">(\d+) просмотр', webpage, 'view count', fatal=False)) comment_count = int_or_none(self._html_search_regex( r'<a[^>]+href="#tab-comments"[^>]*>(\d+) комментари', webpage, 'comment count', default=None)) # Sets some cookies self._download_xml( r'http://%s/video/xml/%s?mode=init' % (host, video_id), video_id, 'Downloading init XML') video_xml = self._download_xml( 'http://%s/video/xml/%s?mode=play' % (host, video_id), video_id, 'Downloading video XML') video = xpath_element(video_xml, './/video', 'video', fatal=True) formats = [{ 'url': xpath_attr(video, '', 'url', 'video URL', fatal=True), }] like_count = int_or_none(video.get('ratingPlus')) dislike_count = int_or_none(video.get('ratingMinus')) age_limit = 18 if video.get('adult') == 'true' else 0 return { 'id': video_id, 'title': title, 'description': description, 'thumbnail': thumbnail, 'uploader': uploader, 'duration': duration, 'timestamp': timestamp, 'view_count': view_count, 'comment_count': comment_count, 'like_count': like_count, 'dislike_count': dislike_count, 'age_limit': age_limit, 'formats': formats, }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/discoverynetworks.py
youtube_dl/extractor/discoverynetworks.py
# coding: utf-8 from __future__ import unicode_literals import re from .dplay import DPlayIE class DiscoveryNetworksDeIE(DPlayIE): _VALID_URL = r'https?://(?:www\.)?(?P<domain>(?:tlc|dmax)\.de|dplay\.co\.uk)/(?:programme|show|sendungen)/(?P<programme>[^/]+)/(?:video/)?(?P<alternate_id>[^/]+)' _TESTS = [{ 'url': 'https://www.tlc.de/programme/breaking-amish/video/die-welt-da-drauen/DCB331270001100', 'info_dict': { 'id': '78867', 'ext': 'mp4', 'title': 'Die Welt da draußen', 'description': 'md5:61033c12b73286e409d99a41742ef608', 'timestamp': 1554069600, 'upload_date': '20190331', }, 'params': { 'format': 'bestvideo', 'skip_download': True, }, }, { 'url': 'https://www.dmax.de/programme/dmax-highlights/video/tuning-star-sidney-hoffmann-exklusiv-bei-dmax/191023082312316', 'only_matching': True, }, { 'url': 'https://www.dplay.co.uk/show/ghost-adventures/video/hotel-leger-103620/EHD_280313B', 'only_matching': True, }, { 'url': 'https://tlc.de/sendungen/breaking-amish/die-welt-da-drauen/', 'only_matching': True, }] def _real_extract(self, url): domain, programme, alternate_id = re.match(self._VALID_URL, url).groups() country = 'GB' if domain == 'dplay.co.uk' else 'DE' realm = 'questuk' if country == 'GB' else domain.replace('.', '') return self._get_disco_api_info( url, '%s/%s' % (programme, alternate_id), 'sonic-eu1-prod.disco-api.com', realm, country)
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/stanfordoc.py
youtube_dl/extractor/stanfordoc.py
from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import ( ExtractorError, orderedSet, unescapeHTML, ) class StanfordOpenClassroomIE(InfoExtractor): IE_NAME = 'stanfordoc' IE_DESC = 'Stanford Open ClassRoom' _VALID_URL = r'https?://openclassroom\.stanford\.edu(?P<path>/?|(/MainFolder/(?:HomePage|CoursePage|VideoPage)\.php([?]course=(?P<course>[^&]+)(&video=(?P<video>[^&]+))?(&.*)?)?))$' _TEST = { 'url': 'http://openclassroom.stanford.edu/MainFolder/VideoPage.php?course=PracticalUnix&video=intro-environment&speed=100', 'md5': '544a9468546059d4e80d76265b0443b8', 'info_dict': { 'id': 'PracticalUnix_intro-environment', 'ext': 'mp4', 'title': 'Intro Environment', } } def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) if mobj.group('course') and mobj.group('video'): # A specific video course = mobj.group('course') video = mobj.group('video') info = { 'id': course + '_' + video, 'uploader': None, 'upload_date': None, } baseUrl = 'http://openclassroom.stanford.edu/MainFolder/courses/' + course + '/videos/' xmlUrl = baseUrl + video + '.xml' mdoc = self._download_xml(xmlUrl, info['id']) try: info['title'] = mdoc.findall('./title')[0].text info['url'] = baseUrl + mdoc.findall('./videoFile')[0].text except IndexError: raise ExtractorError('Invalid metadata XML file') return info elif mobj.group('course'): # A course page course = mobj.group('course') info = { 'id': course, '_type': 'playlist', 'uploader': None, 'upload_date': None, } coursepage = self._download_webpage( url, info['id'], note='Downloading course info page', errnote='Unable to download course info page') info['title'] = self._html_search_regex( r'<h1>([^<]+)</h1>', coursepage, 'title', default=info['id']) info['description'] = self._html_search_regex( r'(?s)<description>([^<]+)</description>', coursepage, 'description', fatal=False) links = orderedSet(re.findall(r'<a href="(VideoPage\.php\?[^"]+)">', coursepage)) info['entries'] = [self.url_result( 'http://openclassroom.stanford.edu/MainFolder/%s' % unescapeHTML(l) ) for l in links] return info else: # Root page info = { 'id': 'Stanford OpenClassroom', '_type': 'playlist', 'uploader': None, 'upload_date': None, } info['title'] = info['id'] rootURL = 'http://openclassroom.stanford.edu/MainFolder/HomePage.php' rootpage = self._download_webpage(rootURL, info['id'], errnote='Unable to download course info page') links = orderedSet(re.findall(r'<a href="(CoursePage\.php\?[^"]+)">', rootpage)) info['entries'] = [self.url_result( 'http://openclassroom.stanford.edu/MainFolder/%s' % unescapeHTML(l) ) for l in links] return info
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/amara.py
youtube_dl/extractor/amara.py
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from .youtube import YoutubeIE from .vimeo import VimeoIE from ..utils import ( int_or_none, parse_iso8601, update_url_query, ) class AmaraIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?amara\.org/(?:\w+/)?videos/(?P<id>\w+)' _TESTS = [{ # Youtube 'url': 'https://amara.org/en/videos/jVx79ZKGK1ky/info/why-jury-trials-are-becoming-less-common/?tab=video', 'md5': 'ea10daf2b6154b8c1ecf9922aca5e8ae', 'info_dict': { 'id': 'h6ZuVdvYnfE', 'ext': 'mp4', 'title': 'Why jury trials are becoming less common', 'description': 'md5:a61811c319943960b6ab1c23e0cbc2c1', 'thumbnail': r're:^https?://.*\.jpg$', 'subtitles': dict, 'upload_date': '20160813', 'uploader': 'PBS NewsHour', 'uploader_id': 'PBSNewsHour', 'timestamp': 1549639570, } }, { # Vimeo 'url': 'https://amara.org/en/videos/kYkK1VUTWW5I/info/vimeo-at-ces-2011', 'md5': '99392c75fa05d432a8f11df03612195e', 'info_dict': { 'id': '18622084', 'ext': 'mov', 'title': 'Vimeo at CES 2011!', 'description': 'md5:d41d8cd98f00b204e9800998ecf8427e', 'thumbnail': r're:^https?://.*\.jpg$', 'subtitles': dict, 'timestamp': 1294763658, 'upload_date': '20110111', 'uploader': 'Sam Morrill', 'uploader_id': 'sammorrill' } }, { # Direct Link 'url': 'https://amara.org/en/videos/s8KL7I3jLmh6/info/the-danger-of-a-single-story/', 'md5': 'd3970f08512738ee60c5807311ff5d3f', 'info_dict': { 'id': 's8KL7I3jLmh6', 'ext': 'mp4', 'title': 'The danger of a single story', 'description': 'md5:d769b31139c3b8bb5be9177f62ea3f23', 'thumbnail': r're:^https?://.*\.jpg$', 'subtitles': dict, 'upload_date': '20091007', 'timestamp': 1254942511, } }] def _real_extract(self, url): video_id = self._match_id(url) meta = self._download_json( 'https://amara.org/api/videos/%s/' % video_id, video_id, query={'format': 'json'}) title = meta['title'] video_url = meta['all_urls'][0] subtitles = {} for language in (meta.get('languages') or []): subtitles_uri = language.get('subtitles_uri') if not (subtitles_uri and language.get('published')): continue subtitle = subtitles.setdefault(language.get('code') or 'en', []) for f in ('json', 'srt', 'vtt'): subtitle.append({ 'ext': f, 'url': update_url_query(subtitles_uri, {'format': f}), }) info = { 'url': video_url, 'id': video_id, 'subtitles': subtitles, 'title': title, 'description': meta.get('description'), 'thumbnail': meta.get('thumbnail'), 'duration': int_or_none(meta.get('duration')), 'timestamp': parse_iso8601(meta.get('created')), } for ie in (YoutubeIE, VimeoIE): if ie.suitable(video_url): info.update({ '_type': 'url_transparent', 'ie_key': ie.ie_key(), }) break return info
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/once.py
youtube_dl/extractor/once.py
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor class OnceIE(InfoExtractor): _VALID_URL = r'https?://.+?\.unicornmedia\.com/now/(?:ads/vmap/)?[^/]+/[^/]+/(?P<domain_id>[^/]+)/(?P<application_id>[^/]+)/(?:[^/]+/)?(?P<media_item_id>[^/]+)/content\.(?:once|m3u8|mp4)' ADAPTIVE_URL_TEMPLATE = 'http://once.unicornmedia.com/now/master/playlist/%s/%s/%s/content.m3u8' PROGRESSIVE_URL_TEMPLATE = 'http://once.unicornmedia.com/now/media/progressive/%s/%s/%s/%s/content.mp4' def _extract_once_formats(self, url, http_formats_preference=None): domain_id, application_id, media_item_id = re.match( OnceIE._VALID_URL, url).groups() formats = self._extract_m3u8_formats( self.ADAPTIVE_URL_TEMPLATE % ( domain_id, application_id, media_item_id), media_item_id, 'mp4', m3u8_id='hls', fatal=False) progressive_formats = [] for adaptive_format in formats: # Prevent advertisement from embedding into m3u8 playlist (see # https://github.com/ytdl-org/youtube-dl/issues/8893#issuecomment-199912684) adaptive_format['url'] = re.sub( r'\badsegmentlength=\d+', r'adsegmentlength=0', adaptive_format['url']) rendition_id = self._search_regex( r'/now/media/playlist/[^/]+/[^/]+/([^/]+)', adaptive_format['url'], 'redition id', default=None) if rendition_id: progressive_format = adaptive_format.copy() progressive_format.update({ 'url': self.PROGRESSIVE_URL_TEMPLATE % ( domain_id, application_id, rendition_id, media_item_id), 'format_id': adaptive_format['format_id'].replace( 'hls', 'http'), 'protocol': 'http', 'preference': http_formats_preference, }) progressive_formats.append(progressive_format) self._check_formats(progressive_formats, media_item_id) formats.extend(progressive_formats) return formats
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/foxsports.py
youtube_dl/extractor/foxsports.py
from __future__ import unicode_literals from .common import InfoExtractor class FoxSportsIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?foxsports\.com/(?:[^/]+/)*video/(?P<id>\d+)' _TEST = { 'url': 'http://www.foxsports.com/tennessee/video/432609859715', 'md5': 'b49050e955bebe32c301972e4012ac17', 'info_dict': { 'id': '432609859715', 'ext': 'mp4', 'title': 'Courtney Lee on going up 2-0 in series vs. Blazers', 'description': 'Courtney Lee talks about Memphis being focused.', # TODO: fix timestamp 'upload_date': '19700101', # '20150423', # 'timestamp': 1429761109, 'uploader': 'NEWA-FNG-FOXSPORTS', }, 'params': { # m3u8 download 'skip_download': True, }, 'add_ie': ['ThePlatform'], } def _real_extract(self, url): video_id = self._match_id(url) return self.url_result( 'https://feed.theplatform.com/f/BKQ29B/foxsports-all?byId=' + video_id, 'ThePlatformFeed')
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/prosiebensat1.py
youtube_dl/extractor/prosiebensat1.py
# coding: utf-8 from __future__ import unicode_literals import re from hashlib import sha1 from .common import InfoExtractor from ..compat import compat_str from ..utils import ( ExtractorError, determine_ext, float_or_none, int_or_none, merge_dicts, unified_strdate, ) class ProSiebenSat1BaseIE(InfoExtractor): _GEO_BYPASS = False _ACCESS_ID = None _SUPPORTED_PROTOCOLS = 'dash:clear,hls:clear,progressive:clear' _V4_BASE_URL = 'https://vas-v4.p7s1video.net/4.0/get' def _extract_video_info(self, url, clip_id): client_location = url video = self._download_json( 'http://vas.sim-technik.de/vas/live/v2/videos', clip_id, 'Downloading videos JSON', query={ 'access_token': self._TOKEN, 'client_location': client_location, 'client_name': self._CLIENT_NAME, 'ids': clip_id, })[0] if video.get('is_protected') is True: raise ExtractorError('This video is DRM protected.', expected=True) formats = [] if self._ACCESS_ID: raw_ct = self._ENCRYPTION_KEY + clip_id + self._IV + self._ACCESS_ID protocols = self._download_json( self._V4_BASE_URL + 'protocols', clip_id, 'Downloading protocols JSON', headers=self.geo_verification_headers(), query={ 'access_id': self._ACCESS_ID, 'client_token': sha1((raw_ct).encode()).hexdigest(), 'video_id': clip_id, }, fatal=False, expected_status=(403,)) or {} error = protocols.get('error') or {} if error.get('title') == 'Geo check failed': self.raise_geo_restricted(countries=['AT', 'CH', 'DE']) server_token = protocols.get('server_token') if server_token: urls = (self._download_json( self._V4_BASE_URL + 'urls', clip_id, 'Downloading urls JSON', query={ 'access_id': self._ACCESS_ID, 'client_token': sha1((raw_ct + server_token + self._SUPPORTED_PROTOCOLS).encode()).hexdigest(), 'protocols': self._SUPPORTED_PROTOCOLS, 'server_token': server_token, 'video_id': clip_id, }, fatal=False) or {}).get('urls') or {} for protocol, variant in urls.items(): source_url = variant.get('clear', {}).get('url') if not source_url: continue if protocol == 'dash': formats.extend(self._extract_mpd_formats( source_url, clip_id, mpd_id=protocol, fatal=False)) elif protocol == 'hls': formats.extend(self._extract_m3u8_formats( source_url, clip_id, 'mp4', 'm3u8_native', m3u8_id=protocol, fatal=False)) else: formats.append({ 'url': source_url, 'format_id': protocol, }) if not formats: source_ids = [compat_str(source['id']) for source in video['sources']] client_id = self._SALT[:2] + sha1(''.join([clip_id, self._SALT, self._TOKEN, client_location, self._SALT, self._CLIENT_NAME]).encode('utf-8')).hexdigest() sources = self._download_json( 'http://vas.sim-technik.de/vas/live/v2/videos/%s/sources' % clip_id, clip_id, 'Downloading sources JSON', query={ 'access_token': self._TOKEN, 'client_id': client_id, 'client_location': client_location, 'client_name': self._CLIENT_NAME, }) server_id = sources['server_id'] def fix_bitrate(bitrate): bitrate = int_or_none(bitrate) if not bitrate: return None return (bitrate // 1000) if bitrate % 1000 == 0 else bitrate for source_id in source_ids: client_id = self._SALT[:2] + sha1(''.join([self._SALT, clip_id, self._TOKEN, server_id, client_location, source_id, self._SALT, self._CLIENT_NAME]).encode('utf-8')).hexdigest() urls = self._download_json( 'http://vas.sim-technik.de/vas/live/v2/videos/%s/sources/url' % clip_id, clip_id, 'Downloading urls JSON', fatal=False, query={ 'access_token': self._TOKEN, 'client_id': client_id, 'client_location': client_location, 'client_name': self._CLIENT_NAME, 'server_id': server_id, 'source_ids': source_id, }) if not urls: continue if urls.get('status_code') != 0: raise ExtractorError('This video is unavailable', expected=True) urls_sources = urls['sources'] if isinstance(urls_sources, dict): urls_sources = urls_sources.values() for source in urls_sources: source_url = source.get('url') if not source_url: continue protocol = source.get('protocol') mimetype = source.get('mimetype') if mimetype == 'application/f4m+xml' or 'f4mgenerator' in source_url or determine_ext(source_url) == 'f4m': formats.extend(self._extract_f4m_formats( source_url, clip_id, f4m_id='hds', fatal=False)) elif mimetype == 'application/x-mpegURL': formats.extend(self._extract_m3u8_formats( source_url, clip_id, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False)) elif mimetype == 'application/dash+xml': formats.extend(self._extract_mpd_formats( source_url, clip_id, mpd_id='dash', fatal=False)) else: tbr = fix_bitrate(source['bitrate']) if protocol in ('rtmp', 'rtmpe'): mobj = re.search(r'^(?P<url>rtmpe?://[^/]+)/(?P<path>.+)$', source_url) if not mobj: continue path = mobj.group('path') mp4colon_index = path.rfind('mp4:') app = path[:mp4colon_index] play_path = path[mp4colon_index:] formats.append({ 'url': '%s/%s' % (mobj.group('url'), app), 'app': app, 'play_path': play_path, 'player_url': 'http://livepassdl.conviva.com/hf/ver/2.79.0.17083/LivePassModuleMain.swf', 'page_url': 'http://www.prosieben.de', 'tbr': tbr, 'ext': 'flv', 'format_id': 'rtmp%s' % ('-%d' % tbr if tbr else ''), }) else: formats.append({ 'url': source_url, 'tbr': tbr, 'format_id': 'http%s' % ('-%d' % tbr if tbr else ''), }) self._sort_formats(formats) return { 'duration': float_or_none(video.get('duration')), 'formats': formats, } class ProSiebenSat1IE(ProSiebenSat1BaseIE): IE_NAME = 'prosiebensat1' IE_DESC = 'ProSiebenSat.1 Digital' _VALID_URL = r'''(?x) https?:// (?:www\.)? (?: (?:beta\.)? (?: prosieben(?:maxx)?|sixx|sat1(?:gold)?|kabeleins(?:doku)?|the-voice-of-germany|advopedia )\.(?:de|at|ch)| ran\.de|fem\.com|advopedia\.de|galileo\.tv/video ) /(?P<id>.+) ''' _TESTS = [ { # Tests changes introduced in https://github.com/ytdl-org/youtube-dl/pull/6242 # in response to fixing https://github.com/ytdl-org/youtube-dl/issues/6215: # - malformed f4m manifest support # - proper handling of URLs starting with `https?://` in 2.0 manifests # - recursive child f4m manifests extraction 'url': 'http://www.prosieben.de/tv/circus-halligalli/videos/218-staffel-2-episode-18-jahresrueckblick-ganze-folge', 'info_dict': { 'id': '2104602', 'ext': 'mp4', 'title': 'CIRCUS HALLIGALLI - Episode 18 - Staffel 2', 'description': 'md5:8733c81b702ea472e069bc48bb658fc1', 'upload_date': '20131231', 'duration': 5845.04, 'series': 'CIRCUS HALLIGALLI', 'season_number': 2, 'episode': 'Episode 18 - Staffel 2', 'episode_number': 18, }, }, { 'url': 'http://www.prosieben.de/videokatalog/Gesellschaft/Leben/Trends/video-Lady-Umstyling-f%C3%BCr-Audrina-Rebekka-Audrina-Fergen-billig-aussehen-Battal-Modica-700544.html', 'info_dict': { 'id': '2570327', 'ext': 'mp4', 'title': 'Lady-Umstyling für Audrina', 'description': 'md5:4c16d0c17a3461a0d43ea4084e96319d', 'upload_date': '20131014', 'duration': 606.76, }, 'params': { # rtmp download 'skip_download': True, }, 'skip': 'Seems to be broken', }, { 'url': 'http://www.prosiebenmaxx.de/tv/experience/video/144-countdown-fuer-die-autowerkstatt-ganze-folge', 'info_dict': { 'id': '2429369', 'ext': 'mp4', 'title': 'Countdown für die Autowerkstatt', 'description': 'md5:809fc051a457b5d8666013bc40698817', 'upload_date': '20140223', 'duration': 2595.04, }, 'params': { # rtmp download 'skip_download': True, }, 'skip': 'This video is unavailable', }, { 'url': 'http://www.sixx.de/stars-style/video/sexy-laufen-in-ugg-boots-clip', 'info_dict': { 'id': '2904997', 'ext': 'mp4', 'title': 'Sexy laufen in Ugg Boots', 'description': 'md5:edf42b8bd5bc4e5da4db4222c5acb7d6', 'upload_date': '20140122', 'duration': 245.32, }, 'params': { # rtmp download 'skip_download': True, }, 'skip': 'This video is unavailable', }, { 'url': 'http://www.sat1.de/film/der-ruecktritt/video/im-interview-kai-wiesinger-clip', 'info_dict': { 'id': '2906572', 'ext': 'mp4', 'title': 'Im Interview: Kai Wiesinger', 'description': 'md5:e4e5370652ec63b95023e914190b4eb9', 'upload_date': '20140203', 'duration': 522.56, }, 'params': { # rtmp download 'skip_download': True, }, 'skip': 'This video is unavailable', }, { 'url': 'http://www.kabeleins.de/tv/rosins-restaurants/videos/jagd-auf-fertigkost-im-elsthal-teil-2-ganze-folge', 'info_dict': { 'id': '2992323', 'ext': 'mp4', 'title': 'Jagd auf Fertigkost im Elsthal - Teil 2', 'description': 'md5:2669cde3febe9bce13904f701e774eb6', 'upload_date': '20141014', 'duration': 2410.44, }, 'params': { # rtmp download 'skip_download': True, }, 'skip': 'This video is unavailable', }, { 'url': 'http://www.ran.de/fussball/bundesliga/video/schalke-toennies-moechte-raul-zurueck-ganze-folge', 'info_dict': { 'id': '3004256', 'ext': 'mp4', 'title': 'Schalke: Tönnies möchte Raul zurück', 'description': 'md5:4b5b271d9bcde223b54390754c8ece3f', 'upload_date': '20140226', 'duration': 228.96, }, 'params': { # rtmp download 'skip_download': True, }, 'skip': 'This video is unavailable', }, { 'url': 'http://www.the-voice-of-germany.de/video/31-andreas-kuemmert-rocket-man-clip', 'info_dict': { 'id': '2572814', 'ext': 'mp4', 'title': 'The Voice of Germany - Andreas Kümmert: Rocket Man', 'description': 'md5:6ddb02b0781c6adf778afea606652e38', 'timestamp': 1382041620, 'upload_date': '20131017', 'duration': 469.88, }, 'params': { 'skip_download': True, }, }, { 'url': 'http://www.fem.com/videos/beauty-lifestyle/kurztrips-zum-valentinstag', 'info_dict': { 'id': '2156342', 'ext': 'mp4', 'title': 'Kurztrips zum Valentinstag', 'description': 'Romantischer Kurztrip zum Valentinstag? Nina Heinemann verrät, was sich hier wirklich lohnt.', 'duration': 307.24, }, 'params': { 'skip_download': True, }, }, { 'url': 'http://www.prosieben.de/tv/joko-gegen-klaas/videos/playlists/episode-8-ganze-folge-playlist', 'info_dict': { 'id': '439664', 'title': 'Episode 8 - Ganze Folge - Playlist', 'description': 'md5:63b8963e71f481782aeea877658dec84', }, 'playlist_count': 2, 'skip': 'This video is unavailable', }, { # title in <h2 class="subtitle"> 'url': 'http://www.prosieben.de/stars/oscar-award/videos/jetzt-erst-enthuellt-das-geheimnis-von-emma-stones-oscar-robe-clip', 'info_dict': { 'id': '4895826', 'ext': 'mp4', 'title': 'Jetzt erst enthüllt: Das Geheimnis von Emma Stones Oscar-Robe', 'description': 'md5:e5ace2bc43fadf7b63adc6187e9450b9', 'upload_date': '20170302', }, 'params': { 'skip_download': True, }, 'skip': 'geo restricted to Germany', }, { # geo restricted to Germany 'url': 'http://www.kabeleinsdoku.de/tv/mayday-alarm-im-cockpit/video/102-notlandung-im-hudson-river-ganze-folge', 'only_matching': True, }, { # geo restricted to Germany 'url': 'http://www.sat1gold.de/tv/edel-starck/video/11-staffel-1-episode-1-partner-wider-willen-ganze-folge', 'only_matching': True, }, { # geo restricted to Germany 'url': 'https://www.galileo.tv/video/diese-emojis-werden-oft-missverstanden', 'only_matching': True, }, { 'url': 'http://www.sat1gold.de/tv/edel-starck/playlist/die-gesamte-1-staffel', 'only_matching': True, }, { 'url': 'http://www.advopedia.de/videos/lenssen-klaert-auf/lenssen-klaert-auf-folge-8-staffel-3-feiertage-und-freie-tage', 'only_matching': True, }, ] _TOKEN = 'prosieben' _SALT = '01!8d8F_)r9]4s[qeuXfP%' _CLIENT_NAME = 'kolibri-2.0.19-splec4' _ACCESS_ID = 'x_prosiebenmaxx-de' _ENCRYPTION_KEY = 'Eeyeey9oquahthainoofashoyoikosag' _IV = 'Aeluchoc6aevechuipiexeeboowedaok' _CLIPID_REGEXES = [ r'"clip_id"\s*:\s+"(\d+)"', r'clipid: "(\d+)"', r'clip[iI]d=(\d+)', r'clip[iI][dD]\s*=\s*["\'](\d+)', r"'itemImageUrl'\s*:\s*'/dynamic/thumbnails/full/\d+/(\d+)", r'proMamsId&quot;\s*:\s*&quot;(\d+)', r'proMamsId"\s*:\s*"(\d+)', ] _TITLE_REGEXES = [ r'<h2 class="subtitle" itemprop="name">\s*(.+?)</h2>', r'<header class="clearfix">\s*<h3>(.+?)</h3>', r'<!-- start video -->\s*<h1>(.+?)</h1>', r'<h1 class="att-name">\s*(.+?)</h1>', r'<header class="module_header">\s*<h2>([^<]+)</h2>\s*</header>', r'<h2 class="video-title" itemprop="name">\s*(.+?)</h2>', r'<div[^>]+id="veeseoTitle"[^>]*>(.+?)</div>', r'<h2[^>]+class="subtitle"[^>]*>([^<]+)</h2>', ] _DESCRIPTION_REGEXES = [ r'<p itemprop="description">\s*(.+?)</p>', r'<div class="videoDecription">\s*<p><strong>Beschreibung</strong>: (.+?)</p>', r'<div class="g-plusone" data-size="medium"></div>\s*</div>\s*</header>\s*(.+?)\s*<footer>', r'<p class="att-description">\s*(.+?)\s*</p>', r'<p class="video-description" itemprop="description">\s*(.+?)</p>', r'<div[^>]+id="veeseoDescription"[^>]*>(.+?)</div>', ] _UPLOAD_DATE_REGEXES = [ r'<span>\s*(\d{2}\.\d{2}\.\d{4} \d{2}:\d{2}) \|\s*<span itemprop="duration"', r'<footer>\s*(\d{2}\.\d{2}\.\d{4}) \d{2}:\d{2} Uhr', r'<span style="padding-left: 4px;line-height:20px; color:#404040">(\d{2}\.\d{2}\.\d{4})</span>', r'(\d{2}\.\d{2}\.\d{4}) \| \d{2}:\d{2} Min<br/>', ] _PAGE_TYPE_REGEXES = [ r'<meta name="page_type" content="([^"]+)">', r"'itemType'\s*:\s*'([^']*)'", ] _PLAYLIST_ID_REGEXES = [ r'content[iI]d=(\d+)', r"'itemId'\s*:\s*'([^']*)'", ] _PLAYLIST_CLIP_REGEXES = [ r'(?s)data-qvt=.+?<a href="([^"]+)"', ] def _extract_clip(self, url, webpage): clip_id = self._html_search_regex( self._CLIPID_REGEXES, webpage, 'clip id') title = self._html_search_regex( self._TITLE_REGEXES, webpage, 'title', default=None) or self._og_search_title(webpage) info = self._extract_video_info(url, clip_id) description = self._html_search_regex( self._DESCRIPTION_REGEXES, webpage, 'description', default=None) if description is None: description = self._og_search_description(webpage) thumbnail = self._og_search_thumbnail(webpage) upload_date = unified_strdate( self._html_search_meta('og:published_time', webpage, 'upload date', default=None) or self._html_search_regex(self._UPLOAD_DATE_REGEXES, webpage, 'upload date', default=None)) json_ld = self._search_json_ld(webpage, clip_id, default={}) return merge_dicts(info, { 'id': clip_id, 'title': title, 'description': description, 'thumbnail': thumbnail, 'upload_date': upload_date, }, json_ld) def _extract_playlist(self, url, webpage): playlist_id = self._html_search_regex( self._PLAYLIST_ID_REGEXES, webpage, 'playlist id') playlist = self._parse_json( self._search_regex( r'var\s+contentResources\s*=\s*(\[.+?\]);\s*</script', webpage, 'playlist'), playlist_id) entries = [] for item in playlist: clip_id = item.get('id') or item.get('upc') if not clip_id: continue info = self._extract_video_info(url, clip_id) info.update({ 'id': clip_id, 'title': item.get('title') or item.get('teaser', {}).get('headline'), 'description': item.get('teaser', {}).get('description'), 'thumbnail': item.get('poster'), 'duration': float_or_none(item.get('duration')), 'series': item.get('tvShowTitle'), 'uploader': item.get('broadcastPublisher'), }) entries.append(info) return self.playlist_result(entries, playlist_id) def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) page_type = self._search_regex( self._PAGE_TYPE_REGEXES, webpage, 'page type', default='clip').lower() if page_type == 'clip': return self._extract_clip(url, webpage) elif page_type == 'playlist': return self._extract_playlist(url, webpage) else: raise ExtractorError( 'Unsupported page type %s' % page_type, expected=True)
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/rtvs.py
youtube_dl/extractor/rtvs.py
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor class RTVSIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?rtvs\.sk/(?:radio|televizia)/archiv/\d+/(?P<id>\d+)' _TESTS = [{ # radio archive 'url': 'http://www.rtvs.sk/radio/archiv/11224/414872', 'md5': '134d5d6debdeddf8a5d761cbc9edacb8', 'info_dict': { 'id': '414872', 'ext': 'mp3', 'title': 'Ostrov pokladov 1 časť.mp3' }, 'params': { 'skip_download': True, } }, { # tv archive 'url': 'http://www.rtvs.sk/televizia/archiv/8249/63118', 'md5': '85e2c55cf988403b70cac24f5c086dc6', 'info_dict': { 'id': '63118', 'ext': 'mp4', 'title': 'Amaro Džives - Náš deň', 'description': 'Galavečer pri príležitosti Medzinárodného dňa Rómov.' }, 'params': { 'skip_download': True, } }] def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) playlist_url = self._search_regex( r'playlist["\']?\s*:\s*(["\'])(?P<url>(?:(?!\1).)+)\1', webpage, 'playlist url', group='url') data = self._download_json( playlist_url, video_id, 'Downloading playlist')[0] return self._parse_jwplayer_data(data, video_id=video_id)
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/npo.py
youtube_dl/extractor/npo.py
from __future__ import unicode_literals import re from .common import InfoExtractor from ..compat import ( compat_HTTPError, compat_str, ) from ..utils import ( determine_ext, ExtractorError, fix_xml_ampersands, int_or_none, merge_dicts, orderedSet, parse_duration, qualities, str_or_none, strip_jsonp, unified_strdate, unified_timestamp, url_or_none, urlencode_postdata, ) class NPOBaseIE(InfoExtractor): def _get_token(self, video_id): return self._download_json( 'http://ida.omroep.nl/app.php/auth', video_id, note='Downloading token')['token'] class NPOIE(NPOBaseIE): IE_NAME = 'npo' IE_DESC = 'npo.nl, ntr.nl, omroepwnl.nl, zapp.nl and npo3.nl' _VALID_URL = r'''(?x) (?: npo:| https?:// (?:www\.)? (?: npo\.nl/(?:[^/]+/)*| (?:ntr|npostart)\.nl/(?:[^/]+/){2,}| omroepwnl\.nl/video/fragment/[^/]+__| (?:zapp|npo3)\.nl/(?:[^/]+/){2,} ) ) (?P<id>[^/?#]+) ''' _TESTS = [{ 'url': 'http://www.npo.nl/nieuwsuur/22-06-2014/VPWON_1220719', 'md5': '4b3f9c429157ec4775f2c9cb7b911016', 'info_dict': { 'id': 'VPWON_1220719', 'ext': 'm4v', 'title': 'Nieuwsuur', 'description': 'Dagelijks tussen tien en elf: nieuws, sport en achtergronden.', 'upload_date': '20140622', }, }, { 'url': 'http://www.npo.nl/de-mega-mike-mega-thomas-show/27-02-2009/VARA_101191800', 'md5': 'da50a5787dbfc1603c4ad80f31c5120b', 'info_dict': { 'id': 'VARA_101191800', 'ext': 'm4v', 'title': 'De Mega Mike & Mega Thomas show: The best of.', 'description': 'md5:3b74c97fc9d6901d5a665aac0e5400f4', 'upload_date': '20090227', 'duration': 2400, }, }, { 'url': 'http://www.npo.nl/tegenlicht/25-02-2013/VPWON_1169289', 'md5': 'f8065e4e5a7824068ed3c7e783178f2c', 'info_dict': { 'id': 'VPWON_1169289', 'ext': 'm4v', 'title': 'Tegenlicht: Zwart geld. De toekomst komt uit Afrika', 'description': 'md5:52cf4eefbc96fffcbdc06d024147abea', 'upload_date': '20130225', 'duration': 3000, }, }, { 'url': 'http://www.npo.nl/de-nieuwe-mens-deel-1/21-07-2010/WO_VPRO_043706', 'info_dict': { 'id': 'WO_VPRO_043706', 'ext': 'm4v', 'title': 'De nieuwe mens - Deel 1', 'description': 'md5:518ae51ba1293ffb80d8d8ce90b74e4b', 'duration': 4680, }, 'params': { 'skip_download': True, } }, { # non asf in streams 'url': 'http://www.npo.nl/hoe-gaat-europa-verder-na-parijs/10-01-2015/WO_NOS_762771', 'info_dict': { 'id': 'WO_NOS_762771', 'ext': 'mp4', 'title': 'Hoe gaat Europa verder na Parijs?', }, 'params': { 'skip_download': True, } }, { 'url': 'http://www.ntr.nl/Aap-Poot-Pies/27/detail/Aap-poot-pies/VPWON_1233944#content', 'info_dict': { 'id': 'VPWON_1233944', 'ext': 'm4v', 'title': 'Aap, poot, pies', 'description': 'md5:c9c8005d1869ae65b858e82c01a91fde', 'upload_date': '20150508', 'duration': 599, }, 'params': { 'skip_download': True, } }, { 'url': 'http://www.omroepwnl.nl/video/fragment/vandaag-de-dag-verkiezingen__POMS_WNL_853698', 'info_dict': { 'id': 'POW_00996502', 'ext': 'm4v', 'title': '''"Dit is wel een 'landslide'..."''', 'description': 'md5:f8d66d537dfb641380226e31ca57b8e8', 'upload_date': '20150508', 'duration': 462, }, 'params': { 'skip_download': True, } }, { # audio 'url': 'http://www.npo.nl/jouw-stad-rotterdam/29-01-2017/RBX_FUNX_6683215/RBX_FUNX_7601437', 'info_dict': { 'id': 'RBX_FUNX_6683215', 'ext': 'mp3', 'title': 'Jouw Stad Rotterdam', 'description': 'md5:db251505244f097717ec59fabc372d9f', }, 'params': { 'skip_download': True, } }, { 'url': 'http://www.zapp.nl/de-bzt-show/gemist/KN_1687547', 'only_matching': True, }, { 'url': 'http://www.zapp.nl/de-bzt-show/filmpjes/POMS_KN_7315118', 'only_matching': True, }, { 'url': 'http://www.zapp.nl/beste-vrienden-quiz/extra-video-s/WO_NTR_1067990', 'only_matching': True, }, { 'url': 'https://www.npo3.nl/3onderzoekt/16-09-2015/VPWON_1239870', 'only_matching': True, }, { # live stream 'url': 'npo:LI_NL1_4188102', 'only_matching': True, }, { 'url': 'http://www.npo.nl/radio-gaga/13-06-2017/BNN_101383373', 'only_matching': True, }, { 'url': 'https://www.zapp.nl/1803-skelterlab/instructie-video-s/740-instructievideo-s/POMS_AT_11736927', 'only_matching': True, }, { 'url': 'https://www.npostart.nl/broodje-gezond-ei/28-05-2018/KN_1698996', 'only_matching': True, }, { 'url': 'https://npo.nl/KN_1698996', 'only_matching': True, }] @classmethod def suitable(cls, url): return (False if any(ie.suitable(url) for ie in (NPOLiveIE, NPORadioIE, NPORadioFragmentIE)) else super(NPOIE, cls).suitable(url)) def _real_extract(self, url): video_id = self._match_id(url) return self._get_info(url, video_id) or self._get_old_info(video_id) def _get_info(self, url, video_id): token = self._download_json( 'https://www.npostart.nl/api/token', video_id, 'Downloading token', headers={ 'Referer': url, 'X-Requested-With': 'XMLHttpRequest', })['token'] player = self._download_json( 'https://www.npostart.nl/player/%s' % video_id, video_id, 'Downloading player JSON', data=urlencode_postdata({ 'autoplay': 0, 'share': 1, 'pageUrl': url, 'hasAdConsent': 0, '_token': token, })) player_token = player['token'] drm = False format_urls = set() formats = [] for profile in ('hls', 'dash-widevine', 'dash-playready', 'smooth'): streams = self._download_json( 'https://start-player.npo.nl/video/%s/streams' % video_id, video_id, 'Downloading %s profile JSON' % profile, fatal=False, query={ 'profile': profile, 'quality': 'npo', 'tokenId': player_token, 'streamType': 'broadcast', }) if not streams: continue stream = streams.get('stream') if not isinstance(stream, dict): continue stream_url = url_or_none(stream.get('src')) if not stream_url or stream_url in format_urls: continue format_urls.add(stream_url) if stream.get('protection') is not None or stream.get('keySystemOptions') is not None: drm = True continue stream_type = stream.get('type') stream_ext = determine_ext(stream_url) if stream_type == 'application/dash+xml' or stream_ext == 'mpd': formats.extend(self._extract_mpd_formats( stream_url, video_id, mpd_id='dash', fatal=False)) elif stream_type == 'application/vnd.apple.mpegurl' or stream_ext == 'm3u8': formats.extend(self._extract_m3u8_formats( stream_url, video_id, ext='mp4', entry_protocol='m3u8_native', m3u8_id='hls', fatal=False)) elif re.search(r'\.isml?/Manifest', stream_url): formats.extend(self._extract_ism_formats( stream_url, video_id, ism_id='mss', fatal=False)) else: formats.append({ 'url': stream_url, }) if not formats: if drm: raise ExtractorError('This video is DRM protected.', expected=True) return self._sort_formats(formats) info = { 'id': video_id, 'title': video_id, 'formats': formats, } embed_url = url_or_none(player.get('embedUrl')) if embed_url: webpage = self._download_webpage( embed_url, video_id, 'Downloading embed page', fatal=False) if webpage: video = self._parse_json( self._search_regex( r'\bvideo\s*=\s*({.+?})\s*;', webpage, 'video', default='{}'), video_id) if video: title = video.get('episodeTitle') subtitles = {} subtitles_list = video.get('subtitles') if isinstance(subtitles_list, list): for cc in subtitles_list: cc_url = url_or_none(cc.get('src')) if not cc_url: continue lang = str_or_none(cc.get('language')) or 'nl' subtitles.setdefault(lang, []).append({ 'url': cc_url, }) return merge_dicts({ 'title': title, 'description': video.get('description'), 'thumbnail': url_or_none( video.get('still_image_url') or video.get('orig_image_url')), 'duration': int_or_none(video.get('duration')), 'timestamp': unified_timestamp(video.get('broadcastDate')), 'creator': video.get('channel'), 'series': video.get('title'), 'episode': title, 'episode_number': int_or_none(video.get('episodeNumber')), 'subtitles': subtitles, }, info) return info def _get_old_info(self, video_id): metadata = self._download_json( 'http://e.omroep.nl/metadata/%s' % video_id, video_id, # We have to remove the javascript callback transform_source=strip_jsonp, ) error = metadata.get('error') if error: raise ExtractorError(error, expected=True) # For some videos actual video id (prid) is different (e.g. for # http://www.omroepwnl.nl/video/fragment/vandaag-de-dag-verkiezingen__POMS_WNL_853698 # video id is POMS_WNL_853698 but prid is POW_00996502) video_id = metadata.get('prid') or video_id # titel is too generic in some cases so utilize aflevering_titel as well # when available (e.g. http://tegenlicht.vpro.nl/afleveringen/2014-2015/access-to-africa.html) title = metadata['titel'] sub_title = metadata.get('aflevering_titel') if sub_title and sub_title != title: title += ': %s' % sub_title token = self._get_token(video_id) formats = [] urls = set() def is_legal_url(format_url): return format_url and format_url not in urls and re.match( r'^(?:https?:)?//', format_url) QUALITY_LABELS = ('Laag', 'Normaal', 'Hoog') QUALITY_FORMATS = ('adaptive', 'wmv_sb', 'h264_sb', 'wmv_bb', 'h264_bb', 'wvc1_std', 'h264_std') quality_from_label = qualities(QUALITY_LABELS) quality_from_format_id = qualities(QUALITY_FORMATS) items = self._download_json( 'http://ida.omroep.nl/app.php/%s' % video_id, video_id, 'Downloading formats JSON', query={ 'adaptive': 'yes', 'token': token, })['items'][0] for num, item in enumerate(items): item_url = item.get('url') if not is_legal_url(item_url): continue urls.add(item_url) format_id = self._search_regex( r'video/ida/([^/]+)', item_url, 'format id', default=None) item_label = item.get('label') def add_format_url(format_url): width = int_or_none(self._search_regex( r'(\d+)[xX]\d+', format_url, 'width', default=None)) height = int_or_none(self._search_regex( r'\d+[xX](\d+)', format_url, 'height', default=None)) if item_label in QUALITY_LABELS: quality = quality_from_label(item_label) f_id = item_label elif item_label in QUALITY_FORMATS: quality = quality_from_format_id(format_id) f_id = format_id else: quality, f_id = [None] * 2 formats.append({ 'url': format_url, 'format_id': f_id, 'width': width, 'height': height, 'quality': quality, }) # Example: http://www.npo.nl/de-nieuwe-mens-deel-1/21-07-2010/WO_VPRO_043706 if item.get('contentType') in ('url', 'audio'): add_format_url(item_url) continue try: stream_info = self._download_json( item_url + '&type=json', video_id, 'Downloading %s stream JSON' % item_label or item.get('format') or format_id or num) except ExtractorError as ee: if isinstance(ee.cause, compat_HTTPError) and ee.cause.code == 404: error = (self._parse_json( ee.cause.read().decode(), video_id, fatal=False) or {}).get('errorstring') if error: raise ExtractorError(error, expected=True) raise # Stream URL instead of JSON, example: npo:LI_NL1_4188102 if isinstance(stream_info, compat_str): if not stream_info.startswith('http'): continue video_url = stream_info # JSON else: video_url = stream_info.get('url') if not video_url or 'vodnotavailable.' in video_url or video_url in urls: continue urls.add(video_url) if determine_ext(video_url) == 'm3u8': formats.extend(self._extract_m3u8_formats( video_url, video_id, ext='mp4', entry_protocol='m3u8_native', m3u8_id='hls', fatal=False)) else: add_format_url(video_url) is_live = metadata.get('medium') == 'live' if not is_live: for num, stream in enumerate(metadata.get('streams', [])): stream_url = stream.get('url') if not is_legal_url(stream_url): continue urls.add(stream_url) # smooth streaming is not supported stream_type = stream.get('type', '').lower() if stream_type in ['ss', 'ms']: continue if stream_type == 'hds': f4m_formats = self._extract_f4m_formats( stream_url, video_id, fatal=False) # f4m downloader downloads only piece of live stream for f4m_format in f4m_formats: f4m_format['preference'] = -1 formats.extend(f4m_formats) elif stream_type == 'hls': formats.extend(self._extract_m3u8_formats( stream_url, video_id, ext='mp4', fatal=False)) # Example: http://www.npo.nl/de-nieuwe-mens-deel-1/21-07-2010/WO_VPRO_043706 elif '.asf' in stream_url: asx = self._download_xml( stream_url, video_id, 'Downloading stream %d ASX playlist' % num, transform_source=fix_xml_ampersands, fatal=False) if not asx: continue ref = asx.find('./ENTRY/Ref') if ref is None: continue video_url = ref.get('href') if not video_url or video_url in urls: continue urls.add(video_url) formats.append({ 'url': video_url, 'ext': stream.get('formaat', 'asf'), 'quality': stream.get('kwaliteit'), 'preference': -10, }) else: formats.append({ 'url': stream_url, 'quality': stream.get('kwaliteit'), }) self._sort_formats(formats) subtitles = {} if metadata.get('tt888') == 'ja': subtitles['nl'] = [{ 'ext': 'vtt', 'url': 'http://tt888.omroep.nl/tt888/%s' % video_id, }] return { 'id': video_id, 'title': self._live_title(title) if is_live else title, 'description': metadata.get('info'), 'thumbnail': metadata.get('images', [{'url': None}])[-1]['url'], 'upload_date': unified_strdate(metadata.get('gidsdatum')), 'duration': parse_duration(metadata.get('tijdsduur')), 'formats': formats, 'subtitles': subtitles, 'is_live': is_live, } class NPOLiveIE(NPOBaseIE): IE_NAME = 'npo.nl:live' _VALID_URL = r'https?://(?:www\.)?npo(?:start)?\.nl/live(?:/(?P<id>[^/?#&]+))?' _TESTS = [{ 'url': 'http://www.npo.nl/live/npo-1', 'info_dict': { 'id': 'LI_NL1_4188102', 'display_id': 'npo-1', 'ext': 'mp4', 'title': 're:^NPO 1 [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$', 'is_live': True, }, 'params': { 'skip_download': True, } }, { 'url': 'http://www.npo.nl/live', 'only_matching': True, }, { 'url': 'https://www.npostart.nl/live/npo-1', 'only_matching': True, }] def _real_extract(self, url): display_id = self._match_id(url) or 'npo-1' webpage = self._download_webpage(url, display_id) live_id = self._search_regex( [r'media-id="([^"]+)"', r'data-prid="([^"]+)"'], webpage, 'live id') return { '_type': 'url_transparent', 'url': 'npo:%s' % live_id, 'ie_key': NPOIE.ie_key(), 'id': live_id, 'display_id': display_id, } class NPORadioIE(InfoExtractor): IE_NAME = 'npo.nl:radio' _VALID_URL = r'https?://(?:www\.)?npo\.nl/radio/(?P<id>[^/]+)' _TEST = { 'url': 'http://www.npo.nl/radio/radio-1', 'info_dict': { 'id': 'radio-1', 'ext': 'mp3', 'title': 're:^NPO Radio 1 [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$', 'is_live': True, }, 'params': { 'skip_download': True, } } @classmethod def suitable(cls, url): return False if NPORadioFragmentIE.suitable(url) else super(NPORadioIE, cls).suitable(url) @staticmethod def _html_get_attribute_regex(attribute): return r'{0}\s*=\s*\'([^\']+)\''.format(attribute) def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) title = self._html_search_regex( self._html_get_attribute_regex('data-channel'), webpage, 'title') stream = self._parse_json( self._html_search_regex(self._html_get_attribute_regex('data-streams'), webpage, 'data-streams'), video_id) codec = stream.get('codec') return { 'id': video_id, 'url': stream['url'], 'title': self._live_title(title), 'acodec': codec, 'ext': codec, 'is_live': True, } class NPORadioFragmentIE(InfoExtractor): IE_NAME = 'npo.nl:radio:fragment' _VALID_URL = r'https?://(?:www\.)?npo\.nl/radio/[^/]+/fragment/(?P<id>\d+)' _TEST = { 'url': 'http://www.npo.nl/radio/radio-5/fragment/174356', 'md5': 'dd8cc470dad764d0fdc70a9a1e2d18c2', 'info_dict': { 'id': '174356', 'ext': 'mp3', 'title': 'Jubileumconcert Willeke Alberti', }, } def _real_extract(self, url): audio_id = self._match_id(url) webpage = self._download_webpage(url, audio_id) title = self._html_search_regex( r'href="/radio/[^/]+/fragment/%s" title="([^"]+)"' % audio_id, webpage, 'title') audio_url = self._search_regex( r"data-streams='([^']+)'", webpage, 'audio url') return { 'id': audio_id, 'url': audio_url, 'title': title, } class NPODataMidEmbedIE(InfoExtractor): def _real_extract(self, url): display_id = self._match_id(url) webpage = self._download_webpage(url, display_id) video_id = self._search_regex( r'data-mid=(["\'])(?P<id>(?:(?!\1).)+)\1', webpage, 'video_id', group='id') return { '_type': 'url_transparent', 'ie_key': 'NPO', 'url': 'npo:%s' % video_id, 'display_id': display_id } class SchoolTVIE(NPODataMidEmbedIE): IE_NAME = 'schooltv' _VALID_URL = r'https?://(?:www\.)?schooltv\.nl/video/(?P<id>[^/?#&]+)' _TEST = { 'url': 'http://www.schooltv.nl/video/ademhaling-de-hele-dag-haal-je-adem-maar-wat-gebeurt-er-dan-eigenlijk-in-je-lichaam/', 'info_dict': { 'id': 'WO_NTR_429477', 'display_id': 'ademhaling-de-hele-dag-haal-je-adem-maar-wat-gebeurt-er-dan-eigenlijk-in-je-lichaam', 'title': 'Ademhaling: De hele dag haal je adem. Maar wat gebeurt er dan eigenlijk in je lichaam?', 'ext': 'mp4', 'description': 'md5:abfa0ff690adb73fd0297fd033aaa631' }, 'params': { # Skip because of m3u8 download 'skip_download': True } } class HetKlokhuisIE(NPODataMidEmbedIE): IE_NAME = 'hetklokhuis' _VALID_URL = r'https?://(?:www\.)?hetklokhuis\.nl/[^/]+/\d+/(?P<id>[^/?#&]+)' _TEST = { 'url': 'http://hetklokhuis.nl/tv-uitzending/3471/Zwaartekrachtsgolven', 'info_dict': { 'id': 'VPWON_1260528', 'display_id': 'Zwaartekrachtsgolven', 'ext': 'm4v', 'title': 'Het Klokhuis: Zwaartekrachtsgolven', 'description': 'md5:c94f31fb930d76c2efa4a4a71651dd48', 'upload_date': '20170223', }, 'params': { 'skip_download': True } } class NPOPlaylistBaseIE(NPOIE): def _real_extract(self, url): playlist_id = self._match_id(url) webpage = self._download_webpage(url, playlist_id) entries = [ self.url_result('npo:%s' % video_id if not video_id.startswith('http') else video_id) for video_id in orderedSet(re.findall(self._PLAYLIST_ENTRY_RE, webpage)) ] playlist_title = self._html_search_regex( self._PLAYLIST_TITLE_RE, webpage, 'playlist title', default=None) or self._og_search_title(webpage) return self.playlist_result(entries, playlist_id, playlist_title) class VPROIE(NPOPlaylistBaseIE): IE_NAME = 'vpro' _VALID_URL = r'https?://(?:www\.)?(?:(?:tegenlicht\.)?vpro|2doc)\.nl/(?:[^/]+/)*(?P<id>[^/]+)\.html' _PLAYLIST_TITLE_RE = (r'<h1[^>]+class=["\'].*?\bmedia-platform-title\b.*?["\'][^>]*>([^<]+)', r'<h5[^>]+class=["\'].*?\bmedia-platform-subtitle\b.*?["\'][^>]*>([^<]+)') _PLAYLIST_ENTRY_RE = r'data-media-id="([^"]+)"' _TESTS = [ { 'url': 'http://tegenlicht.vpro.nl/afleveringen/2012-2013/de-toekomst-komt-uit-afrika.html', 'md5': 'f8065e4e5a7824068ed3c7e783178f2c', 'info_dict': { 'id': 'VPWON_1169289', 'ext': 'm4v', 'title': 'De toekomst komt uit Afrika', 'description': 'md5:52cf4eefbc96fffcbdc06d024147abea', 'upload_date': '20130225', }, 'skip': 'Video gone', }, { 'url': 'http://www.vpro.nl/programmas/2doc/2015/sergio-herman.html', 'info_dict': { 'id': 'sergio-herman', 'title': 'sergio herman: fucking perfect', }, 'playlist_count': 2, }, { # playlist with youtube embed 'url': 'http://www.vpro.nl/programmas/2doc/2015/education-education.html', 'info_dict': { 'id': 'education-education', 'title': 'education education', }, 'playlist_count': 2, }, { 'url': 'http://www.2doc.nl/documentaires/series/2doc/2015/oktober/de-tegenprestatie.html', 'info_dict': { 'id': 'de-tegenprestatie', 'title': 'De Tegenprestatie', }, 'playlist_count': 2, }, { 'url': 'http://www.2doc.nl/speel~VARA_101375237~mh17-het-verdriet-van-nederland~.html', 'info_dict': { 'id': 'VARA_101375237', 'ext': 'm4v', 'title': 'MH17: Het verdriet van Nederland', 'description': 'md5:09e1a37c1fdb144621e22479691a9f18', 'upload_date': '20150716', }, 'params': { # Skip because of m3u8 download 'skip_download': True }, } ] class WNLIE(NPOPlaylistBaseIE): IE_NAME = 'wnl' _VALID_URL = r'https?://(?:www\.)?omroepwnl\.nl/video/detail/(?P<id>[^/]+)__\d+' _PLAYLIST_TITLE_RE = r'(?s)<h1[^>]+class="subject"[^>]*>(.+?)</h1>' _PLAYLIST_ENTRY_RE = r'<a[^>]+href="([^"]+)"[^>]+class="js-mid"[^>]*>Deel \d+' _TESTS = [{ 'url': 'http://www.omroepwnl.nl/video/detail/vandaag-de-dag-6-mei__060515', 'info_dict': { 'id': 'vandaag-de-dag-6-mei', 'title': 'Vandaag de Dag 6 mei', }, 'playlist_count': 4, }] class AndereTijdenIE(NPOPlaylistBaseIE): IE_NAME = 'anderetijden' _VALID_URL = r'https?://(?:www\.)?anderetijden\.nl/programma/(?:[^/]+/)+(?P<id>[^/?#&]+)' _PLAYLIST_TITLE_RE = r'(?s)<h1[^>]+class=["\'].*?\bpage-title\b.*?["\'][^>]*>(.+?)</h1>' _PLAYLIST_ENTRY_RE = r'<figure[^>]+class=["\']episode-container episode-page["\'][^>]+data-prid=["\'](.+?)["\']' _TESTS = [{ 'url': 'http://anderetijden.nl/programma/1/Andere-Tijden/aflevering/676/Duitse-soldaten-over-de-Slag-bij-Arnhem', 'info_dict': { 'id': 'Duitse-soldaten-over-de-Slag-bij-Arnhem', 'title': 'Duitse soldaten over de Slag bij Arnhem', }, 'playlist_count': 3, }]
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/wwe.py
youtube_dl/extractor/wwe.py
from __future__ import unicode_literals import re from .common import InfoExtractor from ..compat import compat_str from ..utils import ( try_get, unescapeHTML, url_or_none, urljoin, ) class WWEBaseIE(InfoExtractor): _SUBTITLE_LANGS = { 'English': 'en', 'Deutsch': 'de', } def _extract_entry(self, data, url, video_id=None): video_id = compat_str(video_id or data['nid']) title = data['title'] formats = self._extract_m3u8_formats( data['file'], video_id, 'mp4', entry_protocol='m3u8_native', m3u8_id='hls') description = data.get('description') thumbnail = urljoin(url, data.get('image')) series = data.get('show_name') episode = data.get('episode_name') subtitles = {} tracks = data.get('tracks') if isinstance(tracks, list): for track in tracks: if not isinstance(track, dict): continue if track.get('kind') != 'captions': continue track_file = url_or_none(track.get('file')) if not track_file: continue label = track.get('label') lang = self._SUBTITLE_LANGS.get(label, label) or 'en' subtitles.setdefault(lang, []).append({ 'url': track_file, }) return { 'id': video_id, 'title': title, 'description': description, 'thumbnail': thumbnail, 'series': series, 'episode': episode, 'formats': formats, 'subtitles': subtitles, } class WWEIE(WWEBaseIE): _VALID_URL = r'https?://(?:[^/]+\.)?wwe\.com/(?:[^/]+/)*videos/(?P<id>[^/?#&]+)' _TESTS = [{ 'url': 'https://www.wwe.com/videos/daniel-bryan-vs-andrade-cien-almas-smackdown-live-sept-4-2018', 'md5': '92811c6a14bfc206f7a6a9c5d9140184', 'info_dict': { 'id': '40048199', 'ext': 'mp4', 'title': 'Daniel Bryan vs. Andrade "Cien" Almas: SmackDown LIVE, Sept. 4, 2018', 'description': 'md5:2d7424dbc6755c61a0e649d2a8677f67', 'thumbnail': r're:^https?://.*\.jpg$', } }, { 'url': 'https://de.wwe.com/videos/gran-metalik-vs-tony-nese-wwe-205-live-sept-4-2018', 'only_matching': True, }] def _real_extract(self, url): display_id = self._match_id(url) webpage = self._download_webpage(url, display_id) landing = self._parse_json( self._html_search_regex( r'(?s)Drupal\.settings\s*,\s*({.+?})\s*\)\s*;', webpage, 'drupal settings'), display_id)['WWEVideoLanding'] data = landing['initialVideo']['playlist'][0] video_id = landing.get('initialVideoId') info = self._extract_entry(data, url, video_id) info['display_id'] = display_id return info class WWEPlaylistIE(WWEBaseIE): _VALID_URL = r'https?://(?:[^/]+\.)?wwe\.com/(?:[^/]+/)*(?P<id>[^/?#&]+)' _TESTS = [{ 'url': 'https://www.wwe.com/shows/raw/2018-11-12', 'info_dict': { 'id': '2018-11-12', }, 'playlist_mincount': 11, }, { 'url': 'http://www.wwe.com/article/walk-the-prank-wwe-edition', 'only_matching': True, }, { 'url': 'https://www.wwe.com/shows/wwenxt/article/matt-riddle-interview', 'only_matching': True, }] @classmethod def suitable(cls, url): return False if WWEIE.suitable(url) else super(WWEPlaylistIE, cls).suitable(url) def _real_extract(self, url): display_id = self._match_id(url) webpage = self._download_webpage(url, display_id) entries = [] for mobj in re.finditer( r'data-video\s*=\s*(["\'])(?P<data>{.+?})\1', webpage): video = self._parse_json( mobj.group('data'), display_id, transform_source=unescapeHTML, fatal=False) if not video: continue data = try_get(video, lambda x: x['playlist'][0], dict) if not data: continue try: entry = self._extract_entry(data, url) except Exception: continue entry['extractor_key'] = WWEIE.ie_key() entries.append(entry) return self.playlist_result(entries, display_id)
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/egghead.py
youtube_dl/extractor/egghead.py
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..compat import compat_str from ..utils import ( determine_ext, int_or_none, try_get, unified_timestamp, url_or_none, ) class EggheadBaseIE(InfoExtractor): def _call_api(self, path, video_id, resource, fatal=True): return self._download_json( 'https://app.egghead.io/api/v1/' + path, video_id, 'Downloading %s JSON' % resource, fatal=fatal) class EggheadCourseIE(EggheadBaseIE): IE_DESC = 'egghead.io course' IE_NAME = 'egghead:course' _VALID_URL = r'https://(?:app\.)?egghead\.io/(?:course|playlist)s/(?P<id>[^/?#&]+)' _TESTS = [{ 'url': 'https://egghead.io/courses/professor-frisby-introduces-composable-functional-javascript', 'playlist_count': 29, 'info_dict': { 'id': '432655', 'title': 'Professor Frisby Introduces Composable Functional JavaScript', 'description': 're:(?s)^This course teaches the ubiquitous.*You\'ll start composing functionality before you know it.$', }, }, { 'url': 'https://app.egghead.io/playlists/professor-frisby-introduces-composable-functional-javascript', 'only_matching': True, }] def _real_extract(self, url): playlist_id = self._match_id(url) series_path = 'series/' + playlist_id lessons = self._call_api( series_path + '/lessons', playlist_id, 'course lessons') entries = [] for lesson in lessons: lesson_url = url_or_none(lesson.get('http_url')) if not lesson_url: continue lesson_id = lesson.get('id') if lesson_id: lesson_id = compat_str(lesson_id) entries.append(self.url_result( lesson_url, ie=EggheadLessonIE.ie_key(), video_id=lesson_id)) course = self._call_api( series_path, playlist_id, 'course', False) or {} playlist_id = course.get('id') if playlist_id: playlist_id = compat_str(playlist_id) return self.playlist_result( entries, playlist_id, course.get('title'), course.get('description')) class EggheadLessonIE(EggheadBaseIE): IE_DESC = 'egghead.io lesson' IE_NAME = 'egghead:lesson' _VALID_URL = r'https://(?:app\.)?egghead\.io/(?:api/v1/)?lessons/(?P<id>[^/?#&]+)' _TESTS = [{ 'url': 'https://egghead.io/lessons/javascript-linear-data-flow-with-container-style-types-box', 'info_dict': { 'id': '1196', 'display_id': 'javascript-linear-data-flow-with-container-style-types-box', 'ext': 'mp4', 'title': 'Create linear data flow with container style types (Box)', 'description': 'md5:9aa2cdb6f9878ed4c39ec09e85a8150e', 'thumbnail': r're:^https?:.*\.jpg$', 'timestamp': 1481296768, 'upload_date': '20161209', 'duration': 304, 'view_count': 0, 'tags': 'count:2', }, 'params': { 'skip_download': True, 'format': 'bestvideo', }, }, { 'url': 'https://egghead.io/api/v1/lessons/react-add-redux-to-a-react-application', 'only_matching': True, }, { 'url': 'https://app.egghead.io/lessons/javascript-linear-data-flow-with-container-style-types-box', 'only_matching': True, }] def _real_extract(self, url): display_id = self._match_id(url) lesson = self._call_api( 'lessons/' + display_id, display_id, 'lesson') lesson_id = compat_str(lesson['id']) title = lesson['title'] formats = [] for _, format_url in lesson['media_urls'].items(): format_url = url_or_none(format_url) if not format_url: continue ext = determine_ext(format_url) if ext == 'm3u8': formats.extend(self._extract_m3u8_formats( format_url, lesson_id, 'mp4', entry_protocol='m3u8', m3u8_id='hls', fatal=False)) elif ext == 'mpd': formats.extend(self._extract_mpd_formats( format_url, lesson_id, mpd_id='dash', fatal=False)) else: formats.append({ 'url': format_url, }) self._sort_formats(formats) return { 'id': lesson_id, 'display_id': display_id, 'title': title, 'description': lesson.get('summary'), 'thumbnail': lesson.get('thumb_nail'), 'timestamp': unified_timestamp(lesson.get('published_at')), 'duration': int_or_none(lesson.get('duration')), 'view_count': int_or_none(lesson.get('plays_count')), 'tags': try_get(lesson, lambda x: x['tag_list'], list), 'series': try_get( lesson, lambda x: x['series']['title'], compat_str), 'formats': formats, }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/contv.py
youtube_dl/extractor/contv.py
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..utils import ( float_or_none, int_or_none, ) class CONtvIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?contv\.com/details-movie/(?P<id>[^/]+)' _TESTS = [{ 'url': 'https://www.contv.com/details-movie/CEG10022949/days-of-thrills-&-laughter', 'info_dict': { 'id': 'CEG10022949', 'ext': 'mp4', 'title': 'Days Of Thrills & Laughter', 'description': 'md5:5d6b3d0b1829bb93eb72898c734802eb', 'upload_date': '20180703', 'timestamp': 1530634789.61, }, 'params': { # m3u8 download 'skip_download': True, }, }, { 'url': 'https://www.contv.com/details-movie/CLIP-show_fotld_bts/fight-of-the-living-dead:-behind-the-scenes-bites', 'info_dict': { 'id': 'CLIP-show_fotld_bts', 'title': 'Fight of the Living Dead: Behind the Scenes Bites', }, 'playlist_mincount': 7, }] def _real_extract(self, url): video_id = self._match_id(url) details = self._download_json( 'http://metax.contv.live.junctiontv.net/metax/2.5/details/' + video_id, video_id, query={'device': 'web'}) if details.get('type') == 'episodic': seasons = self._download_json( 'http://metax.contv.live.junctiontv.net/metax/2.5/seriesfeed/json/' + video_id, video_id) entries = [] for season in seasons: for episode in season.get('episodes', []): episode_id = episode.get('id') if not episode_id: continue entries.append(self.url_result( 'https://www.contv.com/details-movie/' + episode_id, CONtvIE.ie_key(), episode_id)) return self.playlist_result(entries, video_id, details.get('title')) m_details = details['details'] title = details['title'] formats = [] media_hls_url = m_details.get('media_hls_url') if media_hls_url: formats.extend(self._extract_m3u8_formats( media_hls_url, video_id, 'mp4', m3u8_id='hls', fatal=False)) media_mp4_url = m_details.get('media_mp4_url') if media_mp4_url: formats.append({ 'format_id': 'http', 'url': media_mp4_url, }) self._sort_formats(formats) subtitles = {} captions = m_details.get('captions') or {} for caption_url in captions.values(): subtitles.setdefault('en', []).append({ 'url': caption_url }) thumbnails = [] for image in m_details.get('images', []): image_url = image.get('url') if not image_url: continue thumbnails.append({ 'url': image_url, 'width': int_or_none(image.get('width')), 'height': int_or_none(image.get('height')), }) description = None for p in ('large_', 'medium_', 'small_', ''): d = m_details.get(p + 'description') if d: description = d break return { 'id': video_id, 'title': title, 'formats': formats, 'thumbnails': thumbnails, 'description': description, 'timestamp': float_or_none(details.get('metax_added_on'), 1000), 'subtitles': subtitles, 'duration': float_or_none(m_details.get('duration'), 1000), 'view_count': int_or_none(details.get('num_watched')), 'like_count': int_or_none(details.get('num_fav')), 'categories': details.get('category'), 'tags': details.get('tags'), 'season_number': int_or_none(details.get('season')), 'episode_number': int_or_none(details.get('episode')), 'release_year': int_or_none(details.get('pub_year')), }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/xiami.py
youtube_dl/extractor/xiami.py
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..compat import compat_urllib_parse_unquote from ..utils import int_or_none class XiamiBaseIE(InfoExtractor): _API_BASE_URL = 'https://emumo.xiami.com/song/playlist/cat/json/id' def _download_webpage_handle(self, *args, **kwargs): webpage = super(XiamiBaseIE, self)._download_webpage_handle(*args, **kwargs) if '>Xiami is currently not available in your country.<' in webpage: self.raise_geo_restricted('Xiami is currently not available in your country') return webpage def _extract_track(self, track, track_id=None): track_name = track.get('songName') or track.get('name') or track['subName'] artist = track.get('artist') or track.get('artist_name') or track.get('singers') title = '%s - %s' % (artist, track_name) if artist else track_name track_url = self._decrypt(track['location']) subtitles = {} lyrics_url = track.get('lyric_url') or track.get('lyric') if lyrics_url and lyrics_url.startswith('http'): subtitles['origin'] = [{'url': lyrics_url}] return { 'id': track.get('song_id') or track_id, 'url': track_url, 'title': title, 'thumbnail': track.get('pic') or track.get('album_pic'), 'duration': int_or_none(track.get('length')), 'creator': track.get('artist', '').split(';')[0], 'track': track_name, 'track_number': int_or_none(track.get('track')), 'album': track.get('album_name') or track.get('title'), 'artist': artist, 'subtitles': subtitles, } def _extract_tracks(self, item_id, referer, typ=None): playlist = self._download_json( '%s/%s%s' % (self._API_BASE_URL, item_id, '/type/%s' % typ if typ else ''), item_id, headers={ 'Referer': referer, }) return [ self._extract_track(track, item_id) for track in playlist['data']['trackList']] @staticmethod def _decrypt(origin): n = int(origin[0]) origin = origin[1:] short_length = len(origin) // n long_num = len(origin) - short_length * n l = tuple() for i in range(0, n): length = short_length if i < long_num: length += 1 l += (origin[0:length], ) origin = origin[length:] ans = '' for i in range(0, short_length + 1): for j in range(0, n): if len(l[j]) > i: ans += l[j][i] return compat_urllib_parse_unquote(ans).replace('^', '0') class XiamiSongIE(XiamiBaseIE): IE_NAME = 'xiami:song' IE_DESC = '虾米音乐' _VALID_URL = r'https?://(?:www\.)?xiami\.com/song/(?P<id>[^/?#&]+)' _TESTS = [{ 'url': 'http://www.xiami.com/song/1775610518', 'md5': '521dd6bea40fd5c9c69f913c232cb57e', 'info_dict': { 'id': '1775610518', 'ext': 'mp3', 'title': 'HONNE - Woman', 'thumbnail': r're:http://img\.xiami\.net/images/album/.*\.jpg', 'duration': 265, 'creator': 'HONNE', 'track': 'Woman', 'album': 'Woman', 'artist': 'HONNE', 'subtitles': { 'origin': [{ 'ext': 'lrc', }], }, }, 'skip': 'Georestricted', }, { 'url': 'http://www.xiami.com/song/1775256504', 'md5': '932a3abd45c6aa2b1fdbe028fcb4c4fc', 'info_dict': { 'id': '1775256504', 'ext': 'mp3', 'title': '戴荃 - 悟空', 'thumbnail': r're:http://img\.xiami\.net/images/album/.*\.jpg', 'duration': 200, 'creator': '戴荃', 'track': '悟空', 'album': '悟空', 'artist': '戴荃', 'subtitles': { 'origin': [{ 'ext': 'lrc', }], }, }, 'skip': 'Georestricted', }, { 'url': 'http://www.xiami.com/song/1775953850', 'info_dict': { 'id': '1775953850', 'ext': 'mp3', 'title': 'До Скону - Чума Пожирает Землю', 'thumbnail': r're:http://img\.xiami\.net/images/album/.*\.jpg', 'duration': 683, 'creator': 'До Скону', 'track': 'Чума Пожирает Землю', 'track_number': 7, 'album': 'Ад', 'artist': 'До Скону', }, 'params': { 'skip_download': True, }, }, { 'url': 'http://www.xiami.com/song/xLHGwgd07a1', 'only_matching': True, }] def _real_extract(self, url): return self._extract_tracks(self._match_id(url), url)[0] class XiamiPlaylistBaseIE(XiamiBaseIE): def _real_extract(self, url): item_id = self._match_id(url) return self.playlist_result(self._extract_tracks(item_id, url, self._TYPE), item_id) class XiamiAlbumIE(XiamiPlaylistBaseIE): IE_NAME = 'xiami:album' IE_DESC = '虾米音乐 - 专辑' _VALID_URL = r'https?://(?:www\.)?xiami\.com/album/(?P<id>[^/?#&]+)' _TYPE = '1' _TESTS = [{ 'url': 'http://www.xiami.com/album/2100300444', 'info_dict': { 'id': '2100300444', }, 'playlist_count': 10, 'skip': 'Georestricted', }, { 'url': 'http://www.xiami.com/album/512288?spm=a1z1s.6843761.1110925389.6.hhE9p9', 'only_matching': True, }, { 'url': 'http://www.xiami.com/album/URVDji2a506', 'only_matching': True, }] class XiamiArtistIE(XiamiPlaylistBaseIE): IE_NAME = 'xiami:artist' IE_DESC = '虾米音乐 - 歌手' _VALID_URL = r'https?://(?:www\.)?xiami\.com/artist/(?P<id>[^/?#&]+)' _TYPE = '2' _TESTS = [{ 'url': 'http://www.xiami.com/artist/2132?spm=0.0.0.0.dKaScp', 'info_dict': { 'id': '2132', }, 'playlist_count': 20, 'skip': 'Georestricted', }, { 'url': 'http://www.xiami.com/artist/bC5Tk2K6eb99', 'only_matching': True, }] class XiamiCollectionIE(XiamiPlaylistBaseIE): IE_NAME = 'xiami:collection' IE_DESC = '虾米音乐 - 精选集' _VALID_URL = r'https?://(?:www\.)?xiami\.com/collect/(?P<id>[^/?#&]+)' _TYPE = '3' _TEST = { 'url': 'http://www.xiami.com/collect/156527391?spm=a1z1s.2943601.6856193.12.4jpBnr', 'info_dict': { 'id': '156527391', }, 'playlist_mincount': 29, 'skip': 'Georestricted', }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/sonyliv.py
youtube_dl/extractor/sonyliv.py
# coding: utf-8 from __future__ import unicode_literals import time import uuid from .common import InfoExtractor from ..compat import compat_HTTPError from ..utils import ( ExtractorError, int_or_none, ) class SonyLIVIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?sonyliv\.com/(?:s(?:how|port)s/[^/]+|movies|clip|trailer|music-videos)/[^/?#&]+-(?P<id>\d+)' _TESTS = [{ 'url': 'https://www.sonyliv.com/shows/bachelors-delight-1700000113/achaari-cheese-toast-1000022678?watch=true', 'info_dict': { 'title': 'Bachelors Delight - Achaari Cheese Toast', 'id': '1000022678', 'ext': 'mp4', 'upload_date': '20200411', 'description': 'md5:3957fa31d9309bf336ceb3f37ad5b7cb', 'timestamp': 1586632091, 'duration': 185, 'season_number': 1, 'episode': 'Achaari Cheese Toast', 'episode_number': 1, 'release_year': 2016, }, 'params': { 'skip_download': True, }, }, { 'url': 'https://www.sonyliv.com/movies/tahalka-1000050121?watch=true', 'only_matching': True, }, { 'url': 'https://www.sonyliv.com/clip/jigarbaaz-1000098925', 'only_matching': True, }, { 'url': 'https://www.sonyliv.com/trailer/sandwiched-forever-1000100286?watch=true', 'only_matching': True, }, { 'url': 'https://www.sonyliv.com/sports/india-tour-of-australia-2020-21-1700000286/cricket-hls-day-3-1st-test-aus-vs-ind-19-dec-2020-1000100959?watch=true', 'only_matching': True, }, { 'url': 'https://www.sonyliv.com/music-videos/yeh-un-dinon-ki-baat-hai-1000018779', 'only_matching': True, }] _GEO_COUNTRIES = ['IN'] _TOKEN = None def _call_api(self, version, path, video_id): headers = {} if self._TOKEN: headers['security_token'] = self._TOKEN try: return self._download_json( 'https://apiv2.sonyliv.com/AGL/%s/A/ENG/WEB/%s' % (version, path), video_id, headers=headers)['resultObj'] except ExtractorError as e: if isinstance(e.cause, compat_HTTPError) and e.cause.code == 403: message = self._parse_json( e.cause.read().decode(), video_id)['message'] if message == 'Geoblocked Country': self.raise_geo_restricted(countries=self._GEO_COUNTRIES) raise ExtractorError(message) raise def _real_initialize(self): self._TOKEN = self._call_api('1.4', 'ALL/GETTOKEN', None) def _real_extract(self, url): video_id = self._match_id(url) content = self._call_api( '1.5', 'IN/CONTENT/VIDEOURL/VOD/' + video_id, video_id) if content.get('isEncrypted'): raise ExtractorError('This video is DRM protected.', expected=True) dash_url = content['videoURL'] headers = { 'x-playback-session-id': '%s-%d' % (uuid.uuid4().hex, time.time() * 1000) } formats = self._extract_mpd_formats( dash_url, video_id, mpd_id='dash', headers=headers, fatal=False) formats.extend(self._extract_m3u8_formats( dash_url.replace('.mpd', '.m3u8').replace('/DASH/', '/HLS/'), video_id, 'mp4', m3u8_id='hls', headers=headers, fatal=False)) for f in formats: f.setdefault('http_headers', {}).update(headers) self._sort_formats(formats) metadata = self._call_api( '1.6', 'IN/DETAIL/' + video_id, video_id)['containers'][0]['metadata'] title = metadata['title'] episode = metadata.get('episodeTitle') if episode and title != episode: title += ' - ' + episode return { 'id': video_id, 'title': title, 'formats': formats, 'thumbnail': content.get('posterURL'), 'description': metadata.get('longDescription') or metadata.get('shortDescription'), 'timestamp': int_or_none(metadata.get('creationDate'), 1000), 'duration': int_or_none(metadata.get('duration')), 'season_number': int_or_none(metadata.get('season')), 'episode': episode, 'episode_number': int_or_none(metadata.get('episodeNumber')), 'release_year': int_or_none(metadata.get('year')), }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/raywenderlich.py
youtube_dl/extractor/raywenderlich.py
from __future__ import unicode_literals import re from .common import InfoExtractor from .vimeo import VimeoIE from ..compat import compat_str from ..utils import ( ExtractorError, int_or_none, merge_dicts, try_get, unescapeHTML, unified_timestamp, urljoin, ) class RayWenderlichIE(InfoExtractor): _VALID_URL = r'''(?x) https?:// (?: videos\.raywenderlich\.com/courses| (?:www\.)?raywenderlich\.com )/ (?P<course_id>[^/]+)/lessons/(?P<id>\d+) ''' _TESTS = [{ 'url': 'https://www.raywenderlich.com/3530-testing-in-ios/lessons/1', 'info_dict': { 'id': '248377018', 'ext': 'mp4', 'title': 'Introduction', 'description': 'md5:804d031b3efa9fcb49777d512d74f722', 'timestamp': 1513906277, 'upload_date': '20171222', 'duration': 133, 'uploader': 'Ray Wenderlich', 'uploader_id': 'user3304672', }, 'params': { 'noplaylist': True, 'skip_download': True, }, 'add_ie': [VimeoIE.ie_key()], 'expected_warnings': ['HTTP Error 403: Forbidden'], }, { 'url': 'https://videos.raywenderlich.com/courses/105-testing-in-ios/lessons/1', 'only_matching': True, }] @staticmethod def _extract_video_id(data, lesson_id): if not data: return groups = try_get(data, lambda x: x['groups'], list) or [] if not groups: return for group in groups: if not isinstance(group, dict): continue contents = try_get(data, lambda x: x['contents'], list) or [] for content in contents: if not isinstance(content, dict): continue ordinal = int_or_none(content.get('ordinal')) if ordinal != lesson_id: continue video_id = content.get('identifier') if video_id: return compat_str(video_id) def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) course_id, lesson_id = mobj.group('course_id', 'id') display_id = '%s/%s' % (course_id, lesson_id) webpage = self._download_webpage(url, display_id) thumbnail = self._og_search_thumbnail( webpage, default=None) or self._html_search_meta( 'twitter:image', webpage, 'thumbnail') if '>Subscribe to unlock' in webpage: raise ExtractorError( 'This content is only available for subscribers', expected=True) info = { 'thumbnail': thumbnail, } vimeo_id = self._search_regex( r'data-vimeo-id=["\'](\d+)', webpage, 'vimeo id', default=None) if not vimeo_id: data = self._parse_json( self._search_regex( r'data-collection=(["\'])(?P<data>{.+?})\1', webpage, 'data collection', default='{}', group='data'), display_id, transform_source=unescapeHTML, fatal=False) video_id = self._extract_video_id( data, lesson_id) or self._search_regex( r'/videos/(\d+)/', thumbnail, 'video id') headers = { 'Referer': url, 'X-Requested-With': 'XMLHttpRequest', } csrf_token = self._html_search_meta( 'csrf-token', webpage, 'csrf token', default=None) if csrf_token: headers['X-CSRF-Token'] = csrf_token video = self._download_json( 'https://videos.raywenderlich.com/api/v1/videos/%s.json' % video_id, display_id, headers=headers)['video'] vimeo_id = video['clips'][0]['provider_id'] info.update({ '_type': 'url_transparent', 'title': video.get('name'), 'description': video.get('description') or video.get( 'meta_description'), 'duration': int_or_none(video.get('duration')), 'timestamp': unified_timestamp(video.get('created_at')), }) return merge_dicts(info, self.url_result( VimeoIE._smuggle_referrer( 'https://player.vimeo.com/video/%s' % vimeo_id, url), ie=VimeoIE.ie_key(), video_id=vimeo_id)) class RayWenderlichCourseIE(InfoExtractor): _VALID_URL = r'''(?x) https?:// (?: videos\.raywenderlich\.com/courses| (?:www\.)?raywenderlich\.com )/ (?P<id>[^/]+) ''' _TEST = { 'url': 'https://www.raywenderlich.com/3530-testing-in-ios', 'info_dict': { 'title': 'Testing in iOS', 'id': '3530-testing-in-ios', }, 'params': { 'noplaylist': False, }, 'playlist_count': 29, } @classmethod def suitable(cls, url): return False if RayWenderlichIE.suitable(url) else super( RayWenderlichCourseIE, cls).suitable(url) def _real_extract(self, url): course_id = self._match_id(url) webpage = self._download_webpage(url, course_id) entries = [] lesson_urls = set() for lesson_url in re.findall( r'<a[^>]+\bhref=["\'](/%s/lessons/\d+)' % course_id, webpage): if lesson_url in lesson_urls: continue lesson_urls.add(lesson_url) entries.append(self.url_result( urljoin(url, lesson_url), ie=RayWenderlichIE.ie_key())) title = self._og_search_title( webpage, default=None) or self._html_search_meta( 'twitter:title', webpage, 'title', default=None) return self.playlist_result(entries, course_id, title)
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/normalboots.py
youtube_dl/extractor/normalboots.py
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from .jwplatform import JWPlatformIE from ..utils import ( unified_strdate, ) class NormalbootsIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?normalboots\.com/video/(?P<id>[0-9a-z-]*)/?$' _TEST = { 'url': 'http://normalboots.com/video/home-alone-games-jontron/', 'info_dict': { 'id': 'home-alone-games-jontron', 'ext': 'mp4', 'title': 'Home Alone Games - JonTron - NormalBoots', 'description': 'Jon is late for Christmas. Typical. Thanks to: Paul Ritchey for Co-Writing/Filming: http://www.youtube.com/user/ContinueShow Michael Azzi for Christmas Intro Animation: http://michafrar.tumblr.com/ Jerrod Waters for Christmas Intro Music: http://www.youtube.com/user/xXJerryTerryXx Casey Ormond for ‘Tense Battle Theme’:\xa0http://www.youtube.com/Kiamet/', 'uploader': 'JonTron', 'upload_date': '20140125', }, 'params': { # m3u8 download 'skip_download': True, }, 'add_ie': ['JWPlatform'], } def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) video_uploader = self._html_search_regex( r'Posted\sby\s<a\shref="[A-Za-z0-9/]*">(?P<uploader>[A-Za-z]*)\s</a>', webpage, 'uploader', fatal=False) video_upload_date = unified_strdate(self._html_search_regex( r'<span style="text-transform:uppercase; font-size:inherit;">[A-Za-z]+, (?P<date>.*)</span>', webpage, 'date', fatal=False)) jwplatform_url = JWPlatformIE._extract_url(webpage) return { '_type': 'url_transparent', 'id': video_id, 'url': jwplatform_url, 'ie_key': JWPlatformIE.ie_key(), 'title': self._og_search_title(webpage), 'description': self._og_search_description(webpage), 'thumbnail': self._og_search_thumbnail(webpage), 'uploader': video_uploader, 'upload_date': video_upload_date, }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/tver.py
youtube_dl/extractor/tver.py
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor from ..compat import compat_str from ..utils import ( int_or_none, remove_start, smuggle_url, try_get, ) class TVerIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?tver\.jp/(?P<path>(?:corner|episode|feature)/(?P<id>f?\d+))' # videos are only available for 7 days _TESTS = [{ 'url': 'https://tver.jp/corner/f0062178', 'only_matching': True, }, { 'url': 'https://tver.jp/feature/f0062413', 'only_matching': True, }, { 'url': 'https://tver.jp/episode/79622438', 'only_matching': True, }, { # subtitle = ' ' 'url': 'https://tver.jp/corner/f0068870', 'only_matching': True, }] _TOKEN = None BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/%s/default_default/index.html?videoId=%s' def _real_initialize(self): self._TOKEN = self._download_json( 'https://tver.jp/api/access_token.php', None)['token'] def _real_extract(self, url): path, video_id = re.match(self._VALID_URL, url).groups() main = self._download_json( 'https://api.tver.jp/v4/' + path, video_id, query={'token': self._TOKEN})['main'] p_id = main['publisher_id'] service = remove_start(main['service'], 'ts_') r_id = main['reference_id'] if service not in ('tx', 'russia2018', 'sebare2018live', 'gorin'): r_id = 'ref:' + r_id bc_url = smuggle_url( self.BRIGHTCOVE_URL_TEMPLATE % (p_id, r_id), {'geo_countries': ['JP']}) return { '_type': 'url_transparent', 'description': try_get(main, lambda x: x['note'][0]['text'], compat_str), 'episode_number': int_or_none(try_get(main, lambda x: x['ext']['episode_number'])), 'url': bc_url, 'ie_key': 'BrightcoveNew', }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/videopress.py
youtube_dl/extractor/videopress.py
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import ( determine_ext, float_or_none, int_or_none, parse_age_limit, qualities, random_birthday, unified_timestamp, urljoin, ) class VideoPressIE(InfoExtractor): _ID_REGEX = r'[\da-zA-Z]{8}' _PATH_REGEX = r'video(?:\.word)?press\.com/embed/' _VALID_URL = r'https?://%s(?P<id>%s)' % (_PATH_REGEX, _ID_REGEX) _TESTS = [{ 'url': 'https://videopress.com/embed/kUJmAcSf', 'md5': '706956a6c875873d51010921310e4bc6', 'info_dict': { 'id': 'kUJmAcSf', 'ext': 'mp4', 'title': 'VideoPress Demo', 'thumbnail': r're:^https?://.*\.jpg', 'duration': 634.6, 'timestamp': 1434983935, 'upload_date': '20150622', 'age_limit': 0, }, }, { # 17+, requires birth_* params 'url': 'https://videopress.com/embed/iH3gstfZ', 'only_matching': True, }, { 'url': 'https://video.wordpress.com/embed/kUJmAcSf', 'only_matching': True, }] @staticmethod def _extract_urls(webpage): return re.findall( r'<iframe[^>]+src=["\']((?:https?://)?%s%s)' % (VideoPressIE._PATH_REGEX, VideoPressIE._ID_REGEX), webpage) def _real_extract(self, url): video_id = self._match_id(url) query = random_birthday('birth_year', 'birth_month', 'birth_day') query['fields'] = 'description,duration,file_url_base,files,height,original,poster,rating,title,upload_date,width' video = self._download_json( 'https://public-api.wordpress.com/rest/v1.1/videos/%s' % video_id, video_id, query=query) title = video['title'] file_url_base = video.get('file_url_base') or {} base_url = file_url_base.get('https') or file_url_base.get('http') QUALITIES = ('std', 'dvd', 'hd') quality = qualities(QUALITIES) formats = [] for format_id, f in (video.get('files') or {}).items(): if not isinstance(f, dict): continue for ext, path in f.items(): if ext in ('mp4', 'ogg'): formats.append({ 'url': urljoin(base_url, path), 'format_id': '%s-%s' % (format_id, ext), 'ext': determine_ext(path, ext), 'quality': quality(format_id), }) original_url = video.get('original') if original_url: formats.append({ 'url': original_url, 'format_id': 'original', 'quality': len(QUALITIES), 'width': int_or_none(video.get('width')), 'height': int_or_none(video.get('height')), }) self._sort_formats(formats) return { 'id': video_id, 'title': title, 'description': video.get('description'), 'thumbnail': video.get('poster'), 'duration': float_or_none(video.get('duration'), 1000), 'timestamp': unified_timestamp(video.get('upload_date')), 'age_limit': parse_age_limit(video.get('rating')), 'formats': formats, }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/lego.py
youtube_dl/extractor/lego.py
# coding: utf-8 from __future__ import unicode_literals import re import uuid from .common import InfoExtractor from ..compat import compat_HTTPError from ..utils import ( ExtractorError, int_or_none, qualities, ) class LEGOIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?lego\.com/(?P<locale>[a-z]{2}-[a-z]{2})/(?:[^/]+/)*videos/(?:[^/]+/)*[^/?#]+-(?P<id>[0-9a-f]{32})' _TESTS = [{ 'url': 'http://www.lego.com/en-us/videos/themes/club/blocumentary-kawaguchi-55492d823b1b4d5e985787fa8c2973b1', 'md5': 'f34468f176cfd76488767fc162c405fa', 'info_dict': { 'id': '55492d82-3b1b-4d5e-9857-87fa8c2973b1_en-US', 'ext': 'mp4', 'title': 'Blocumentary Great Creations: Akiyuki Kawaguchi', 'description': 'Blocumentary Great Creations: Akiyuki Kawaguchi', }, }, { # geo-restricted but the contentUrl contain a valid url 'url': 'http://www.lego.com/nl-nl/videos/themes/nexoknights/episode-20-kingdom-of-heroes-13bdc2299ab24d9685701a915b3d71e7##sp=399', 'md5': 'c7420221f7ffd03ff056f9db7f8d807c', 'info_dict': { 'id': '13bdc229-9ab2-4d96-8570-1a915b3d71e7_nl-NL', 'ext': 'mp4', 'title': 'Aflevering 20: Helden van het koninkrijk', 'description': 'md5:8ee499aac26d7fa8bcb0cedb7f9c3941', 'age_limit': 5, }, }, { # with subtitle 'url': 'https://www.lego.com/nl-nl/kids/videos/classic/creative-storytelling-the-little-puppy-aa24f27c7d5242bc86102ebdc0f24cba', 'info_dict': { 'id': 'aa24f27c-7d52-42bc-8610-2ebdc0f24cba_nl-NL', 'ext': 'mp4', 'title': 'De kleine puppy', 'description': 'md5:5b725471f849348ac73f2e12cfb4be06', 'age_limit': 1, 'subtitles': { 'nl': [{ 'ext': 'srt', 'url': r're:^https://.+\.srt$', }], }, }, 'params': { 'skip_download': True, }, }] _QUALITIES = { 'Lowest': (64, 180, 320), 'Low': (64, 270, 480), 'Medium': (96, 360, 640), 'High': (128, 540, 960), 'Highest': (128, 720, 1280), } def _real_extract(self, url): locale, video_id = re.match(self._VALID_URL, url).groups() countries = [locale.split('-')[1].upper()] self._initialize_geo_bypass({ 'countries': countries, }) try: item = self._download_json( # https://contentfeed.services.lego.com/api/v2/item/[VIDEO_ID]?culture=[LOCALE]&contentType=Video 'https://services.slingshot.lego.com/mediaplayer/v2', video_id, query={ 'videoId': '%s_%s' % (uuid.UUID(video_id), locale), }, headers=self.geo_verification_headers()) except ExtractorError as e: if isinstance(e.cause, compat_HTTPError) and e.cause.code == 451: self.raise_geo_restricted(countries=countries) raise video = item['Video'] video_id = video['Id'] title = video['Title'] q = qualities(['Lowest', 'Low', 'Medium', 'High', 'Highest']) formats = [] for video_source in item.get('VideoFormats', []): video_source_url = video_source.get('Url') if not video_source_url: continue video_source_format = video_source.get('Format') if video_source_format == 'F4M': formats.extend(self._extract_f4m_formats( video_source_url, video_id, f4m_id=video_source_format, fatal=False)) elif video_source_format == 'M3U8': formats.extend(self._extract_m3u8_formats( video_source_url, video_id, 'mp4', 'm3u8_native', m3u8_id=video_source_format, fatal=False)) else: video_source_quality = video_source.get('Quality') format_id = [] for v in (video_source_format, video_source_quality): if v: format_id.append(v) f = { 'format_id': '-'.join(format_id), 'quality': q(video_source_quality), 'url': video_source_url, } quality = self._QUALITIES.get(video_source_quality) if quality: f.update({ 'abr': quality[0], 'height': quality[1], 'width': quality[2], }), formats.append(f) self._sort_formats(formats) subtitles = {} sub_file_id = video.get('SubFileId') if sub_file_id and sub_file_id != '00000000-0000-0000-0000-000000000000': net_storage_path = video.get('NetstoragePath') invariant_id = video.get('InvariantId') video_file_id = video.get('VideoFileId') video_version = video.get('VideoVersion') if net_storage_path and invariant_id and video_file_id and video_version: subtitles.setdefault(locale[:2], []).append({ 'url': 'https://lc-mediaplayerns-live-s.legocdn.com/public/%s/%s_%s_%s_%s_sub.srt' % (net_storage_path, invariant_id, video_file_id, locale, video_version), }) return { 'id': video_id, 'title': title, 'description': video.get('Description'), 'thumbnail': video.get('GeneratedCoverImage') or video.get('GeneratedThumbnail'), 'duration': int_or_none(video.get('Length')), 'formats': formats, 'subtitles': subtitles, 'age_limit': int_or_none(video.get('AgeFrom')), 'season': video.get('SeasonTitle'), 'season_number': int_or_none(video.get('Season')) or None, 'episode_number': int_or_none(video.get('Episode')) or None, }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/cbslocal.py
youtube_dl/extractor/cbslocal.py
# coding: utf-8 from __future__ import unicode_literals from .anvato import AnvatoIE from .sendtonews import SendtoNewsIE from ..compat import compat_urlparse from ..utils import ( parse_iso8601, unified_timestamp, ) class CBSLocalIE(AnvatoIE): _VALID_URL_BASE = r'https?://[a-z]+\.cbslocal\.com/' _VALID_URL = _VALID_URL_BASE + r'video/(?P<id>\d+)' _TESTS = [{ 'url': 'http://newyork.cbslocal.com/video/3580809-a-very-blue-anniversary/', 'info_dict': { 'id': '3580809', 'ext': 'mp4', 'title': 'A Very Blue Anniversary', 'description': 'CBS2’s Cindy Hsu has more.', 'thumbnail': 're:^https?://.*', 'timestamp': int, 'upload_date': r're:^\d{8}$', 'uploader': 'CBS', 'subtitles': { 'en': 'mincount:5', }, 'categories': [ 'Stations\\Spoken Word\\WCBSTV', 'Syndication\\AOL', 'Syndication\\MSN', 'Syndication\\NDN', 'Syndication\\Yahoo', 'Content\\News', 'Content\\News\\Local News', ], 'tags': ['CBS 2 News Weekends', 'Cindy Hsu', 'Blue Man Group'], }, 'params': { 'skip_download': True, }, }] def _real_extract(self, url): mcp_id = self._match_id(url) return self.url_result( 'anvato:anvato_cbslocal_app_web_prod_547f3e49241ef0e5d30c79b2efbca5d92c698f67:' + mcp_id, 'Anvato', mcp_id) class CBSLocalArticleIE(AnvatoIE): _VALID_URL = CBSLocalIE._VALID_URL_BASE + r'\d+/\d+/\d+/(?P<id>[0-9a-z-]+)' _TESTS = [{ # Anvato backend 'url': 'http://losangeles.cbslocal.com/2016/05/16/safety-advocates-say-fatal-car-seat-failures-are-public-health-crisis', 'md5': 'f0ee3081e3843f575fccef901199b212', 'info_dict': { 'id': '3401037', 'ext': 'mp4', 'title': 'Safety Advocates Say Fatal Car Seat Failures Are \'Public Health Crisis\'', 'description': 'Collapsing seats have been the focus of scrutiny for decades, though experts say remarkably little has been done to address the issue. Randy Paige reports.', 'thumbnail': 're:^https?://.*', 'timestamp': 1463440500, 'upload_date': '20160516', 'uploader': 'CBS', 'subtitles': { 'en': 'mincount:5', }, 'categories': [ 'Stations\\Spoken Word\\KCBSTV', 'Syndication\\MSN', 'Syndication\\NDN', 'Syndication\\AOL', 'Syndication\\Yahoo', 'Syndication\\Tribune', 'Syndication\\Curb.tv', 'Content\\News' ], 'tags': ['CBS 2 News Evening'], }, }, { # SendtoNews embed 'url': 'http://cleveland.cbslocal.com/2016/05/16/indians-score-season-high-15-runs-in-blowout-win-over-reds-rapid-reaction/', 'info_dict': { 'id': 'GxfCe0Zo7D-175909-5588', }, 'playlist_count': 9, 'params': { # m3u8 download 'skip_download': True, }, }] def _real_extract(self, url): display_id = self._match_id(url) webpage = self._download_webpage(url, display_id) sendtonews_url = SendtoNewsIE._extract_url(webpage) if sendtonews_url: return self.url_result( compat_urlparse.urljoin(url, sendtonews_url), ie=SendtoNewsIE.ie_key()) info_dict = self._extract_anvato_videos(webpage, display_id) timestamp = unified_timestamp(self._html_search_regex( r'class="(?:entry|post)-date"[^>]*>([^<]+)', webpage, 'released date', default=None)) or parse_iso8601( self._html_search_meta('uploadDate', webpage)) info_dict.update({ 'display_id': display_id, 'timestamp': timestamp, }) return info_dict
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/tvnow.py
youtube_dl/extractor/tvnow.py
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor from ..compat import compat_str from ..utils import ( ExtractorError, int_or_none, parse_iso8601, parse_duration, str_or_none, update_url_query, urljoin, ) class TVNowBaseIE(InfoExtractor): _VIDEO_FIELDS = ( 'id', 'title', 'free', 'geoblocked', 'articleLong', 'articleShort', 'broadcastStartDate', 'isDrm', 'duration', 'season', 'episode', 'manifest.dashclear', 'manifest.hlsclear', 'manifest.smoothclear', 'format.title', 'format.defaultImage169Format', 'format.defaultImage169Logo') def _call_api(self, path, video_id, query): return self._download_json( 'https://api.tvnow.de/v3/' + path, video_id, query=query) def _extract_video(self, info, display_id): video_id = compat_str(info['id']) title = info['title'] paths = [] for manifest_url in (info.get('manifest') or {}).values(): if not manifest_url: continue manifest_url = update_url_query(manifest_url, {'filter': ''}) path = self._search_regex(r'https?://[^/]+/(.+?)\.ism/', manifest_url, 'path') if path in paths: continue paths.append(path) def url_repl(proto, suffix): return re.sub( r'(?:hls|dash|hss)([.-])', proto + r'\1', re.sub( r'\.ism/(?:[^.]*\.(?:m3u8|mpd)|[Mm]anifest)', '.ism/' + suffix, manifest_url)) def make_urls(proto, suffix): urls = [url_repl(proto, suffix)] hd_url = urls[0].replace('/manifest/', '/ngvod/') if hd_url != urls[0]: urls.append(hd_url) return urls for man_url in make_urls('dash', '.mpd'): formats = self._extract_mpd_formats( man_url, video_id, mpd_id='dash', fatal=False) for man_url in make_urls('hss', 'Manifest'): formats.extend(self._extract_ism_formats( man_url, video_id, ism_id='mss', fatal=False)) for man_url in make_urls('hls', '.m3u8'): formats.extend(self._extract_m3u8_formats( man_url, video_id, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False)) if formats: break else: if info.get('isDrm'): raise ExtractorError( 'Video %s is DRM protected' % video_id, expected=True) if info.get('geoblocked'): raise self.raise_geo_restricted() if not info.get('free', True): raise ExtractorError( 'Video %s is not available for free' % video_id, expected=True) self._sort_formats(formats) description = info.get('articleLong') or info.get('articleShort') timestamp = parse_iso8601(info.get('broadcastStartDate'), ' ') duration = parse_duration(info.get('duration')) f = info.get('format', {}) thumbnails = [{ 'url': 'https://aistvnow-a.akamaihd.net/tvnow/movie/%s' % video_id, }] thumbnail = f.get('defaultImage169Format') or f.get('defaultImage169Logo') if thumbnail: thumbnails.append({ 'url': thumbnail, }) return { 'id': video_id, 'display_id': display_id, 'title': title, 'description': description, 'thumbnails': thumbnails, 'timestamp': timestamp, 'duration': duration, 'series': f.get('title'), 'season_number': int_or_none(info.get('season')), 'episode_number': int_or_none(info.get('episode')), 'episode': title, 'formats': formats, } class TVNowIE(TVNowBaseIE): _VALID_URL = r'''(?x) https?:// (?:www\.)?tvnow\.(?:de|at|ch)/(?P<station>[^/]+)/ (?P<show_id>[^/]+)/ (?!(?:list|jahr)(?:/|$))(?P<id>[^/?\#&]+) ''' @classmethod def suitable(cls, url): return (False if TVNowNewIE.suitable(url) or TVNowSeasonIE.suitable(url) or TVNowAnnualIE.suitable(url) or TVNowShowIE.suitable(url) else super(TVNowIE, cls).suitable(url)) _TESTS = [{ 'url': 'https://www.tvnow.de/rtl2/grip-das-motormagazin/der-neue-porsche-911-gt-3/player', 'info_dict': { 'id': '331082', 'display_id': 'grip-das-motormagazin/der-neue-porsche-911-gt-3', 'ext': 'mp4', 'title': 'Der neue Porsche 911 GT 3', 'description': 'md5:6143220c661f9b0aae73b245e5d898bb', 'timestamp': 1495994400, 'upload_date': '20170528', 'duration': 5283, 'series': 'GRIP - Das Motormagazin', 'season_number': 14, 'episode_number': 405, 'episode': 'Der neue Porsche 911 GT 3', }, }, { # rtl2 'url': 'https://www.tvnow.de/rtl2/armes-deutschland/episode-0008/player', 'only_matching': True, }, { # rtlnitro 'url': 'https://www.tvnow.de/nitro/alarm-fuer-cobra-11-die-autobahnpolizei/auf-eigene-faust-pilot/player', 'only_matching': True, }, { # superrtl 'url': 'https://www.tvnow.de/superrtl/die-lustigsten-schlamassel-der-welt/u-a-ketchup-effekt/player', 'only_matching': True, }, { # ntv 'url': 'https://www.tvnow.de/ntv/startup-news/goetter-in-weiss/player', 'only_matching': True, }, { # vox 'url': 'https://www.tvnow.de/vox/auto-mobil/neues-vom-automobilmarkt-2017-11-19-17-00-00/player', 'only_matching': True, }, { # rtlplus 'url': 'https://www.tvnow.de/rtlplus/op-ruft-dr-bruckner/die-vernaehte-frau/player', 'only_matching': True, }, { 'url': 'https://www.tvnow.de/rtl2/grip-das-motormagazin/der-neue-porsche-911-gt-3', 'only_matching': True, }] def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) display_id = '%s/%s' % mobj.group(2, 3) info = self._call_api( 'movies/' + display_id, display_id, query={ 'fields': ','.join(self._VIDEO_FIELDS), }) return self._extract_video(info, display_id) class TVNowNewIE(InfoExtractor): _VALID_URL = r'''(?x) (?P<base_url>https?:// (?:www\.)?tvnow\.(?:de|at|ch)/ (?:shows|serien))/ (?P<show>[^/]+)-\d+/ [^/]+/ episode-\d+-(?P<episode>[^/?$&]+)-(?P<id>\d+) ''' _TESTS = [{ 'url': 'https://www.tvnow.de/shows/grip-das-motormagazin-1669/2017-05/episode-405-der-neue-porsche-911-gt-3-331082', 'only_matching': True, }] def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) base_url = re.sub(r'(?:shows|serien)', '_', mobj.group('base_url')) show, episode = mobj.group('show', 'episode') return self.url_result( # Rewrite new URLs to the old format and use extraction via old API # at api.tvnow.de as a loophole for bypassing premium content checks '%s/%s/%s' % (base_url, show, episode), ie=TVNowIE.ie_key(), video_id=mobj.group('id')) class TVNowNewBaseIE(InfoExtractor): def _call_api(self, path, video_id, query={}): result = self._download_json( 'https://apigw.tvnow.de/module/' + path, video_id, query=query) error = result.get('error') if error: raise ExtractorError( '%s said: %s' % (self.IE_NAME, error), expected=True) return result r""" TODO: new apigw.tvnow.de based version of TVNowIE. Replace old TVNowIE with it when api.tvnow.de is shut down. This version can't bypass premium checks though. class TVNowIE(TVNowNewBaseIE): _VALID_URL = r'''(?x) https?:// (?:www\.)?tvnow\.(?:de|at|ch)/ (?:shows|serien)/[^/]+/ (?:[^/]+/)+ (?P<display_id>[^/?$&]+)-(?P<id>\d+) ''' _TESTS = [{ # episode with annual navigation 'url': 'https://www.tvnow.de/shows/grip-das-motormagazin-1669/2017-05/episode-405-der-neue-porsche-911-gt-3-331082', 'info_dict': { 'id': '331082', 'display_id': 'grip-das-motormagazin/der-neue-porsche-911-gt-3', 'ext': 'mp4', 'title': 'Der neue Porsche 911 GT 3', 'description': 'md5:6143220c661f9b0aae73b245e5d898bb', 'thumbnail': r're:^https?://.*\.jpg$', 'timestamp': 1495994400, 'upload_date': '20170528', 'duration': 5283, 'series': 'GRIP - Das Motormagazin', 'season_number': 14, 'episode_number': 405, 'episode': 'Der neue Porsche 911 GT 3', }, }, { # rtl2, episode with season navigation 'url': 'https://www.tvnow.de/shows/armes-deutschland-11471/staffel-3/episode-14-bernd-steht-seit-der-trennung-von-seiner-frau-allein-da-526124', 'only_matching': True, }, { # rtlnitro 'url': 'https://www.tvnow.de/serien/alarm-fuer-cobra-11-die-autobahnpolizei-1815/staffel-13/episode-5-auf-eigene-faust-pilot-366822', 'only_matching': True, }, { # superrtl 'url': 'https://www.tvnow.de/shows/die-lustigsten-schlamassel-der-welt-1221/staffel-2/episode-14-u-a-ketchup-effekt-364120', 'only_matching': True, }, { # ntv 'url': 'https://www.tvnow.de/shows/startup-news-10674/staffel-2/episode-39-goetter-in-weiss-387630', 'only_matching': True, }, { # vox 'url': 'https://www.tvnow.de/shows/auto-mobil-174/2017-11/episode-46-neues-vom-automobilmarkt-2017-11-19-17-00-00-380072', 'only_matching': True, }, { 'url': 'https://www.tvnow.de/shows/grip-das-motormagazin-1669/2017-05/episode-405-der-neue-porsche-911-gt-3-331082', 'only_matching': True, }] def _extract_video(self, info, url, display_id): config = info['config'] source = config['source'] video_id = compat_str(info.get('id') or source['videoId']) title = source['title'].strip() paths = [] for manifest_url in (info.get('manifest') or {}).values(): if not manifest_url: continue manifest_url = update_url_query(manifest_url, {'filter': ''}) path = self._search_regex(r'https?://[^/]+/(.+?)\.ism/', manifest_url, 'path') if path in paths: continue paths.append(path) def url_repl(proto, suffix): return re.sub( r'(?:hls|dash|hss)([.-])', proto + r'\1', re.sub( r'\.ism/(?:[^.]*\.(?:m3u8|mpd)|[Mm]anifest)', '.ism/' + suffix, manifest_url)) formats = self._extract_mpd_formats( url_repl('dash', '.mpd'), video_id, mpd_id='dash', fatal=False) formats.extend(self._extract_ism_formats( url_repl('hss', 'Manifest'), video_id, ism_id='mss', fatal=False)) formats.extend(self._extract_m3u8_formats( url_repl('hls', '.m3u8'), video_id, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False)) if formats: break else: if try_get(info, lambda x: x['rights']['isDrm']): raise ExtractorError( 'Video %s is DRM protected' % video_id, expected=True) if try_get(config, lambda x: x['boards']['geoBlocking']['block']): raise self.raise_geo_restricted() if not info.get('free', True): raise ExtractorError( 'Video %s is not available for free' % video_id, expected=True) self._sort_formats(formats) description = source.get('description') thumbnail = url_or_none(source.get('poster')) timestamp = unified_timestamp(source.get('previewStart')) duration = parse_duration(source.get('length')) series = source.get('format') season_number = int_or_none(self._search_regex( r'staffel-(\d+)', url, 'season number', default=None)) episode_number = int_or_none(self._search_regex( r'episode-(\d+)', url, 'episode number', default=None)) return { 'id': video_id, 'display_id': display_id, 'title': title, 'description': description, 'thumbnail': thumbnail, 'timestamp': timestamp, 'duration': duration, 'series': series, 'season_number': season_number, 'episode_number': episode_number, 'episode': title, 'formats': formats, } def _real_extract(self, url): display_id, video_id = re.match(self._VALID_URL, url).groups() info = self._call_api('player/' + video_id, video_id) return self._extract_video(info, video_id, display_id) """ class TVNowListBaseIE(TVNowNewBaseIE): _SHOW_VALID_URL = r'''(?x) (?P<base_url> https?:// (?:www\.)?tvnow\.(?:de|at|ch)/(?:shows|serien)/ [^/?#&]+-(?P<show_id>\d+) ) ''' @classmethod def suitable(cls, url): return (False if TVNowNewIE.suitable(url) else super(TVNowListBaseIE, cls).suitable(url)) def _extract_items(self, url, show_id, list_id, query): items = self._call_api( 'teaserrow/format/episode/' + show_id, list_id, query=query)['items'] entries = [] for item in items: if not isinstance(item, dict): continue item_url = urljoin(url, item.get('url')) if not item_url: continue video_id = str_or_none(item.get('id') or item.get('videoId')) item_title = item.get('subheadline') or item.get('text') entries.append(self.url_result( item_url, ie=TVNowNewIE.ie_key(), video_id=video_id, video_title=item_title)) return self.playlist_result(entries, '%s/%s' % (show_id, list_id)) class TVNowSeasonIE(TVNowListBaseIE): _VALID_URL = r'%s/staffel-(?P<id>\d+)' % TVNowListBaseIE._SHOW_VALID_URL _TESTS = [{ 'url': 'https://www.tvnow.de/serien/alarm-fuer-cobra-11-die-autobahnpolizei-1815/staffel-13', 'info_dict': { 'id': '1815/13', }, 'playlist_mincount': 22, }] def _real_extract(self, url): _, show_id, season_id = re.match(self._VALID_URL, url).groups() return self._extract_items( url, show_id, season_id, {'season': season_id}) class TVNowAnnualIE(TVNowListBaseIE): _VALID_URL = r'%s/(?P<year>\d{4})-(?P<month>\d{2})' % TVNowListBaseIE._SHOW_VALID_URL _TESTS = [{ 'url': 'https://www.tvnow.de/shows/grip-das-motormagazin-1669/2017-05', 'info_dict': { 'id': '1669/2017-05', }, 'playlist_mincount': 2, }] def _real_extract(self, url): _, show_id, year, month = re.match(self._VALID_URL, url).groups() return self._extract_items( url, show_id, '%s-%s' % (year, month), { 'year': int(year), 'month': int(month), }) class TVNowShowIE(TVNowListBaseIE): _VALID_URL = TVNowListBaseIE._SHOW_VALID_URL _TESTS = [{ # annual navigationType 'url': 'https://www.tvnow.de/shows/grip-das-motormagazin-1669', 'info_dict': { 'id': '1669', }, 'playlist_mincount': 73, }, { # season navigationType 'url': 'https://www.tvnow.de/shows/armes-deutschland-11471', 'info_dict': { 'id': '11471', }, 'playlist_mincount': 3, }] @classmethod def suitable(cls, url): return (False if TVNowNewIE.suitable(url) or TVNowSeasonIE.suitable(url) or TVNowAnnualIE.suitable(url) else super(TVNowShowIE, cls).suitable(url)) def _real_extract(self, url): base_url, show_id = re.match(self._VALID_URL, url).groups() result = self._call_api( 'teaserrow/format/navigation/' + show_id, show_id) items = result['items'] entries = [] navigation = result.get('navigationType') if navigation == 'annual': for item in items: if not isinstance(item, dict): continue year = int_or_none(item.get('year')) if year is None: continue months = item.get('months') if not isinstance(months, list): continue for month_dict in months: if not isinstance(month_dict, dict) or not month_dict: continue month_number = int_or_none(list(month_dict.keys())[0]) if month_number is None: continue entries.append(self.url_result( '%s/%04d-%02d' % (base_url, year, month_number), ie=TVNowAnnualIE.ie_key())) elif navigation == 'season': for item in items: if not isinstance(item, dict): continue season_number = int_or_none(item.get('season')) if season_number is None: continue entries.append(self.url_result( '%s/staffel-%d' % (base_url, season_number), ie=TVNowSeasonIE.ie_key())) else: raise ExtractorError('Unknown navigationType') return self.playlist_result(entries, show_id)
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/breakcom.py
youtube_dl/extractor/breakcom.py
from __future__ import unicode_literals import re from .common import InfoExtractor from .youtube import YoutubeIE from ..utils import ( int_or_none, url_or_none, ) class BreakIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?break\.com/video/(?P<display_id>[^/]+?)(?:-(?P<id>\d+))?(?:[/?#&]|$)' _TESTS = [{ 'url': 'http://www.break.com/video/when-girls-act-like-guys-2468056', 'info_dict': { 'id': '2468056', 'ext': 'mp4', 'title': 'When Girls Act Like D-Bags', 'age_limit': 13, }, }, { # youtube embed 'url': 'http://www.break.com/video/someone-forgot-boat-brakes-work', 'info_dict': { 'id': 'RrrDLdeL2HQ', 'ext': 'mp4', 'title': 'Whale Watching Boat Crashing Into San Diego Dock', 'description': 'md5:afc1b2772f0a8468be51dd80eb021069', 'upload_date': '20160331', 'uploader': 'Steve Holden', 'uploader_id': 'sdholden07', }, 'params': { 'skip_download': True, } }, { 'url': 'http://www.break.com/video/ugc/baby-flex-2773063', 'only_matching': True, }] def _real_extract(self, url): display_id, video_id = re.match(self._VALID_URL, url).groups() webpage = self._download_webpage(url, display_id) youtube_url = YoutubeIE._extract_url(webpage) if youtube_url: return self.url_result(youtube_url, ie=YoutubeIE.ie_key()) content = self._parse_json( self._search_regex( r'(?s)content["\']\s*:\s*(\[.+?\])\s*[,\n]', webpage, 'content'), display_id) formats = [] for video in content: video_url = url_or_none(video.get('url')) if not video_url: continue bitrate = int_or_none(self._search_regex( r'(\d+)_kbps', video_url, 'tbr', default=None)) formats.append({ 'url': video_url, 'format_id': 'http-%d' % bitrate if bitrate else 'http', 'tbr': bitrate, }) self._sort_formats(formats) title = self._search_regex( (r'title["\']\s*:\s*(["\'])(?P<value>(?:(?!\1).)+)\1', r'<h1[^>]*>(?P<value>[^<]+)'), webpage, 'title', group='value') def get(key, name): return int_or_none(self._search_regex( r'%s["\']\s*:\s*["\'](\d+)' % key, webpage, name, default=None)) age_limit = get('ratings', 'age limit') video_id = video_id or get('pid', 'video id') or display_id return { 'id': video_id, 'display_id': display_id, 'title': title, 'thumbnail': self._og_search_thumbnail(webpage), 'age_limit': age_limit, 'formats': formats, }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/filmon.py
youtube_dl/extractor/filmon.py
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..compat import ( compat_str, compat_HTTPError, ) from ..utils import ( qualities, strip_or_none, int_or_none, ExtractorError, ) class FilmOnIE(InfoExtractor): IE_NAME = 'filmon' _VALID_URL = r'(?:https?://(?:www\.)?filmon\.com/vod/view/|filmon:)(?P<id>\d+)' _TESTS = [{ 'url': 'https://www.filmon.com/vod/view/24869-0-plan-9-from-outer-space', 'info_dict': { 'id': '24869', 'ext': 'mp4', 'title': 'Plan 9 From Outer Space', 'description': 'Dead human, zombies and vampires', }, }, { 'url': 'https://www.filmon.com/vod/view/2825-1-popeye-series-1', 'info_dict': { 'id': '2825', 'title': 'Popeye Series 1', 'description': 'The original series of Popeye.', }, 'playlist_mincount': 8, }] def _real_extract(self, url): video_id = self._match_id(url) try: response = self._download_json( 'https://www.filmon.com/api/vod/movie?id=%s' % video_id, video_id)['response'] except ExtractorError as e: if isinstance(e.cause, compat_HTTPError): errmsg = self._parse_json(e.cause.read().decode(), video_id)['reason'] raise ExtractorError('%s said: %s' % (self.IE_NAME, errmsg), expected=True) raise title = response['title'] description = strip_or_none(response.get('description')) if response.get('type_id') == 1: entries = [self.url_result('filmon:' + episode_id) for episode_id in response.get('episodes', [])] return self.playlist_result(entries, video_id, title, description) QUALITY = qualities(('low', 'high')) formats = [] for format_id, stream in response.get('streams', {}).items(): stream_url = stream.get('url') if not stream_url: continue formats.append({ 'format_id': format_id, 'url': stream_url, 'ext': 'mp4', 'quality': QUALITY(stream.get('quality')), 'protocol': 'm3u8_native', }) self._sort_formats(formats) thumbnails = [] poster = response.get('poster', {}) thumbs = poster.get('thumbs', {}) thumbs['poster'] = poster for thumb_id, thumb in thumbs.items(): thumb_url = thumb.get('url') if not thumb_url: continue thumbnails.append({ 'id': thumb_id, 'url': thumb_url, 'width': int_or_none(thumb.get('width')), 'height': int_or_none(thumb.get('height')), }) return { 'id': video_id, 'title': title, 'formats': formats, 'description': description, 'thumbnails': thumbnails, } class FilmOnChannelIE(InfoExtractor): IE_NAME = 'filmon:channel' _VALID_URL = r'https?://(?:www\.)?filmon\.com/(?:tv|channel)/(?P<id>[a-z0-9-]+)' _TESTS = [{ # VOD 'url': 'http://www.filmon.com/tv/sports-haters', 'info_dict': { 'id': '4190', 'ext': 'mp4', 'title': 'Sports Haters', 'description': 'md5:dabcb4c1d9cfc77085612f1a85f8275d', }, }, { # LIVE 'url': 'https://www.filmon.com/channel/filmon-sports', 'only_matching': True, }, { 'url': 'https://www.filmon.com/tv/2894', 'only_matching': True, }] _THUMBNAIL_RES = [ ('logo', 56, 28), ('big_logo', 106, 106), ('extra_big_logo', 300, 300), ] def _real_extract(self, url): channel_id = self._match_id(url) try: channel_data = self._download_json( 'http://www.filmon.com/api-v2/channel/' + channel_id, channel_id)['data'] except ExtractorError as e: if isinstance(e.cause, compat_HTTPError): errmsg = self._parse_json(e.cause.read().decode(), channel_id)['message'] raise ExtractorError('%s said: %s' % (self.IE_NAME, errmsg), expected=True) raise channel_id = compat_str(channel_data['id']) is_live = not channel_data.get('is_vod') and not channel_data.get('is_vox') title = channel_data['title'] QUALITY = qualities(('low', 'high')) formats = [] for stream in channel_data.get('streams', []): stream_url = stream.get('url') if not stream_url: continue if not is_live: formats.extend(self._extract_wowza_formats( stream_url, channel_id, skip_protocols=['dash', 'rtmp', 'rtsp'])) continue quality = stream.get('quality') formats.append({ 'format_id': quality, # this is an m3u8 stream, but we are deliberately not using _extract_m3u8_formats # because it doesn't have bitrate variants anyway 'url': stream_url, 'ext': 'mp4', 'quality': QUALITY(quality), }) self._sort_formats(formats) thumbnails = [] for name, width, height in self._THUMBNAIL_RES: thumbnails.append({ 'id': name, 'url': 'http://static.filmon.com/assets/channels/%s/%s.png' % (channel_id, name), 'width': width, 'height': height, }) return { 'id': channel_id, 'display_id': channel_data.get('alias'), 'title': self._live_title(title) if is_live else title, 'description': channel_data.get('description'), 'thumbnails': thumbnails, 'formats': formats, 'is_live': is_live, }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/arkena.py
youtube_dl/extractor/arkena.py
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor from ..compat import compat_urlparse from ..utils import ( ExtractorError, float_or_none, int_or_none, parse_iso8601, try_get, ) class ArkenaIE(InfoExtractor): _VALID_URL = r'''(?x) https?:// (?: video\.(?:arkena|qbrick)\.com/play2/embed/player\?| play\.arkena\.com/(?:config|embed)/avp/v\d/player/media/(?P<id>[^/]+)/[^/]+/(?P<account_id>\d+) ) ''' _TESTS = [{ 'url': 'https://video.qbrick.com/play2/embed/player?accountId=1034090&mediaId=d8ab4607-00090107-aab86310', 'md5': '97f117754e5f3c020f5f26da4a44ebaf', 'info_dict': { 'id': 'd8ab4607-00090107-aab86310', 'ext': 'mp4', 'title': 'EM_HT20_117_roslund_v2.mp4', 'timestamp': 1608285912, 'upload_date': '20201218', 'duration': 1429.162667, 'subtitles': { 'sv': 'count:3', }, }, }, { 'url': 'https://play.arkena.com/embed/avp/v2/player/media/b41dda37-d8e7-4d3f-b1b5-9a9db578bdfe/1/129411', 'only_matching': True, }, { 'url': 'https://play.arkena.com/config/avp/v2/player/media/b41dda37-d8e7-4d3f-b1b5-9a9db578bdfe/1/129411/?callbackMethod=jQuery1111023664739129262213_1469227693893', 'only_matching': True, }, { 'url': 'http://play.arkena.com/config/avp/v1/player/media/327336/darkmatter/131064/?callbackMethod=jQuery1111002221189684892677_1469227595972', 'only_matching': True, }, { 'url': 'http://play.arkena.com/embed/avp/v1/player/media/327336/darkmatter/131064/', 'only_matching': True, }, { 'url': 'http://video.arkena.com/play2/embed/player?accountId=472718&mediaId=35763b3b-00090078-bf604299&pageStyling=styled', 'only_matching': True, }] @staticmethod def _extract_url(webpage): # See https://support.arkena.com/display/PLAY/Ways+to+embed+your+video mobj = re.search( r'<iframe[^>]+src=(["\'])(?P<url>(?:https?:)?//play\.arkena\.com/embed/avp/.+?)\1', webpage) if mobj: return mobj.group('url') def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) video_id = mobj.group('id') account_id = mobj.group('account_id') # Handle http://video.arkena.com/play2/embed/player URL if not video_id: qs = compat_urlparse.parse_qs(compat_urlparse.urlparse(url).query) video_id = qs.get('mediaId', [None])[0] account_id = qs.get('accountId', [None])[0] if not video_id or not account_id: raise ExtractorError('Invalid URL', expected=True) media = self._download_json( 'https://video.qbrick.com/api/v1/public/accounts/%s/medias/%s' % (account_id, video_id), video_id, query={ # https://video.qbrick.com/docs/api/examples/library-api.html 'fields': 'asset/resources/*/renditions/*(height,id,language,links/*(href,mimeType),type,size,videos/*(audios/*(codec,sampleRate),bitrate,codec,duration,height,width),width),created,metadata/*(title,description),tags', }) metadata = media.get('metadata') or {} title = metadata['title'] duration = None formats = [] thumbnails = [] subtitles = {} for resource in media['asset']['resources']: for rendition in (resource.get('renditions') or []): rendition_type = rendition.get('type') for i, link in enumerate(rendition.get('links') or []): href = link.get('href') if not href: continue if rendition_type == 'image': thumbnails.append({ 'filesize': int_or_none(rendition.get('size')), 'height': int_or_none(rendition.get('height')), 'id': rendition.get('id'), 'url': href, 'width': int_or_none(rendition.get('width')), }) elif rendition_type == 'subtitle': subtitles.setdefault(rendition.get('language') or 'en', []).append({ 'url': href, }) elif rendition_type == 'video': f = { 'filesize': int_or_none(rendition.get('size')), 'format_id': rendition.get('id'), 'url': href, } video = try_get(rendition, lambda x: x['videos'][i], dict) if video: if not duration: duration = float_or_none(video.get('duration')) f.update({ 'height': int_or_none(video.get('height')), 'tbr': int_or_none(video.get('bitrate'), 1000), 'vcodec': video.get('codec'), 'width': int_or_none(video.get('width')), }) audio = try_get(video, lambda x: x['audios'][0], dict) if audio: f.update({ 'acodec': audio.get('codec'), 'asr': int_or_none(audio.get('sampleRate')), }) formats.append(f) elif rendition_type == 'index': mime_type = link.get('mimeType') if mime_type == 'application/smil+xml': formats.extend(self._extract_smil_formats( href, video_id, fatal=False)) elif mime_type == 'application/x-mpegURL': formats.extend(self._extract_m3u8_formats( href, video_id, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False)) elif mime_type == 'application/hds+xml': formats.extend(self._extract_f4m_formats( href, video_id, f4m_id='hds', fatal=False)) elif mime_type == 'application/dash+xml': formats.extend(self._extract_f4m_formats( href, video_id, f4m_id='hds', fatal=False)) elif mime_type == 'application/vnd.ms-sstr+xml': formats.extend(self._extract_ism_formats( href, video_id, ism_id='mss', fatal=False)) self._sort_formats(formats) return { 'id': video_id, 'title': title, 'description': metadata.get('description'), 'timestamp': parse_iso8601(media.get('created')), 'thumbnails': thumbnails, 'subtitles': subtitles, 'duration': duration, 'tags': media.get('tags'), 'formats': formats, }
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false
ytdl-org/youtube-dl
https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/malltv.py
youtube_dl/extractor/malltv.py
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..utils import ( clean_html, dict_get, float_or_none, int_or_none, merge_dicts, parse_duration, try_get, ) class MallTVIE(InfoExtractor): _VALID_URL = r'https?://(?:(?:www|sk)\.)?mall\.tv/(?:[^/]+/)*(?P<id>[^/?#&]+)' _TESTS = [{ 'url': 'https://www.mall.tv/18-miliard-pro-neziskovky-opravdu-jsou-sportovci-nebo-clovek-v-tisni-pijavice', 'md5': '1c4a37f080e1f3023103a7b43458e518', 'info_dict': { 'id': 't0zzt0', 'display_id': '18-miliard-pro-neziskovky-opravdu-jsou-sportovci-nebo-clovek-v-tisni-pijavice', 'ext': 'mp4', 'title': '18 miliard pro neziskovky. Opravdu jsou sportovci nebo Člověk v tísni pijavice?', 'description': 'md5:db7d5744a4bd4043d9d98324aa72ab35', 'duration': 216, 'timestamp': 1538870400, 'upload_date': '20181007', 'view_count': int, } }, { 'url': 'https://www.mall.tv/kdo-to-plati/18-miliard-pro-neziskovky-opravdu-jsou-sportovci-nebo-clovek-v-tisni-pijavice', 'only_matching': True, }, { 'url': 'https://sk.mall.tv/gejmhaus/reklamacia-nehreje-vyrobnik-tepla-alebo-spekacka', 'only_matching': True, }] def _real_extract(self, url): display_id = self._match_id(url) webpage = self._download_webpage( url, display_id, headers=self.geo_verification_headers()) video = self._parse_json(self._search_regex( r'videoObject\s*=\s*JSON\.parse\(JSON\.stringify\(({.+?})\)\);', webpage, 'video object'), display_id) video_source = video['VideoSource'] video_id = self._search_regex( r'/([\da-z]+)/index\b', video_source, 'video id') formats = self._extract_m3u8_formats( video_source + '.m3u8', video_id, 'mp4', 'm3u8_native') self._sort_formats(formats) subtitles = {} for s in (video.get('Subtitles') or {}): s_url = s.get('Url') if not s_url: continue subtitles.setdefault(s.get('Language') or 'cz', []).append({ 'url': s_url, }) entity_counts = video.get('EntityCounts') or {} def get_count(k): v = entity_counts.get(k + 's') or {} return int_or_none(dict_get(v, ('Count', 'StrCount'))) info = self._search_json_ld(webpage, video_id, default={}) return merge_dicts({ 'id': video_id, 'display_id': display_id, 'title': video.get('Title'), 'description': clean_html(video.get('Description')), 'thumbnail': video.get('ThumbnailUrl'), 'formats': formats, 'subtitles': subtitles, 'duration': int_or_none(video.get('DurationSeconds')) or parse_duration(video.get('Duration')), 'view_count': get_count('View'), 'like_count': get_count('Like'), 'dislike_count': get_count('Dislike'), 'average_rating': float_or_none(try_get(video, lambda x: x['EntityRating']['AvarageRate'])), 'comment_count': get_count('Comment'), }, info)
python
Unlicense
956b8c585591b401a543e409accb163eeaaa1193
2026-01-04T14:38:15.437342Z
false