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