]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/cinemassacre.py
Imported Upstream version 2015.11.10
[youtubedl] / youtube_dl / extractor / cinemassacre.py
1 # encoding: utf-8
2 from __future__ import unicode_literals
3
4 import re
5
6 from .common import InfoExtractor
7 from ..utils import ExtractorError
8 from .bliptv import BlipTVIE
9 from .screenwavemedia import ScreenwaveMediaIE
10
11
12 class CinemassacreIE(InfoExtractor):
13 _VALID_URL = 'https?://(?:www\.)?cinemassacre\.com/(?P<date_y>[0-9]{4})/(?P<date_m>[0-9]{2})/(?P<date_d>[0-9]{2})/(?P<display_id>[^?#/]+)'
14 _TESTS = [
15 {
16 'url': 'http://cinemassacre.com/2012/11/10/avgn-the-movie-trailer/',
17 'md5': 'fde81fbafaee331785f58cd6c0d46190',
18 'info_dict': {
19 'id': 'Cinemassacre-19911',
20 'ext': 'mp4',
21 'upload_date': '20121110',
22 'title': '“Angry Video Game Nerd: The Movie” – Trailer',
23 'description': 'md5:fb87405fcb42a331742a0dce2708560b',
24 },
25 },
26 {
27 'url': 'http://cinemassacre.com/2013/10/02/the-mummys-hand-1940',
28 'md5': 'd72f10cd39eac4215048f62ab477a511',
29 'info_dict': {
30 'id': 'Cinemassacre-521be8ef82b16',
31 'ext': 'mp4',
32 'upload_date': '20131002',
33 'title': 'The Mummy’s Hand (1940)',
34 },
35 },
36 {
37 # blip.tv embedded video
38 'url': 'http://cinemassacre.com/2006/12/07/chronologically-confused-about-bad-movie-and-video-game-sequel-titles/',
39 'md5': 'ca9b3c8dd5a66f9375daeb5135f5a3de',
40 'info_dict': {
41 'id': '4065369',
42 'ext': 'flv',
43 'title': 'AVGN: Chronologically Confused about Bad Movie and Video Game Sequel Titles',
44 'upload_date': '20061207',
45 'uploader': 'cinemassacre',
46 'uploader_id': '250778',
47 'timestamp': 1283233867,
48 'description': 'md5:0a108c78d130676b207d0f6d029ecffd',
49 }
50 },
51 {
52 # Youtube embedded video
53 'url': 'http://cinemassacre.com/2006/09/01/mckids/',
54 'md5': '6eb30961fa795fedc750eac4881ad2e1',
55 'info_dict': {
56 'id': 'FnxsNhuikpo',
57 'ext': 'mp4',
58 'upload_date': '20060901',
59 'uploader': 'Cinemassacre Extras',
60 'description': 'md5:de9b751efa9e45fbaafd9c8a1123ed53',
61 'uploader_id': 'Cinemassacre',
62 'title': 'AVGN: McKids',
63 }
64 },
65 {
66 'url': 'http://cinemassacre.com/2015/05/25/mario-kart-64-nintendo-64-james-mike-mondays/',
67 'md5': '1376908e49572389e7b06251a53cdd08',
68 'info_dict': {
69 'id': 'Cinemassacre-555779690c440',
70 'ext': 'mp4',
71 'description': 'Let’s Play Mario Kart 64 !! Mario Kart 64 is a classic go-kart racing game released for the Nintendo 64 (N64). Today James & Mike do 4 player Battle Mode with Kyle and Bootsy!',
72 'title': 'Mario Kart 64 (Nintendo 64) James & Mike Mondays',
73 'upload_date': '20150525',
74 }
75 }
76 ]
77
78 def _real_extract(self, url):
79 mobj = re.match(self._VALID_URL, url)
80 display_id = mobj.group('display_id')
81 video_date = mobj.group('date_y') + mobj.group('date_m') + mobj.group('date_d')
82
83 webpage = self._download_webpage(url, display_id)
84
85 playerdata_url = self._search_regex(
86 [
87 ScreenwaveMediaIE.EMBED_PATTERN,
88 r'<iframe[^>]+src="(?P<url>(?:https?:)?//(?:[^.]+\.)?youtube\.com/.+?)"',
89 ],
90 webpage, 'player data URL', default=None, group='url')
91 if not playerdata_url:
92 playerdata_url = BlipTVIE._extract_url(webpage)
93 if not playerdata_url:
94 raise ExtractorError('Unable to find player data')
95
96 video_title = self._html_search_regex(
97 r'<title>(?P<title>.+?)\|', webpage, 'title')
98 video_description = self._html_search_regex(
99 r'<div class="entry-content">(?P<description>.+?)</div>',
100 webpage, 'description', flags=re.DOTALL, fatal=False)
101 video_thumbnail = self._og_search_thumbnail(webpage)
102
103 return {
104 '_type': 'url_transparent',
105 'display_id': display_id,
106 'title': video_title,
107 'description': video_description,
108 'upload_date': video_date,
109 'thumbnail': video_thumbnail,
110 'url': playerdata_url,
111 }