]> jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/clipfish.py
Merge branch 'master' of github.com:rg3/youtube-dl
[yt-dlp.git] / youtube_dl / extractor / clipfish.py
1 import re
2 import time
3 import xml.etree.ElementTree
4
5 from .common import InfoExtractor
6
7
8 class ClipfishIE(InfoExtractor):
9 IE_NAME = u'clipfish'
10
11 _VALID_URL = r'^https?://(?:www\.)?clipfish\.de/.*?/video/(?P<id>[0-9]+)/'
12 _TEST = {
13 u'url': u'http://www.clipfish.de/special/supertalent/video/4028320/supertalent-2013-ivana-opacak-singt-nobodys-perfect/',
14 u'file': u'4028320.f4v',
15 u'md5': u'5e38bda8c329fbfb42be0386a3f5a382',
16 u'info_dict': {
17 u'title': u'Supertalent 2013: Ivana Opacak singt Nobody\'s Perfect',
18 u'duration': 399,
19 }
20 }
21
22 def _real_extract(self, url):
23 mobj = re.match(self._VALID_URL, url)
24 video_id = mobj.group(1)
25
26 info_url = ('http://www.clipfish.de/devxml/videoinfo/%s?ts=%d' %
27 (video_id, int(time.time())))
28 doc = self._download_xml(
29 info_url, video_id, note=u'Downloading info page')
30 title = doc.find('title').text
31 video_url = doc.find('filename').text
32 if video_url is None:
33 xml_bytes = xml.etree.ElementTree.tostring(doc)
34 raise ExtractorError(u'Cannot find video URL in document %r' %
35 xml_bytes)
36 thumbnail = doc.find('imageurl').text
37 duration_str = doc.find('duration').text
38 m = re.match(
39 r'^(?P<hours>[0-9]+):(?P<minutes>[0-9]{2}):(?P<seconds>[0-9]{2}):(?P<ms>[0-9]*)$',
40 duration_str)
41 if m:
42 duration = (
43 (int(m.group('hours')) * 60 * 60) +
44 (int(m.group('minutes')) * 60) +
45 (int(m.group('seconds')))
46 )
47 else:
48 duration = None
49
50 return {
51 'id': video_id,
52 'title': title,
53 'url': video_url,
54 'thumbnail': thumbnail,
55 'duration': duration,
56 }