]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/funk.py
New upstream version 2019.09.01
[youtubedl] / youtube_dl / extractor / funk.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 import re
5
6 from .common import InfoExtractor
7 from .nexx import NexxIE
8 from ..utils import (
9 int_or_none,
10 str_or_none,
11 )
12
13
14 class FunkIE(InfoExtractor):
15 _VALID_URL = r'https?://(?:www\.)?funk\.net/(?:channel|playlist)/[^/]+/(?P<display_id>[0-9a-z-]+)-(?P<id>\d+)'
16 _TESTS = [{
17 'url': 'https://www.funk.net/channel/ba-793/die-lustigsten-instrumente-aus-dem-internet-teil-2-1155821',
18 'md5': '8dd9d9ab59b4aa4173b3197f2ea48e81',
19 'info_dict': {
20 'id': '1155821',
21 'ext': 'mp4',
22 'title': 'Die LUSTIGSTEN INSTRUMENTE aus dem Internet - Teil 2',
23 'description': 'md5:a691d0413ef4835588c5b03ded670c1f',
24 'timestamp': 1514507395,
25 'upload_date': '20171229',
26 },
27
28 }, {
29 'url': 'https://www.funk.net/playlist/neuesteVideos/kameras-auf-dem-fusion-festival-1618699',
30 'only_matching': True,
31 }]
32
33 def _real_extract(self, url):
34 display_id, nexx_id = re.match(self._VALID_URL, url).groups()
35 video = self._download_json(
36 'https://www.funk.net/api/v4.0/videos/' + nexx_id, nexx_id)
37 return {
38 '_type': 'url_transparent',
39 'url': 'nexx:741:' + nexx_id,
40 'ie_key': NexxIE.ie_key(),
41 'id': nexx_id,
42 'title': video.get('title'),
43 'description': video.get('description'),
44 'duration': int_or_none(video.get('duration')),
45 'channel_id': str_or_none(video.get('channelId')),
46 'display_id': display_id,
47 'tags': video.get('tags'),
48 'thumbnail': video.get('imageUrlLandscape'),
49 }