]>
Commit | Line | Data |
---|---|---|
ba40a746 PH |
1 | from __future__ import unicode_literals |
2 | ||
fd5d8270 S |
3 | import re |
4 | ||
0c7c19d6 | 5 | from .common import InfoExtractor |
ba40a746 | 6 | from ..utils import ( |
fd5d8270 | 7 | determine_ext, |
1a117a77 | 8 | int_or_none, |
9 | js_to_json, | |
fd5d8270 S |
10 | parse_iso8601, |
11 | remove_end, | |
ba40a746 | 12 | ) |
0c7c19d6 PH |
13 | |
14 | ||
15 | class ClipfishIE(InfoExtractor): | |
fd5d8270 | 16 | _VALID_URL = r'https?://(?:www\.)?clipfish\.de/(?:[^/]+/)+video/(?P<id>[0-9]+)' |
0c7c19d6 | 17 | _TEST = { |
ba40a746 | 18 | 'url': 'http://www.clipfish.de/special/game-trailer/video/3966754/fifa-14-e3-2013-trailer/', |
1a117a77 | 19 | 'md5': '79bc922f3e8a9097b3d68a93780fd475', |
ba40a746 PH |
20 | 'info_dict': { |
21 | 'id': '3966754', | |
22 | 'ext': 'mp4', | |
23 | 'title': 'FIFA 14 - E3 2013 Trailer', | |
fd5d8270 S |
24 | 'timestamp': 1370938118, |
25 | 'upload_date': '20130611', | |
ba40a746 | 26 | 'duration': 82, |
1a117a77 | 27 | } |
0c7c19d6 PH |
28 | } |
29 | ||
30 | def _real_extract(self, url): | |
1a117a77 | 31 | video_id = self._match_id(url) |
fd5d8270 | 32 | |
1a117a77 | 33 | webpage = self._download_webpage(url, video_id) |
fd5d8270 | 34 | |
1a117a77 | 35 | video_info = self._parse_json( |
fd5d8270 S |
36 | js_to_json(self._html_search_regex( |
37 | '(?s)videoObject\s*=\s*({.+?});', webpage, 'video object')), | |
38 | video_id) | |
39 | ||
40 | formats = [] | |
41 | for video_url in re.findall(r'var\s+videourl\s*=\s*"([^"]+)"', webpage): | |
42 | ext = determine_ext(video_url) | |
43 | if ext == 'm3u8': | |
44 | formats.append({ | |
45 | 'url': video_url.replace('de.hls.fra.clipfish.de', 'hls.fra.clipfish.de'), | |
46 | 'ext': 'mp4', | |
47 | 'format_id': 'hls', | |
48 | }) | |
49 | else: | |
50 | formats.append({ | |
51 | 'url': video_url, | |
52 | 'format_id': ext, | |
53 | }) | |
1a117a77 | 54 | self._sort_formats(formats) |
0c7c19d6 | 55 | |
fd5d8270 S |
56 | title = remove_end(self._og_search_title(webpage), ' - Video') |
57 | thumbnail = self._og_search_thumbnail(webpage) | |
58 | duration = int_or_none(video_info.get('length')) | |
59 | timestamp = parse_iso8601(self._html_search_meta('uploadDate', webpage, 'upload date')) | |
60 | ||
0c7c19d6 PH |
61 | return { |
62 | 'id': video_id, | |
63 | 'title': title, | |
1a117a77 | 64 | 'formats': formats, |
0c7c19d6 PH |
65 | 'thumbnail': thumbnail, |
66 | 'duration': duration, | |
fd5d8270 | 67 | 'timestamp': timestamp, |
0c7c19d6 | 68 | } |