]>
Commit | Line | Data |
---|---|---|
1 | from .common import InfoExtractor | |
2 | from ..utils import ( | |
3 | float_or_none, | |
4 | int_or_none, | |
5 | parse_age_limit, | |
6 | traverse_obj, | |
7 | unified_timestamp, | |
8 | url_or_none, | |
9 | ) | |
10 | ||
11 | ||
12 | class WeyyakIE(InfoExtractor): | |
13 | _VALID_URL = r'https?://weyyak\.com/(?P<lang>\w+)/(?:player/)?(?P<type>episode|movie)/(?P<id>\d+)' | |
14 | _TESTS = [ | |
15 | { | |
16 | 'url': 'https://weyyak.com/en/player/episode/1341952/Ribat-Al-Hob-Episode49', | |
17 | 'md5': '0caf55c1a615531c8fe60f146ae46849', | |
18 | 'info_dict': { | |
19 | 'id': '1341952', | |
20 | 'ext': 'mp4', | |
21 | 'title': 'Ribat Al Hob', | |
22 | 'duration': 2771, | |
23 | 'alt_title': 'رباط الحب', | |
24 | 'season': 'Season 1', | |
25 | 'season_number': 1, | |
26 | 'episode': 'Episode 49', | |
27 | 'episode_number': 49, | |
28 | 'timestamp': 1485907200, | |
29 | 'upload_date': '20170201', | |
30 | 'thumbnail': r're:^https://content\.weyyak\.com/.+/poster-image', | |
31 | 'categories': ['Drama', 'Thrillers', 'Romance'], | |
32 | 'tags': 'count:8', | |
33 | }, | |
34 | }, | |
35 | { | |
36 | 'url': 'https://weyyak.com/en/movie/233255/8-Seconds', | |
37 | 'md5': 'fe740ae0f63e4d1c8a7fc147a410c564', | |
38 | 'info_dict': { | |
39 | 'id': '233255', | |
40 | 'ext': 'mp4', | |
41 | 'title': '8 Seconds', | |
42 | 'duration': 6490, | |
43 | 'alt_title': '8 ثواني', | |
44 | 'description': 'md5:45b83a155c30b49950624c7e99600b9d', | |
45 | 'age_limit': 15, | |
46 | 'release_year': 2015, | |
47 | 'timestamp': 1683106031, | |
48 | 'upload_date': '20230503', | |
49 | 'thumbnail': r're:^https://content\.weyyak\.com/.+/poster-image', | |
50 | 'categories': ['Drama', 'Social'], | |
51 | 'cast': ['Ceylin Adiyaman', 'Esra Inal'], | |
52 | }, | |
53 | }, | |
54 | ] | |
55 | ||
56 | def _real_extract(self, url): | |
57 | video_id, lang, type_ = self._match_valid_url(url).group('id', 'lang', 'type') | |
58 | ||
59 | path = 'episode/' if type_ == 'episode' else 'contents/moviedetails?contentkey=' | |
60 | data = self._download_json( | |
61 | f'https://msapifo-prod-me.weyyak.z5.com/v1/{lang}/{path}{video_id}', video_id)['data'] | |
62 | m3u8_url = self._download_json( | |
63 | f'https://api-weyyak.akamaized.net/get_info/{data["video_id"]}', | |
64 | video_id, 'Extracting video details')['url_video'] | |
65 | formats, subtitles = self._extract_m3u8_formats_and_subtitles(m3u8_url, video_id) | |
66 | ||
67 | return { | |
68 | 'id': video_id, | |
69 | 'formats': formats, | |
70 | 'subtitles': subtitles, | |
71 | **traverse_obj(data, { | |
72 | 'title': ('title', {str}), | |
73 | 'alt_title': ('translated_title', {str}), | |
74 | 'description': ('synopsis', {str}), | |
75 | 'duration': ('length', {float_or_none}), | |
76 | 'age_limit': ('age_rating', {parse_age_limit}), | |
77 | 'season_number': ('season_number', {int_or_none}), | |
78 | 'episode_number': ('episode_number', {int_or_none}), | |
79 | 'thumbnail': ('imagery', 'thumbnail', {url_or_none}), | |
80 | 'categories': ('genres', ..., {str}), | |
81 | 'tags': ('tags', ..., {str}), | |
82 | 'cast': (('main_actor', 'main_actress'), {str}), | |
83 | 'timestamp': ('insertedAt', {unified_timestamp}), | |
84 | 'release_year': ('production_year', {int_or_none}), | |
85 | }), | |
86 | } |