gmanetwork.py 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. from .common import InfoExtractor
  2. from .dailymotion import DailymotionIE
  3. from .youtube import YoutubeIE
  4. class GMANetworkVideoIE(InfoExtractor):
  5. _VALID_URL = r'https?://(?:www)\.gmanetwork\.com/(?:\w+/){3}(?P<id>\d+)/(?P<display_id>[\w-]+)/video'
  6. _TESTS = [{
  7. 'url': 'https://www.gmanetwork.com/fullepisodes/home/running_man_philippines/168677/running-man-philippines-catch-the-thief-full-chapter-2/video?section=home',
  8. 'info_dict': {
  9. 'id': '28BqW0AXPe0',
  10. 'ext': 'mp4',
  11. 'upload_date': '20220919',
  12. 'uploader_url': 'http://www.youtube.com/channel/UChsoPNR5x-wdSO2GrOSIWqQ',
  13. 'like_count': int,
  14. 'view_count': int,
  15. 'uploader': 'YoüLOL',
  16. 'channel_id': 'UChsoPNR5x-wdSO2GrOSIWqQ',
  17. 'duration': 5313,
  18. 'comment_count': int,
  19. 'tags': 'count:22',
  20. 'uploader_id': 'UChsoPNR5x-wdSO2GrOSIWqQ',
  21. 'title': 'Running Man Philippines: Catch the Thief (FULL CHAPTER 2)',
  22. 'channel_url': 'https://www.youtube.com/channel/UChsoPNR5x-wdSO2GrOSIWqQ',
  23. 'thumbnail': 'https://i.ytimg.com/vi/28BqW0AXPe0/maxresdefault.jpg',
  24. 'release_timestamp': 1663594212,
  25. 'age_limit': 0,
  26. 'channel_follower_count': int,
  27. 'categories': ['Entertainment'],
  28. 'description': 'md5:811bdcea74f9c48051824e494756e926',
  29. 'live_status': 'not_live',
  30. 'playable_in_embed': True,
  31. 'channel': 'YoüLOL',
  32. 'availability': 'public',
  33. 'release_date': '20220919',
  34. },
  35. }, {
  36. 'url': 'https://www.gmanetwork.com/fullepisodes/home/more_than_words/87059/more-than-words-full-episode-80/video?section=home',
  37. 'info_dict': {
  38. 'id': 'yiDOExw2aSA',
  39. 'ext': 'mp4',
  40. 'live_status': 'not_live',
  41. 'channel': 'GMANetwork',
  42. 'like_count': int,
  43. 'channel_follower_count': int,
  44. 'description': 'md5:6d00cd658394fa1a5071200d3ed4be05',
  45. 'duration': 1419,
  46. 'age_limit': 0,
  47. 'comment_count': int,
  48. 'upload_date': '20181003',
  49. 'thumbnail': 'https://i.ytimg.com/vi_webp/yiDOExw2aSA/maxresdefault.webp',
  50. 'availability': 'public',
  51. 'playable_in_embed': True,
  52. 'channel_id': 'UCKL5hAuzgFQsyrsQKgU0Qng',
  53. 'title': 'More Than Words: Full Episode 80 (Finale)',
  54. 'uploader_id': 'GMANETWORK',
  55. 'categories': ['Entertainment'],
  56. 'uploader': 'GMANetwork',
  57. 'channel_url': 'https://www.youtube.com/channel/UCKL5hAuzgFQsyrsQKgU0Qng',
  58. 'tags': 'count:29',
  59. 'view_count': int,
  60. 'uploader_url': 'http://www.youtube.com/user/GMANETWORK',
  61. },
  62. }]
  63. def _real_extract(self, url):
  64. content_id, display_id = self._match_valid_url(url).group('id', 'display_id')
  65. webpage = self._download_webpage(url, display_id)
  66. # webpage route
  67. youtube_id = self._search_regex(
  68. r'var\s*YOUTUBE_VIDEO\s*=\s*[\'"]+(?P<yt_id>[\w-]+)', webpage, 'youtube_id', fatal=False)
  69. if youtube_id:
  70. return self.url_result(youtube_id, YoutubeIE, youtube_id)
  71. # api call route
  72. # more info at https://aphrodite.gmanetwork.com/fullepisodes/assets/fullepisodes/js/dist/fullepisodes_video.js?v=1.1.11
  73. network_url = self._search_regex(
  74. r'NETWORK_URL\s*=\s*[\'"](?P<url>[^\'"]+)', webpage, 'network_url')
  75. json_data = self._download_json(f'{network_url}api/data/content/video/{content_id}', display_id)
  76. if json_data.get('video_file'):
  77. return self.url_result(json_data['video_file'], YoutubeIE, json_data['video_file'])
  78. else:
  79. return self.url_result(json_data['dailymotion_file'], DailymotionIE, json_data['dailymotion_file'])