]>
Commit | Line | Data |
---|---|---|
366b1f3c NJ |
1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
4 | import re | |
5 | ||
6 | from .common import InfoExtractor | |
f4776371 | 7 | from ..utils import ( |
f4776371 | 8 | determine_ext, |
2c5c1f48 | 9 | float_or_none, |
81b22aee NJ |
10 | get_element_by_id, |
11 | int_or_none, | |
12 | parse_iso8601, | |
f4776371 S |
13 | str_to_int, |
14 | ) | |
366b1f3c NJ |
15 | |
16 | ||
17 | class IzleseneIE(InfoExtractor): | |
f1d15e6d NJ |
18 | _VALID_URL = r'''(?x) |
19 | https?://(?:(?:www|m)\.)?izlesene\.com/ | |
20 | (?:video|embedplayer)/(?:[^/]+/)?(?P<id>[0-9]+) | |
21 | ''' | |
f1d15e6d NJ |
22 | _TESTS = [ |
23 | { | |
24 | 'url': 'http://www.izlesene.com/video/sevincten-cildirtan-dogum-gunu-hediyesi/7599694', | |
25 | 'md5': '4384f9f0ea65086734b881085ee05ac2', | |
26 | 'info_dict': { | |
27 | 'id': '7599694', | |
28 | 'ext': 'mp4', | |
29 | 'title': 'Sevinçten Çıldırtan Doğum Günü Hediyesi', | |
30 | 'description': 'md5:253753e2655dde93f59f74b572454f6d', | |
31 | 'thumbnail': 're:^http://.*\.jpg', | |
32 | 'uploader_id': 'pelikzzle', | |
81b22aee | 33 | 'timestamp': 1404302298, |
f1d15e6d NJ |
34 | 'upload_date': '20140702', |
35 | 'duration': 95.395, | |
36 | 'age_limit': 0, | |
37 | } | |
38 | }, | |
39 | { | |
40 | 'url': 'http://www.izlesene.com/video/tarkan-dortmund-2006-konseri/17997', | |
41 | 'md5': '97f09b6872bffa284cb7fa4f6910cb72', | |
42 | 'info_dict': { | |
43 | 'id': '17997', | |
44 | 'ext': 'mp4', | |
45 | 'title': 'Tarkan Dortmund 2006 Konseri', | |
46 | 'description': 'Tarkan Dortmund 2006 Konseri', | |
47 | 'thumbnail': 're:^http://.*\.jpg', | |
48 | 'uploader_id': 'parlayankiz', | |
81b22aee | 49 | 'timestamp': 1163322193, |
f1d15e6d NJ |
50 | 'upload_date': '20061112', |
51 | 'duration': 253.666, | |
52 | 'age_limit': 0, | |
53 | } | |
54 | }, | |
55 | ] | |
366b1f3c NJ |
56 | |
57 | def _real_extract(self, url): | |
81b22aee | 58 | video_id = self._match_id(url) |
366b1f3c | 59 | |
81b22aee | 60 | url = 'http://www.izlesene.com/video/%s' % video_id |
366b1f3c NJ |
61 | webpage = self._download_webpage(url, video_id) |
62 | ||
63 | title = self._og_search_title(webpage) | |
64 | description = self._og_search_description(webpage) | |
1414df5c NJ |
65 | thumbnail = self._proto_relative_url( |
66 | self._og_search_thumbnail(webpage), scheme='http:') | |
f4776371 S |
67 | |
68 | uploader = self._html_search_regex( | |
f1d15e6d NJ |
69 | r"adduserUsername\s*=\s*'([^']+)';", |
70 | webpage, 'uploader', fatal=False, default='') | |
f4776371 S |
71 | timestamp = parse_iso8601(self._html_search_meta( |
72 | 'uploadDate', webpage, 'upload date', fatal=False)) | |
73 | ||
2c5c1f48 | 74 | duration = float_or_none(self._html_search_regex( |
f1d15e6d | 75 | r'"videoduration"\s*:\s*"([^"]+)"', |
2c5c1f48 | 76 | webpage, 'duration', fatal=False), scale=1000) |
f4776371 S |
77 | |
78 | view_count = str_to_int(get_element_by_id('videoViewCount', webpage)) | |
366b1f3c | 79 | comment_count = self._html_search_regex( |
f1d15e6d NJ |
80 | r'comment_count\s*=\s*\'([^\']+)\';', |
81 | webpage, 'comment_count', fatal=False) | |
366b1f3c | 82 | |
f4776371 S |
83 | family_friendly = self._html_search_meta( |
84 | 'isFamilyFriendly', webpage, 'age limit', fatal=False) | |
85 | ||
86 | content_url = self._html_search_meta( | |
87 | 'contentURL', webpage, 'content URL', fatal=False) | |
88 | ext = determine_ext(content_url, 'mp4') | |
366b1f3c NJ |
89 | |
90 | # Might be empty for some videos. | |
f1d15e6d NJ |
91 | streams = self._html_search_regex( |
92 | r'"qualitylevel"\s*:\s*"([^"]+)"', | |
93 | webpage, 'streams', fatal=False, default='') | |
366b1f3c NJ |
94 | |
95 | formats = [] | |
f1d15e6d NJ |
96 | if streams: |
97 | for stream in streams.split('|'): | |
98 | quality, url = re.search(r'\[(\w+)\](.+)', stream).groups() | |
99 | formats.append({ | |
100 | 'format_id': '%sp' % quality if quality else 'sd', | |
101 | 'url': url, | |
102 | 'ext': ext, | |
103 | }) | |
104 | else: | |
105 | stream_url = self._search_regex( | |
106 | r'"streamurl"\s?:\s?"([^"]+)"', webpage, 'stream URL') | |
366b1f3c | 107 | formats.append({ |
f1d15e6d NJ |
108 | 'format_id': 'sd', |
109 | 'url': stream_url, | |
366b1f3c | 110 | 'ext': ext, |
366b1f3c NJ |
111 | }) |
112 | ||
113 | return { | |
114 | 'id': video_id, | |
115 | 'title': title, | |
366b1f3c NJ |
116 | 'description': description, |
117 | 'thumbnail': thumbnail, | |
f4776371 S |
118 | 'uploader_id': uploader, |
119 | 'timestamp': timestamp, | |
366b1f3c NJ |
120 | 'duration': duration, |
121 | 'view_count': int_or_none(view_count), | |
366b1f3c | 122 | 'comment_count': int_or_none(comment_count), |
f4776371 S |
123 | 'age_limit': 18 if family_friendly == 'False' else 0, |
124 | 'formats': formats, | |
366b1f3c | 125 | } |