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