[puls4] fix extraction(closes #10583)
parent
846d8b76a0
commit
9d54b02bae
@ -1,88 +1,51 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .prosiebensat1 import ProSiebenSat1BaseIE
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
ExtractorError,
|
|
||||||
unified_strdate,
|
unified_strdate,
|
||||||
int_or_none,
|
parse_duration,
|
||||||
|
compat_str,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class Puls4IE(InfoExtractor):
|
class Puls4IE(ProSiebenSat1BaseIE):
|
||||||
_VALID_URL = r'https?://(?:www\.)?puls4\.com/video/[^/]+/play/(?P<id>[0-9]+)'
|
_VALID_URL = r'https?://(?:www\.)?puls4\.com/(?P<id>(?:[^/]+/)*?videos/[^?#]+)'
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'http://www.puls4.com/video/pro-und-contra/play/2716816',
|
'url': 'http://www.puls4.com/2-minuten-2-millionen/staffel-3/videos/2min2miotalk/Tobias-Homberger-von-myclubs-im-2min2miotalk-118118',
|
||||||
'md5': '49f6a6629747eeec43cef6a46b5df81d',
|
'md5': 'fd3c6b0903ac72c9d004f04bc6bb3e03',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '2716816',
|
'id': '118118',
|
||||||
'ext': 'mp4',
|
'ext': 'flv',
|
||||||
'title': 'Pro und Contra vom 23.02.2015',
|
'title': 'Tobias Homberger von myclubs im #2min2miotalk',
|
||||||
'description': 'md5:293e44634d9477a67122489994675db6',
|
'description': 'md5:f9def7c5e8745d6026d8885487d91955',
|
||||||
'duration': 2989,
|
'upload_date': '20160830',
|
||||||
'upload_date': '20150224',
|
|
||||||
'uploader': 'PULS_4',
|
'uploader': 'PULS_4',
|
||||||
},
|
},
|
||||||
'skip': 'Only works from Germany',
|
|
||||||
}, {
|
|
||||||
'url': 'http://www.puls4.com/video/kult-spielfilme/play/1298106',
|
|
||||||
'md5': '6a48316c8903ece8dab9b9a7bf7a59ec',
|
|
||||||
'info_dict': {
|
|
||||||
'id': '1298106',
|
|
||||||
'ext': 'mp4',
|
|
||||||
'title': 'Lucky Fritz',
|
|
||||||
},
|
|
||||||
'skip': 'Only works from Germany',
|
|
||||||
}]
|
}]
|
||||||
|
_TOKEN = 'puls4'
|
||||||
|
_SALT = '01!kaNgaiNgah1Ie4AeSha'
|
||||||
|
_CLIENT_NAME = ''
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
path = self._match_id(url)
|
||||||
webpage = self._download_webpage(url, video_id)
|
content_path = self._download_json(
|
||||||
|
'http://www.puls4.com/api/json-fe/page/' + path, path)['content'][0]['url']
|
||||||
error_message = self._html_search_regex(
|
media = self._download_json(
|
||||||
r'<div[^>]+class="message-error"[^>]*>(.+?)</div>',
|
'http://www.puls4.com' + content_path,
|
||||||
webpage, 'error message', default=None)
|
content_path)['mediaCurrent']
|
||||||
if error_message:
|
player_content = media['playerContent']
|
||||||
raise ExtractorError(
|
info = self._extract_video_info(url, player_content['id'])
|
||||||
'%s returned error: %s' % (self.IE_NAME, error_message), expected=True)
|
info.update({
|
||||||
|
'id': compat_str(media['objectId']),
|
||||||
real_url = self._html_search_regex(
|
'title': player_content['title'],
|
||||||
r'\"fsk-button\".+?href=\"([^"]+)',
|
'description': media.get('description'),
|
||||||
webpage, 'fsk_button', default=None)
|
'thumbnail': media.get('previewLink'),
|
||||||
if real_url:
|
'upload_date': unified_strdate(media.get('date')),
|
||||||
webpage = self._download_webpage(real_url, video_id)
|
'duration': parse_duration(player_content.get('duration')),
|
||||||
|
'episode': player_content.get('episodePartName'),
|
||||||
player = self._search_regex(
|
'show': media.get('channel'),
|
||||||
r'p4_video_player(?:_iframe)?\("video_\d+_container"\s*,(.+?)\);\s*\}',
|
'season_id': player_content.get('seasonId'),
|
||||||
webpage, 'player')
|
'uploader': player_content.get('sourceCompany'),
|
||||||
|
})
|
||||||
player_json = self._parse_json(
|
return info
|
||||||
'[%s]' % player, video_id,
|
|
||||||
transform_source=lambda s: s.replace('undefined,', ''))
|
|
||||||
|
|
||||||
formats = None
|
|
||||||
result = None
|
|
||||||
|
|
||||||
for v in player_json:
|
|
||||||
if isinstance(v, list) and not formats:
|
|
||||||
formats = [{
|
|
||||||
'url': f['url'],
|
|
||||||
'format': 'hd' if f.get('hd') else 'sd',
|
|
||||||
'width': int_or_none(f.get('size_x')),
|
|
||||||
'height': int_or_none(f.get('size_y')),
|
|
||||||
'tbr': int_or_none(f.get('bitrate')),
|
|
||||||
} for f in v]
|
|
||||||
self._sort_formats(formats)
|
|
||||||
elif isinstance(v, dict) and not result:
|
|
||||||
result = {
|
|
||||||
'id': video_id,
|
|
||||||
'title': v['videopartname'].strip(),
|
|
||||||
'description': v.get('videotitle'),
|
|
||||||
'duration': int_or_none(v.get('videoduration') or v.get('episodeduration')),
|
|
||||||
'upload_date': unified_strdate(v.get('clipreleasetime')),
|
|
||||||
'uploader': v.get('channel'),
|
|
||||||
}
|
|
||||||
|
|
||||||
result['formats'] = formats
|
|
||||||
|
|
||||||
return result
|
|
||||||
|
Loading…
Reference in New Issue