]>
Commit | Line | Data |
---|---|---|
0d113603 | 1 | from .common import InfoExtractor |
2 | from .zype import ZypeIE | |
3 | from ..utils import traverse_obj | |
4 | ||
5 | ||
6 | class OfTVIE(InfoExtractor): | |
7 | _VALID_URL = r'https?://(?:www\.)?of.tv/video/(?P<id>\w+)' | |
8 | _TESTS = [{ | |
9 | 'url': 'https://of.tv/video/627d7d95b353db0001dadd1a', | |
10 | 'md5': 'cb9cd5db3bb9ee0d32bfd7e373d6ef0a', | |
11 | 'info_dict': { | |
12 | 'id': '627d7d95b353db0001dadd1a', | |
13 | 'ext': 'mp4', | |
14 | 'title': 'E1: Jacky vs Eric', | |
15 | 'thumbnail': r're:^https?://.*\.jpg', | |
16 | 'average_rating': 0, | |
17 | 'description': 'md5:dd16e3e2a8d27d922e7a989f85986853', | |
18 | 'display_id': '', | |
19 | 'duration': 1423, | |
20 | 'timestamp': 1652391300, | |
21 | 'upload_date': '20220512', | |
22 | 'view_count': 0, | |
23 | 'creator': 'This is Fire' | |
24 | } | |
25 | }] | |
26 | ||
27 | def _real_extract(self, url): | |
28 | video_id = self._match_id(url) | |
29 | webpage = self._download_webpage(url, video_id) | |
30 | info = next(ZypeIE.extract_from_webpage(self._downloader, url, webpage)) | |
31 | info['_type'] = 'url_transparent' | |
32 | info['creator'] = self._search_regex(r'<a[^>]+class=\"creator-name\"[^>]+>([^<]+)', webpage, 'creator') | |
33 | return info | |
34 | ||
35 | ||
36 | class OfTVPlaylistIE(InfoExtractor): | |
37 | _VALID_URL = r'https?://(?:www\.)?of.tv/creators/(?P<id>[a-zA-Z0-9-]+)/.?' | |
38 | _TESTS = [{ | |
39 | 'url': 'https://of.tv/creators/this-is-fire/', | |
40 | 'playlist_count': 8, | |
41 | 'info_dict': { | |
42 | 'id': 'this-is-fire' | |
43 | } | |
44 | }] | |
45 | ||
46 | def _real_extract(self, url): | |
47 | playlist_id = self._match_id(url) | |
48 | webpage = self._download_webpage(url, playlist_id) | |
49 | ||
50 | json_match = self._search_json( | |
51 | r'var\s*remaining_videos\s*=', webpage, 'oftv playlists', playlist_id, contains_pattern=r'\[.+\]') | |
52 | ||
53 | return self.playlist_from_matches( | |
54 | traverse_obj(json_match, (..., 'discovery_url')), playlist_id) |