]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/spike.py
Prepare new release.
[youtubedl] / youtube_dl / extractor / spike.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .mtv import MTVServicesInfoExtractor
6
7
8 class SpikeIE(MTVServicesInfoExtractor):
9 _VALID_URL = r'https?://(?:[^/]+\.)?spike\.com/[^/]+/[\da-z]{6}(?:[/?#&]|$)'
10 _TESTS = [{
11 'url': 'http://www.spike.com/video-clips/lhtu8m/auction-hunters-can-allen-ride-a-hundred-year-old-motorcycle',
12 'md5': '1a9265f32b0c375793d6c4ce45255256',
13 'info_dict': {
14 'id': 'b9c8221a-4e50-479a-b86d-3333323e38ba',
15 'ext': 'mp4',
16 'title': 'Auction Hunters|December 27, 2013|4|414|Can Allen Ride A Hundred Year-Old Motorcycle?',
17 'description': 'md5:fbed7e82ed5fad493615b3094a9499cb',
18 'timestamp': 1388120400,
19 'upload_date': '20131227',
20 },
21 }, {
22 'url': 'http://www.spike.com/full-episodes/j830qm/lip-sync-battle-joel-mchale-vs-jim-rash-season-2-ep-209',
23 'md5': 'b25c6f16418aefb9ad5a6cae2559321f',
24 'info_dict': {
25 'id': '37ace3a8-1df6-48be-85b8-38df8229e241',
26 'ext': 'mp4',
27 'title': 'Lip Sync Battle|April 28, 2016|2|209|Joel McHale Vs. Jim Rash|Act 1',
28 'description': 'md5:a739ca8f978a7802f67f8016d27ce114',
29 },
30 }, {
31 'url': 'http://www.spike.com/video-clips/lhtu8m/',
32 'only_matching': True,
33 }, {
34 'url': 'http://www.spike.com/video-clips/lhtu8m',
35 'only_matching': True,
36 }, {
37 'url': 'http://bellator.spike.com/fight/atwr7k/bellator-158-michael-page-vs-evangelista-cyborg',
38 'only_matching': True,
39 }, {
40 'url': 'http://bellator.spike.com/video-clips/bw6k7n/bellator-158-foundations-michael-venom-page',
41 'only_matching': True,
42 }]
43
44 _FEED_URL = 'http://www.spike.com/feeds/mrss/'
45 _MOBILE_TEMPLATE = 'http://m.spike.com/videos/video.rbml?id=%s'
46 _CUSTOM_URL_REGEX = re.compile(r'spikenetworkapp://([^/]+/[-a-fA-F0-9]+)')
47
48 def _extract_mgid(self, webpage):
49 mgid = super(SpikeIE, self)._extract_mgid(webpage)
50 if mgid is None:
51 url_parts = self._search_regex(self._CUSTOM_URL_REGEX, webpage, 'episode_id')
52 video_type, episode_id = url_parts.split('/', 1)
53 mgid = 'mgid:arc:{0}:spike.com:{1}'.format(video_type, episode_id)
54 return mgid