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