]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/cinemassacre.py
[youtube] Download DASH manifest
[yt-dlp.git] / youtube_dl / extractor / cinemassacre.py
CommitLineData
400afdda 1# encoding: utf-8
2import re
3
4from .common import InfoExtractor
5from ..utils import (
6 ExtractorError,
7)
8
8032e31f 9
400afdda 10class CinemassacreIE(InfoExtractor):
400afdda 11 _VALID_URL = r'(?:http://)?(?:www\.)?(?P<url>cinemassacre\.com/(?P<date_Y>[0-9]{4})/(?P<date_m>[0-9]{2})/(?P<date_d>[0-9]{2})/.+?)(?:[/?].*)?'
12 _TESTS = [{
13 u'url': u'http://cinemassacre.com/2012/11/10/avgn-the-movie-trailer/',
8032e31f 14 u'file': u'19911.flv',
400afdda 15 u'info_dict': {
8032e31f 16 u'upload_date': u'20121110',
400afdda 17 u'title': u'“Angry Video Game Nerd: The Movie” – Trailer',
ca215e0a 18 u'description': u'md5:fb87405fcb42a331742a0dce2708560b',
400afdda 19 },
20 u'params': {
8032e31f 21 # rtmp download
400afdda 22 u'skip_download': True,
23 },
1ece880d 24 },
25 {
26 u'url': u'http://cinemassacre.com/2013/10/02/the-mummys-hand-1940',
8032e31f 27 u'file': u'521be8ef82b16.flv',
1ece880d 28 u'info_dict': {
8032e31f 29 u'upload_date': u'20131002',
1ece880d 30 u'title': u'The Mummy’s Hand (1940)',
31 },
32 u'params': {
8032e31f 33 # rtmp download
1ece880d 34 u'skip_download': True,
35 },
400afdda 36 }]
37
8032e31f 38 def _real_extract(self, url):
400afdda 39 mobj = re.match(self._VALID_URL, url)
40
41 webpage_url = u'http://' + mobj.group('url')
42 webpage = self._download_webpage(webpage_url, None) # Don't know video id yet
43 video_date = mobj.group('date_Y') + mobj.group('date_m') + mobj.group('date_d')
ab4e1513 44 mobj = re.search(r'src="(?P<embed_url>http://player\.screenwavemedia\.com/play/[a-zA-Z]+\.php\?id=(?:Cinemassacre-)?(?P<video_id>.+?))"', webpage)
1ece880d 45 if not mobj:
46 raise ExtractorError(u'Can\'t extract embed url and video id')
47 playerdata_url = mobj.group(u'embed_url')
48 video_id = mobj.group(u'video_id')
49
50 video_title = self._html_search_regex(r'<title>(?P<title>.+?)\|',
400afdda 51 webpage, u'title')
52 video_description = self._html_search_regex(r'<div class="entry-content">(?P<description>.+?)</div>',
53 webpage, u'description', flags=re.DOTALL, fatal=False)
1ece880d 54 if len(video_description) == 0:
55 video_description = None
8032e31f 56
400afdda 57 playerdata = self._download_webpage(playerdata_url, video_id)
b0505eb6 58 url = self._html_search_regex(r'\'streamer\': \'(?P<url>[^\']+)\'', playerdata, u'url')
b0505eb6 59
60 sd_file = self._html_search_regex(r'\'file\': \'(?P<sd_file>[^\']+)\'', playerdata, u'sd_file')
61 hd_file = self._html_search_regex(r'\'?file\'?: "(?P<hd_file>[^"]+)"', playerdata, u'hd_file')
62 video_thumbnail = self._html_search_regex(r'\'image\': \'(?P<thumbnail>[^\']+)\'', playerdata, u'thumbnail', fatal=False)
400afdda 63
8032e31f
JMF
64 formats = [
65 {
b0505eb6 66 'url': url,
b0505eb6 67 'play_path': 'mp4:' + sd_file,
0ed05a1d 68 'rtmp_live': True, # workaround
8032e31f
JMF
69 'ext': 'flv',
70 'format': 'sd',
71 'format_id': 'sd',
72 },
73 {
b0505eb6 74 'url': url,
b0505eb6 75 'play_path': 'mp4:' + hd_file,
0ed05a1d 76 'rtmp_live': True, # workaround
8032e31f
JMF
77 'ext': 'flv',
78 'format': 'hd',
79 'format_id': 'hd',
80 },
81 ]
400afdda 82
fcc28edb 83 return {
8032e31f
JMF
84 'id': video_id,
85 'title': video_title,
86 'formats': formats,
87 'description': video_description,
88 'upload_date': video_date,
89 'thumbnail': video_thumbnail,
90 }