]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/clipfish.py
Update Standards-Version to 3.9.8 (no changes required).
[youtubedl] / youtube_dl / extractor / clipfish.py
1 from __future__ import unicode_literals
2
3 from .common import InfoExtractor
4 from ..utils import (
5 int_or_none,
6 unified_strdate,
7 )
8
9
10 class ClipfishIE(InfoExtractor):
11 _VALID_URL = r'https?://(?:www\.)?clipfish\.de/(?:[^/]+/)+video/(?P<id>[0-9]+)'
12 _TEST = {
13 'url': 'http://www.clipfish.de/special/game-trailer/video/3966754/fifa-14-e3-2013-trailer/',
14 'md5': '79bc922f3e8a9097b3d68a93780fd475',
15 'info_dict': {
16 'id': '3966754',
17 'ext': 'mp4',
18 'title': 'FIFA 14 - E3 2013 Trailer',
19 'description': 'Video zu FIFA 14: E3 2013 Trailer',
20 'upload_date': '20130611',
21 'duration': 82,
22 'view_count': int,
23 }
24 }
25
26 def _real_extract(self, url):
27 video_id = self._match_id(url)
28
29 video_info = self._download_json(
30 'http://www.clipfish.de/devapi/id/%s?format=json&apikey=hbbtv' % video_id,
31 video_id)['items'][0]
32
33 formats = []
34
35 m3u8_url = video_info.get('media_videourl_hls')
36 if m3u8_url:
37 formats.append({
38 'url': m3u8_url.replace('de.hls.fra.clipfish.de', 'hls.fra.clipfish.de'),
39 'ext': 'mp4',
40 'format_id': 'hls',
41 })
42
43 mp4_url = video_info.get('media_videourl')
44 if mp4_url:
45 formats.append({
46 'url': mp4_url,
47 'format_id': 'mp4',
48 'width': int_or_none(video_info.get('width')),
49 'height': int_or_none(video_info.get('height')),
50 'tbr': int_or_none(video_info.get('bitrate')),
51 })
52
53 return {
54 'id': video_id,
55 'title': video_info['title'],
56 'description': video_info.get('descr'),
57 'formats': formats,
58 'thumbnail': video_info.get('media_content_thumbnail_large') or video_info.get('media_thumbnail'),
59 'duration': int_or_none(video_info.get('media_length')),
60 'upload_date': unified_strdate(video_info.get('pubDate')),
61 'view_count': int_or_none(video_info.get('media_views'))
62 }