]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/gameone.py
renamed for consistency
[yt-dlp.git] / youtube_dl / extractor / gameone.py
CommitLineData
412f356e
TB
1# coding: utf-8
2from __future__ import unicode_literals
3
4import re
5
6from .common import InfoExtractor
305d0683
TB
7from ..utils import (
8 xpath_with_ns,
9 parse_iso8601
10)
412f356e
TB
11
12NAMESPACE_MAP = {
13 'media': 'http://search.yahoo.com/mrss/',
14}
15
10d5c7aa 16# URL prefix to download the mp4 files directly instead of streaming via rtmp
e5c3a4b5
TB
17# Credits go to XBox-Maniac
18# http://board.jdownloader.org/showpost.php?p=185835&postcount=31
412f356e
TB
19RAW_MP4_URL = 'http://cdn.riptide-mtvn.com/'
20
305d0683 21
412f356e
TB
22class GameOneIE(InfoExtractor):
23 _VALID_URL = r'https?://(?:www\.)?gameone\.de/tv/(?P<id>\d+)'
9e300923 24 _TEST = {
412f356e
TB
25 'url': 'http://www.gameone.de/tv/288',
26 'md5': '136656b7fb4c9cb4a8e2d500651c499b',
27 'info_dict': {
28 'id': '288',
29 'ext': 'mp4',
30 'title': 'Game One - Folge 288',
31 'duration': 1238,
32 'thumbnail': 'http://s3.gameone.de/gameone/assets/video_metas/teaser_images/000/643/636/big/640x360.jpg',
a84d20fc 33 'description': 'FIFA-Pressepokal 2014, Star Citizen, Kingdom Come: Deliverance, Project Cars, Schöner Trants Nerdquiz Folge 2 Runde 1',
305d0683
TB
34 'age_limit': 16,
35 'upload_date': '20140513',
36 'timestamp': 1399980122,
412f356e
TB
37 }
38 }
39
40 def _real_extract(self, url):
41 mobj = re.match(self._VALID_URL, url)
42 video_id = mobj.group('id')
43
44 webpage = self._download_webpage(url, video_id)
45 og_video = self._og_search_video_url(webpage, secure=False)
a84d20fc 46 description = self._html_search_meta('description', webpage)
e5c3a4b5
TB
47 age_limit = int(
48 self._search_regex(
49 r'age=(\d+)',
50 self._html_search_meta(
51 'age-de-meta-label',
52 webpage),
53 'age_limit',
54 '0'))
412f356e
TB
55 mrss_url = self._search_regex(r'mrss=([^&]+)', og_video, 'mrss')
56
57 mrss = self._download_xml(mrss_url, video_id, 'Downloading mrss')
58 title = mrss.find('.//item/title').text
59 thumbnail = mrss.find('.//item/image').get('url')
305d0683 60 timestamp = parse_iso8601(mrss.find('.//pubDate').text, delimiter=' ')
412f356e
TB
61 content = mrss.find(xpath_with_ns('.//media:content', NAMESPACE_MAP))
62 content_url = content.get('url')
63
e5c3a4b5
TB
64 content = self._download_xml(
65 content_url,
66 video_id,
67 'Downloading media:content')
412f356e
TB
68 rendition_items = content.findall('.//rendition')
69 duration = int(rendition_items[0].get('duration'))
70 formats = [
e5c3a4b5
TB
71 {
72 'url': re.sub(r'.*/(r2)', RAW_MP4_URL + r'\1', r.find('./src').text),
73 'width': int(r.get('width')),
74 'height': int(r.get('height')),
75 'tbr': int(r.get('bitrate')),
76 }
412f356e
TB
77 for r in rendition_items
78 ]
d96b9d40 79 self._sort_formats(formats)
412f356e
TB
80
81 return {
82 'id': video_id,
83 'title': title,
84 'thumbnail': thumbnail,
85 'duration': duration,
86 'formats': formats,
9e300923 87 'description': description,
a231ce87 88 'age_limit': age_limit,
305d0683 89 'timestamp': timestamp,
412f356e 90 }
c065fd35 91
28028629 92
c065fd35
OE
93class GameOnePlaylistIE(InfoExtractor):
94 _VALID_URL = r'https?://(?:www\.)?gameone\.de(?:/tv)?/?$'
28028629
PH
95 IE_NAME = 'gameone:playlist'
96 _TEST = {
97 'url': 'http://www.gameone.de/tv',
98 'info_dict': {
99 'title': 'GameOne',
100 },
101 'playlist_mincount': 294,
102 }
c065fd35
OE
103
104 def _real_extract(self, url):
8c778adc 105 webpage = self._download_webpage('http://www.gameone.de/tv', 'TV')
c065fd35 106 max_id = max(map(int, re.findall(r'<a href="/tv/(\d+)"', webpage)))
28028629
PH
107 entries = [
108 self.url_result('http://www.gameone.de/tv/%d' % video_id, 'GameOne')
109 for video_id in range(max_id, 0, -1)]
c065fd35
OE
110
111 return {
112 '_type': 'playlist',
113 'title': 'GameOne',
114 'entries': entries,
115 }