]>
Commit | Line | Data |
---|---|---|
add96eb9 | 1 | import urllib.parse |
2 | ||
366b1f3c | 3 | from .common import InfoExtractor |
f4776371 | 4 | from ..utils import ( |
f4776371 | 5 | determine_ext, |
2c5c1f48 | 6 | float_or_none, |
81b22aee NJ |
7 | get_element_by_id, |
8 | int_or_none, | |
9 | parse_iso8601, | |
f4776371 S |
10 | str_to_int, |
11 | ) | |
366b1f3c NJ |
12 | |
13 | ||
14 | class IzleseneIE(InfoExtractor): | |
f1d15e6d NJ |
15 | _VALID_URL = r'''(?x) |
16 | https?://(?:(?:www|m)\.)?izlesene\.com/ | |
17 | (?:video|embedplayer)/(?:[^/]+/)?(?P<id>[0-9]+) | |
18 | ''' | |
f1d15e6d NJ |
19 | _TESTS = [ |
20 | { | |
21 | 'url': 'http://www.izlesene.com/video/sevincten-cildirtan-dogum-gunu-hediyesi/7599694', | |
22 | 'md5': '4384f9f0ea65086734b881085ee05ac2', | |
23 | 'info_dict': { | |
24 | 'id': '7599694', | |
25 | 'ext': 'mp4', | |
26 | 'title': 'Sevinçten Çıldırtan Doğum Günü Hediyesi', | |
27 | 'description': 'md5:253753e2655dde93f59f74b572454f6d', | |
ec85ded8 | 28 | 'thumbnail': r're:^https?://.*\.jpg', |
f1d15e6d | 29 | 'uploader_id': 'pelikzzle', |
c33c547d | 30 | 'timestamp': int, |
f1d15e6d NJ |
31 | 'upload_date': '20140702', |
32 | 'duration': 95.395, | |
33 | 'age_limit': 0, | |
add96eb9 | 34 | }, |
f1d15e6d NJ |
35 | }, |
36 | { | |
37 | 'url': 'http://www.izlesene.com/video/tarkan-dortmund-2006-konseri/17997', | |
38 | 'md5': '97f09b6872bffa284cb7fa4f6910cb72', | |
39 | 'info_dict': { | |
40 | 'id': '17997', | |
41 | 'ext': 'mp4', | |
42 | 'title': 'Tarkan Dortmund 2006 Konseri', | |
ec85ded8 | 43 | 'thumbnail': r're:^https://.*\.jpg', |
f1d15e6d | 44 | 'uploader_id': 'parlayankiz', |
c33c547d | 45 | 'timestamp': int, |
f1d15e6d NJ |
46 | 'upload_date': '20061112', |
47 | 'duration': 253.666, | |
48 | 'age_limit': 0, | |
add96eb9 | 49 | }, |
f1d15e6d NJ |
50 | }, |
51 | ] | |
366b1f3c NJ |
52 | |
53 | def _real_extract(self, url): | |
81b22aee | 54 | video_id = self._match_id(url) |
366b1f3c | 55 | |
add96eb9 | 56 | webpage = self._download_webpage(f'http://www.izlesene.com/video/{video_id}', video_id) |
03fad17c S |
57 | |
58 | video = self._parse_json( | |
59 | self._search_regex( | |
60 | r'videoObj\s*=\s*({.+?})\s*;\s*\n', webpage, 'streams'), | |
61 | video_id) | |
62 | ||
63 | title = video.get('videoTitle') or self._og_search_title(webpage) | |
64 | ||
65 | formats = [] | |
66 | for stream in video['media']['level']: | |
67 | source_url = stream.get('source') | |
add96eb9 | 68 | if not source_url or not isinstance(source_url, str): |
03fad17c S |
69 | continue |
70 | ext = determine_ext(url, 'mp4') | |
71 | quality = stream.get('value') | |
72 | height = int_or_none(quality) | |
73 | formats.append({ | |
add96eb9 | 74 | 'format_id': f'{quality}p' if quality else 'sd', |
75 | 'url': urllib.parse.unquote(source_url), | |
03fad17c S |
76 | 'ext': ext, |
77 | 'height': height, | |
78 | }) | |
366b1f3c | 79 | |
c9d44887 | 80 | description = self._og_search_description(webpage, default=None) |
03fad17c | 81 | thumbnail = video.get('posterURL') or self._proto_relative_url( |
1414df5c | 82 | self._og_search_thumbnail(webpage), scheme='http:') |
f4776371 S |
83 | |
84 | uploader = self._html_search_regex( | |
f1d15e6d | 85 | r"adduserUsername\s*=\s*'([^']+)';", |
dfe7dd9b | 86 | webpage, 'uploader', fatal=False) |
f4776371 | 87 | timestamp = parse_iso8601(self._html_search_meta( |
dfe7dd9b | 88 | 'uploadDate', webpage, 'upload date')) |
f4776371 | 89 | |
03fad17c S |
90 | duration = float_or_none(video.get('duration') or self._html_search_regex( |
91 | r'videoduration["\']?\s*=\s*(["\'])(?P<value>(?:(?!\1).)+)\1', | |
92 | webpage, 'duration', fatal=False, group='value'), scale=1000) | |
f4776371 S |
93 | |
94 | view_count = str_to_int(get_element_by_id('videoViewCount', webpage)) | |
366b1f3c | 95 | comment_count = self._html_search_regex( |
f1d15e6d NJ |
96 | r'comment_count\s*=\s*\'([^\']+)\';', |
97 | webpage, 'comment_count', fatal=False) | |
366b1f3c | 98 | |
366b1f3c NJ |
99 | return { |
100 | 'id': video_id, | |
101 | 'title': title, | |
366b1f3c NJ |
102 | 'description': description, |
103 | 'thumbnail': thumbnail, | |
f4776371 S |
104 | 'uploader_id': uploader, |
105 | 'timestamp': timestamp, | |
366b1f3c NJ |
106 | 'duration': duration, |
107 | 'view_count': int_or_none(view_count), | |
366b1f3c | 108 | 'comment_count': int_or_none(comment_count), |
641eb10d | 109 | 'age_limit': self._family_friendly_search(webpage), |
f4776371 | 110 | 'formats': formats, |
366b1f3c | 111 | } |