]> gitweb @ CieloNegro.org - youtube-dl.git/blob - youtube_dl/extractor/gamekings.py
[Gamekings] Added test and replaced video_url
[youtube-dl.git] / youtube_dl / extractor / gamekings.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .common import InfoExtractor
6
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             }
29         }
30     ]
31
32     def _real_extract(self, url):
33
34         mobj = re.match(self._VALID_URL, url)
35         name = mobj.group('name')
36         webpage = self._download_webpage(url, name)
37         video_url = self._og_search_video_url(webpage)
38
39         video = re.search(r'[0-9]+', video_url)
40         video_id = video.group(0)
41
42         # Todo: add medium format
43         video_url = video_url.replace(video_id, 'large/' + video_id)
44         if not (self._is_valid_url(video_url, video_id)):
45             video_url = video_url.replace('large/' + video_id, video_id)
46             video_url = video_url.replace('http://stream.gamekings.tv/', '')
47
48         return {
49             'id': video_id,
50             'ext': 'mp4',
51             'url': video_url,
52             'title': self._og_search_title(webpage),
53             'description': self._og_search_description(webpage),
54         }