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