]>
Commit | Line | Data |
---|---|---|
0c7c19d6 PH |
1 | import re |
2 | import time | |
dcca796c | 3 | import xml.etree.ElementTree |
0c7c19d6 PH |
4 | |
5 | from .common import InfoExtractor | |
f8f60d27 | 6 | from ..utils import ExtractorError |
0c7c19d6 PH |
7 | |
8 | ||
9 | class ClipfishIE(InfoExtractor): | |
10 | IE_NAME = u'clipfish' | |
11 | ||
12 | _VALID_URL = r'^https?://(?:www\.)?clipfish\.de/.*?/video/(?P<id>[0-9]+)/' | |
13 | _TEST = { | |
fc9e1cc6 PH |
14 | u'url': u'http://www.clipfish.de/special/game-trailer/video/3966754/fifa-14-e3-2013-trailer/', |
15 | u'file': u'3966754.mp4', | |
16 | u'md5': u'2521cd644e862936cf2e698206e47385', | |
0c7c19d6 | 17 | u'info_dict': { |
fc9e1cc6 PH |
18 | u'title': u'FIFA 14 - E3 2013 Trailer', |
19 | u'duration': 82, | |
5e09d6ab PH |
20 | }, |
21 | u'skip': 'Blocked in the US' | |
0c7c19d6 PH |
22 | } |
23 | ||
24 | def _real_extract(self, url): | |
25 | mobj = re.match(self._VALID_URL, url) | |
26 | video_id = mobj.group(1) | |
27 | ||
28 | info_url = ('http://www.clipfish.de/devxml/videoinfo/%s?ts=%d' % | |
29 | (video_id, int(time.time()))) | |
e26f8712 | 30 | doc = self._download_xml( |
0c7c19d6 | 31 | info_url, video_id, note=u'Downloading info page') |
0c7c19d6 PH |
32 | title = doc.find('title').text |
33 | video_url = doc.find('filename').text | |
dcca796c PH |
34 | if video_url is None: |
35 | xml_bytes = xml.etree.ElementTree.tostring(doc) | |
36 | raise ExtractorError(u'Cannot find video URL in document %r' % | |
37 | xml_bytes) | |
0c7c19d6 PH |
38 | thumbnail = doc.find('imageurl').text |
39 | duration_str = doc.find('duration').text | |
40 | m = re.match( | |
41 | r'^(?P<hours>[0-9]+):(?P<minutes>[0-9]{2}):(?P<seconds>[0-9]{2}):(?P<ms>[0-9]*)$', | |
42 | duration_str) | |
43 | if m: | |
44 | duration = ( | |
45 | (int(m.group('hours')) * 60 * 60) + | |
46 | (int(m.group('minutes')) * 60) + | |
47 | (int(m.group('seconds'))) | |
48 | ) | |
49 | else: | |
50 | duration = None | |
51 | ||
52 | return { | |
53 | 'id': video_id, | |
54 | 'title': title, | |
55 | 'url': video_url, | |
56 | 'thumbnail': thumbnail, | |
57 | 'duration': duration, | |
58 | } |