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