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