]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/gamestar.py
7591a151ea352ea4d3c3b066d68bffb1141c513f
[youtubedl] / youtube_dl / extractor / gamestar.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5 from ..utils import (
6 int_or_none,
7 parse_duration,
8 str_to_int,
9 unified_strdate,
10 )
11
12
13 class GameStarIE(InfoExtractor):
14 _VALID_URL = r'http://www\.gamestar\.de/videos/.*,(?P<id>[0-9]+)\.html'
15 _TEST = {
16 'url': 'http://www.gamestar.de/videos/trailer,3/hobbit-3-die-schlacht-der-fuenf-heere,76110.html',
17 'md5': '96974ecbb7fd8d0d20fca5a00810cea7',
18 'info_dict': {
19 'id': '76110',
20 'ext': 'mp4',
21 'title': 'Hobbit 3: Die Schlacht der Fünf Heere - Teaser-Trailer zum dritten Teil',
22 'description': 'Der Teaser-Trailer zu Hobbit 3: Die Schlacht der Fünf Heere zeigt einige Szenen aus dem dritten Teil der Saga und kündigt den vollständigen Trailer an.',
23 'thumbnail': 'http://images.gamestar.de/images/idgwpgsgp/bdb/2494525/600x.jpg',
24 'upload_date': '20140728',
25 'duration': 17
26 }
27 }
28
29 def _real_extract(self, url):
30 video_id = self._match_id(url)
31 webpage = self._download_webpage(url, video_id)
32
33 og_title = self._og_search_title(webpage)
34 title = og_title.replace(' - Video bei GameStar.de', '').strip()
35
36 url = 'http://gamestar.de/_misc/videos/portal/getVideoUrl.cfm?premium=0&videoId=' + video_id
37
38 description = self._og_search_description(webpage).strip()
39
40 thumbnail = self._proto_relative_url(
41 self._og_search_thumbnail(webpage), scheme='http:')
42
43 upload_date = unified_strdate(self._html_search_regex(
44 r'<span style="float:left;font-size:11px;">Datum: ([0-9]+\.[0-9]+\.[0-9]+)&nbsp;&nbsp;',
45 webpage, 'upload_date', fatal=False))
46
47 duration = parse_duration(self._html_search_regex(
48 r'&nbsp;&nbsp;Länge: ([0-9]+:[0-9]+)</span>', webpage, 'duration',
49 fatal=False))
50
51 view_count = str_to_int(self._html_search_regex(
52 r'&nbsp;&nbsp;Zuschauer: ([0-9\.]+)&nbsp;&nbsp;', webpage,
53 'view_count', fatal=False))
54
55 comment_count = int_or_none(self._html_search_regex(
56 r'>Kommentieren \(([0-9]+)\)</a>', webpage, 'comment_count',
57 fatal=False))
58
59 return {
60 'id': video_id,
61 'title': title,
62 'url': url,
63 'ext': 'mp4',
64 'thumbnail': thumbnail,
65 'description': description,
66 'upload_date': upload_date,
67 'duration': duration,
68 'view_count': view_count,
69 'comment_count': comment_count
70 }