]>
Commit | Line | Data |
---|---|---|
91d4b32b | 1 | from .common import InfoExtractor |
e897bd82 | 2 | from ..utils import clean_html, int_or_none, traverse_obj |
91d4b32b | 3 | |
4 | _API_URL = 'https://dak1vd5vmi7x6.cloudfront.net/api/v1/publicrole/{}/{}?id={}' | |
5 | ||
6 | ||
7 | class ManotoTVIE(InfoExtractor): | |
8 | IE_DESC = 'Manoto TV (Episode)' | |
9 | _VALID_URL = r'https?://(?:www\.)?manototv\.com/episode/(?P<id>[0-9]+)' | |
10 | _TESTS = [{ | |
11 | 'url': 'https://www.manototv.com/episode/8475', | |
12 | 'info_dict': { | |
13 | 'id': '8475', | |
14 | 'series': 'خانه های رویایی با برادران اسکات', | |
15 | 'season_number': 7, | |
16 | 'episode_number': 25, | |
17 | 'episode_id': 'My Dream Home S7: Carol & John', | |
18 | 'duration': 3600, | |
19 | 'categories': ['سرگرمی'], | |
20 | 'title': 'کارول و جان', | |
21 | 'description': 'md5:d0fff1f8ba5c6775d312a00165d1a97e', | |
22 | 'thumbnail': r're:^https?://.*\.(jpeg|png|jpg)$', | |
23 | 'ext': 'mp4' | |
24 | }, | |
25 | 'params': { | |
26 | 'skip_download': 'm3u8', | |
27 | } | |
28 | }, { | |
29 | 'url': 'https://www.manototv.com/episode/12576', | |
30 | 'info_dict': { | |
31 | 'id': '12576', | |
32 | 'series': 'فیلم های ایرانی', | |
33 | 'episode_id': 'Seh Mah Taatili', | |
34 | 'duration': 5400, | |
35 | 'view_count': int, | |
36 | 'categories': ['سرگرمی'], | |
37 | 'title': 'سه ماه تعطیلی', | |
38 | 'description': 'سه ماه تعطیلی فیلمی به کارگردانی و نویسندگی شاپور قریب ساختهٔ سال ۱۳۵۶ است.', | |
39 | 'thumbnail': r're:^https?://.*\.(jpeg|png|jpg)$', | |
40 | 'ext': 'mp4' | |
41 | }, | |
42 | 'params': { | |
43 | 'skip_download': 'm3u8', | |
44 | } | |
45 | }] | |
46 | ||
47 | def _real_extract(self, url): | |
48 | video_id = self._match_id(url) | |
49 | episode_json = self._download_json(_API_URL.format('showmodule', 'episodedetails', video_id), video_id) | |
50 | details = episode_json.get('details', {}) | |
51 | formats = self._extract_m3u8_formats(details.get('videoM3u8Url'), video_id, 'mp4') | |
91d4b32b | 52 | return { |
53 | 'id': video_id, | |
54 | 'series': details.get('showTitle'), | |
55 | 'season_number': int_or_none(details.get('analyticsSeasonNumber')), | |
56 | 'episode_number': int_or_none(details.get('episodeNumber')), | |
57 | 'episode_id': details.get('analyticsEpisodeTitle'), | |
58 | 'duration': int_or_none(details.get('durationInMinutes'), invscale=60), | |
59 | 'view_count': details.get('viewCount'), | |
60 | 'categories': [details.get('videoCategory')], | |
61 | 'title': details.get('episodeTitle'), | |
62 | 'description': clean_html(details.get('episodeDescription')), | |
63 | 'thumbnail': details.get('episodelandscapeImgIxUrl'), | |
64 | 'formats': formats, | |
65 | } | |
66 | ||
67 | ||
68 | class ManotoTVShowIE(InfoExtractor): | |
69 | IE_DESC = 'Manoto TV (Show)' | |
70 | _VALID_URL = r'https?://(?:www\.)?manototv\.com/show/(?P<id>[0-9]+)' | |
71 | _TESTS = [{ | |
72 | 'url': 'https://www.manototv.com/show/2526', | |
73 | 'playlist_mincount': 68, | |
74 | 'info_dict': { | |
75 | 'id': '2526', | |
76 | 'title': 'فیلم های ایرانی', | |
77 | 'description': 'مجموعه ای از فیلم های سینمای کلاسیک ایران', | |
78 | }, | |
79 | }] | |
80 | ||
81 | def _real_extract(self, url): | |
82 | show_id = self._match_id(url) | |
83 | show_json = self._download_json(_API_URL.format('showmodule', 'details', show_id), show_id) | |
84 | show_details = show_json.get('details', {}) | |
85 | title = show_details.get('showTitle') | |
86 | description = show_details.get('showSynopsis') | |
87 | ||
88 | series_json = self._download_json(_API_URL.format('showmodule', 'serieslist', show_id), show_id) | |
89 | playlist_id = str(traverse_obj(series_json, ('details', 'list', 0, 'id'))) | |
90 | ||
91 | playlist_json = self._download_json(_API_URL.format('showmodule', 'episodelist', playlist_id), playlist_id) | |
92 | playlist = traverse_obj(playlist_json, ('details', 'list')) or [] | |
93 | ||
94 | entries = [ | |
95 | self.url_result( | |
96 | 'https://www.manototv.com/episode/%s' % item['slideID'], ie=ManotoTVIE.ie_key(), video_id=item['slideID']) | |
97 | for item in playlist] | |
98 | return self.playlist_result(entries, show_id, title, description) | |
99 | ||
100 | ||
101 | class ManotoTVLiveIE(InfoExtractor): | |
102 | IE_DESC = 'Manoto TV (Live)' | |
103 | _VALID_URL = r'https?://(?:www\.)?manototv\.com/live/' | |
104 | _TEST = { | |
105 | 'url': 'https://www.manototv.com/live/', | |
106 | 'info_dict': { | |
107 | 'id': 'live', | |
108 | 'title': 'Manoto TV Live', | |
109 | 'ext': 'mp4', | |
110 | 'is_live': True, | |
111 | }, | |
112 | 'params': { | |
113 | 'skip_download': 'm3u8', | |
114 | } | |
115 | } | |
116 | ||
117 | def _real_extract(self, url): | |
118 | video_id = 'live' | |
119 | json = self._download_json(_API_URL.format('livemodule', 'details', ''), video_id) | |
120 | details = json.get('details', {}) | |
121 | video_url = details.get('liveUrl') | |
122 | formats = self._extract_m3u8_formats(video_url, video_id, 'mp4', live=True) | |
91d4b32b | 123 | return { |
124 | 'id': video_id, | |
125 | 'title': 'Manoto TV Live', | |
126 | 'is_live': True, | |
127 | 'formats': formats, | |
128 | } |