oftv.py 1.9 KB

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