]> jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/gamekings.py
[Gamekings] Download playlist
[yt-dlp.git] / youtube_dl / extractor / gamekings.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .common import InfoExtractor
6 from ..utils import xpath_text
7
8 class GamekingsIE(InfoExtractor):
9 _VALID_URL = r'http://www\.gamekings\.tv/videos/(?P<name>[0-9a-z\-]+)'
10 _TESTS = [
11 {
12 'url': 'http://www.gamekings.tv/videos/phoenix-wright-ace-attorney-dual-destinies-review/',
13 # MD5 is flaky, seems to change regularly
14 # 'md5': '2f32b1f7b80fdc5cb616efb4f387f8a3',
15 'info_dict': {
16 'id': '20130811',
17 'ext': 'mp4',
18 'title': 'Phoenix Wright: Ace Attorney \u2013 Dual Destinies Review',
19 'description': 'md5:36fd701e57e8c15ac8682a2374c99731',
20 }
21 },
22 {
23 'url': 'http://www.gamekings.tv/videos/the-legend-of-zelda-majoras-mask/',
24 'info_dict': {
25 'id': '118933752',
26 'ext': 'mp4',
27 'title': 'The Legend of Zelda: Majora’s Mask',
28 'description': 'md5:9917825fe0e9f4057601fe1e38860de3'
29 }
30 }
31 ]
32
33 def _real_extract(self, url):
34
35 mobj = re.match(self._VALID_URL, url)
36 name = mobj.group('name')
37 webpage = self._download_webpage(url, name)
38
39 playlist_id = re.search(r'(?:gogoVideo)\(\d+,"?(?P<playlist_id>.*)"', webpage, re.MULTILINE).group('playlist_id')
40 playlist_url = 'http://www.gamekings.tv/wp-content/themes/gk2010/rss_playlist.php?id=' + playlist_id
41 playlist_rss = self._download_xml(playlist_url, playlist_id)
42
43 NS_MAP {
44 'rss': 'http://rss.jwpcdn.com/'
45 }
46
47 # Todo: Implement Xpath for searching the video link
48
49 video_url = self._og_search_video_url(webpage)
50
51 video = re.search(r'[0-9]+', video_url)
52 video_id = video.group(0)
53
54 # Todo: add medium format
55 video_url = video_url.replace(video_id, 'large/' + video_id)
56 if "vimeo" in video_url:
57 video_url = video_url.replace('large/' + video_id, video_id)
58 video_url = video_url.replace('http://stream.gamekings.tv/', '')
59
60 return {
61 'id': video_id,
62 'ext': 'mp4',
63 'url': video_url,
64 'title': self._og_search_title(webpage),
65 'description': self._og_search_description(webpage),
66 }