9c2ccbe2de38fe779ec2e857c761a3989027a0ee
[youtube-dl] / youtube_dl / extractor / puls4.py
1 # -*- coding: utf-8 -*-
2 from __future__ import unicode_literals
3
4 from .prosiebensat1 import ProSiebenSat1BaseIE
5 from ..utils import (
6     unified_strdate,
7     parse_duration,
8     compat_str,
9 )
10
11
12 class Puls4IE(ProSiebenSat1BaseIE):
13     _VALID_URL = r'https?://(?:www\.)?puls4\.com/(?P<id>(?:[^/]+/)*?videos/[^?#]+)'
14     _TESTS = [{
15         'url': 'http://www.puls4.com/2-minuten-2-millionen/staffel-3/videos/2min2miotalk/Tobias-Homberger-von-myclubs-im-2min2miotalk-118118',
16         'md5': 'fd3c6b0903ac72c9d004f04bc6bb3e03',
17         'info_dict': {
18             'id': '118118',
19             'ext': 'flv',
20             'title': 'Tobias Homberger von myclubs im #2min2miotalk',
21             'description': 'md5:f9def7c5e8745d6026d8885487d91955',
22             'upload_date': '20160830',
23             'uploader': 'PULS_4',
24         },
25     }]
26     _TOKEN = 'puls4'
27     _SALT = '01!kaNgaiNgah1Ie4AeSha'
28     _CLIENT_NAME = ''
29
30     def _real_extract(self, url):
31         path = self._match_id(url)
32         content_path = self._download_json(
33             'http://www.puls4.com/api/json-fe/page/' + path, path)['content'][0]['url']
34         media = self._download_json(
35             'http://www.puls4.com' + content_path,
36             content_path)['mediaCurrent']
37         player_content = media['playerContent']
38         info = self._extract_video_info(url, player_content['id'])
39         info.update({
40             'id': compat_str(media['objectId']),
41             'title': player_content['title'],
42             'description': media.get('description'),
43             'thumbnail': media.get('previewLink'),
44             'upload_date': unified_strdate(media.get('date')),
45             'duration': parse_duration(player_content.get('duration')),
46             'episode': player_content.get('episodePartName'),
47             'show': media.get('channel'),
48             'season_id': player_content.get('seasonId'),
49             'uploader': player_content.get('sourceCompany'),
50         })
51         return info