]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/gamekings.py
debian/watch: Skip pgpsigurlmangle for the moment.
[youtubedl] / youtube_dl / extractor / gamekings.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5 from ..utils import (
6 xpath_text,
7 xpath_with_ns,
8 )
9 from .youtube import YoutubeIE
10
11
12 class GamekingsIE(InfoExtractor):
13 _VALID_URL = r'http://www\.gamekings\.nl/(?:videos|nieuws)/(?P<id>[^/]+)'
14 _TESTS = [{
15 # YouTube embed video
16 'url': 'http://www.gamekings.nl/videos/phoenix-wright-ace-attorney-dual-destinies-review/',
17 'md5': '5208d3a17adeaef829a7861887cb9029',
18 'info_dict': {
19 'id': 'HkSQKetlGOU',
20 'ext': 'mp4',
21 'title': 'Phoenix Wright: Ace Attorney - Dual Destinies Review',
22 'description': 'md5:db88c0e7f47e9ea50df3271b9dc72e1d',
23 'thumbnail': 're:^https?://.*\.jpg$',
24 'uploader_id': 'UCJugRGo4STYMeFr5RoOShtQ',
25 'uploader': 'Gamekings Vault',
26 'upload_date': '20151123',
27 },
28 'add_ie': ['Youtube'],
29 }, {
30 # vimeo video
31 'url': 'http://www.gamekings.nl/videos/the-legend-of-zelda-majoras-mask/',
32 'md5': '12bf04dfd238e70058046937657ea68d',
33 'info_dict': {
34 'id': 'the-legend-of-zelda-majoras-mask',
35 'ext': 'mp4',
36 'title': 'The Legend of Zelda: Majora’s Mask',
37 'description': 'md5:9917825fe0e9f4057601fe1e38860de3',
38 'thumbnail': 're:^https?://.*\.jpg$',
39 },
40 }, {
41 'url': 'http://www.gamekings.nl/nieuws/gamekings-extra-shelly-en-david-bereiden-zich-voor-op-de-livestream/',
42 'only_matching': True,
43 }]
44
45 def _real_extract(self, url):
46 video_id = self._match_id(url)
47
48 webpage = self._download_webpage(url, video_id)
49
50 playlist_id = self._search_regex(
51 r'gogoVideo\([^,]+,\s*"([^"]+)', webpage, 'playlist id')
52
53 # Check if a YouTube embed is used
54 if YoutubeIE.suitable(playlist_id):
55 return self.url_result(playlist_id, ie='Youtube')
56
57 playlist = self._download_xml(
58 'http://www.gamekings.tv/wp-content/themes/gk2010/rss_playlist.php?id=%s' % playlist_id,
59 video_id)
60
61 NS_MAP = {
62 'jwplayer': 'http://rss.jwpcdn.com/'
63 }
64
65 item = playlist.find('./channel/item')
66
67 thumbnail = xpath_text(item, xpath_with_ns('./jwplayer:image', NS_MAP), 'thumbnail')
68 video_url = item.find(xpath_with_ns('./jwplayer:source', NS_MAP)).get('file')
69
70 return {
71 'id': video_id,
72 'url': video_url,
73 'title': self._og_search_title(webpage),
74 'description': self._og_search_description(webpage),
75 'thumbnail': thumbnail,
76 }