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