1 from .common
import InfoExtractor
7 from ..utils
.traversal
import traverse_obj
10 class VidlyIE(InfoExtractor
):
11 _VALID_URL
= r
'https?://(?:vid\.ly/|(?:s\.)?vid\.ly/embeded\.html\?(?:[^#]+&)?link=)(?P<id>\w+)'
12 _EMBED_REGEX
= [r
'<script[^>]+\bsrc=[\'"](?P<url>(?:https?:)?//vid\.ly/\w+/embed[^\'"]+)',
13 r'<iframe
[^
>]+\bsrc
=[\'"](?P<url>(?:https?:)?//(?:s\.)?vid\.ly/embeded\.html\?(?:[^#\'"]+&)?link
=\w
+[^
\'"]+)']
15 # JWPlayer 7, Embeds forbidden
16 'url': 'https://vid.ly/2i3o9j/embed',
21 'thumbnail': r're:https://\w+\.cloudfront\.net/',
25 'url': 'http://s.vid.ly/embeded.html?link=jw_test&new=1&autoplay=true&controls=true',
30 'thumbnail': r're:https://\w+\.cloudfront\.net/',
34 'url': 'https://vid.ly/7x0e6l',
42 'url': 'https://www.petfinder.com/dog/gus-57378930/tn/ooltewah/furever-furkids-rescue-tn592/',
47 'thumbnail': r're:https://\w+\.cloudfront\.net/',
51 def _real_extract(self, url):
52 video_id = self._match_id(url)
54 embed_script = self._download_webpage(
55 f'https://vid.ly/{video_id}/embed', video_id, headers={'Referer': 'https://vid.ly/'})
56 player = self._search_json(r'initCallback\(', embed_script, 'player', video_id)
58 player_type = player.get('player') or ''
59 if player_type.startswith('jwplayer'):
60 return self._parse_jwplayer_data(player['config'], video_id)
61 elif not player_type.startswith('vidly'):
62 raise ExtractorError(f'Unknown player type {player_type!r}')
65 ext = mimetype2ext(traverse_obj(player, ('config', 'type')))
66 for source, fid in [('source', 'sd'), ('source_hd', 'hd')]:
67 if traverse_obj(player, ('config', source, {url_or_none})):
69 'url': player['config'][source],
70 'format_id': f'http-{fid}',
73 # Has higher quality formats
74 formats.extend(self._extract_m3u8_formats(
75 f'https://d3fenhwk93s16g.cloudfront.net/{video_id}/hls.m3u8', video_id,
76 fatal=False, note='Requesting higher quality m3u8 formats',
77 errnote='No higher quality m3u8 formats found') or [])