]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/filmmodu.py
[tiktok] Fix `extractor_key` used in archive
[yt-dlp.git] / yt_dlp / extractor / filmmodu.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5 from ..utils import int_or_none
6
7
8 class FilmmoduIE(InfoExtractor):
9 _VALID_URL = r'https?://(?:www.)?filmmodu.org/(?P<id>[^/]+-(?:turkce-dublaj-izle|altyazili-izle))'
10 _TESTS = [{
11 'url': 'https://www.filmmodu.org/f9-altyazili-izle',
12 'md5': 'aeefd955c2a508a5bdaa3bcec8eeb0d4',
13 'info_dict': {
14 'id': '10804',
15 'ext': 'mp4',
16 'title': 'F9',
17 'description': 'md5:2713f584a4d65afa2611e2948d0b953c',
18 'subtitles': {
19 'tr': [{
20 'ext': 'vtt',
21 }],
22 },
23 'thumbnail': r're:https://s[0-9]+.filmmodu.org/uploads/movie/cover/10804/xXHZeb1yhJvnSHPzZDqee0zfMb6.jpg',
24 },
25 }, {
26 'url': 'https://www.filmmodu.org/the-godfather-turkce-dublaj-izle',
27 'md5': '109f2fcb9c941330eed133971c035c00',
28 'info_dict': {
29 'id': '3646',
30 'ext': 'mp4',
31 'title': 'Baba',
32 'description': 'md5:d43fd651937cd75cc650883ebd8d8461',
33 'thumbnail': r're:https://s[0-9]+.filmmodu.org/uploads/movie/cover/3646/6xKCYgH16UuwEGAyroLU6p8HLIn.jpg',
34 },
35 }]
36
37 def _real_extract(self, url):
38 video_id = self._match_id(url)
39 webpage = self._download_webpage(url, video_id)
40 title = self._og_search_title(webpage, fatal=True)
41 description = self._og_search_description(webpage)
42 thumbnail = self._og_search_thumbnail(webpage)
43 real_video_id = self._search_regex(r'var\s*videoId\s*=\s*\'([0-9]+)\'', webpage, 'video_id')
44 video_type = self._search_regex(r'var\s*videoType\s*=\s*\'([a-z]+)\'', webpage, 'video_type')
45 data = self._download_json('https://www.filmmodu.org/get-source', real_video_id, query={
46 'movie_id': real_video_id,
47 'type': video_type,
48 })
49 formats = [{
50 'url': source['src'],
51 'ext': 'mp4',
52 'format_id': source['label'],
53 'height': int_or_none(source.get('res')),
54 'protocol': 'm3u8_native',
55 } for source in data['sources']]
56
57 self._sort_formats(formats)
58
59 subtitles = {}
60
61 if data.get('subtitle'):
62 subtitles['tr'] = [{
63 'url': data['subtitle'],
64 }]
65
66 return {
67 'id': real_video_id,
68 'display_id': video_id,
69 'title': title,
70 'description': description,
71 'formats': formats,
72 'subtitles': subtitles,
73 'thumbnail': thumbnail,
74 }