]> jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/cinemassacre.py
Merge pull request #8611 from remitamine/ffmpegfd
[yt-dlp.git] / 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 .screenwavemedia import ScreenwaveMediaIE
9
10
11 class CinemassacreIE(InfoExtractor):
12 _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>[^?#/]+)'
13 _TESTS = [
14 {
15 'url': 'http://cinemassacre.com/2012/11/10/avgn-the-movie-trailer/',
16 'md5': 'fde81fbafaee331785f58cd6c0d46190',
17 'info_dict': {
18 'id': 'Cinemassacre-19911',
19 'ext': 'mp4',
20 'upload_date': '20121110',
21 'title': '“Angry Video Game Nerd: The Movie” – Trailer',
22 'description': 'md5:fb87405fcb42a331742a0dce2708560b',
23 },
24 'params': {
25 # m3u8 download
26 'skip_download': True,
27 },
28 },
29 {
30 'url': 'http://cinemassacre.com/2013/10/02/the-mummys-hand-1940',
31 'md5': 'd72f10cd39eac4215048f62ab477a511',
32 'info_dict': {
33 'id': 'Cinemassacre-521be8ef82b16',
34 'ext': 'mp4',
35 'upload_date': '20131002',
36 'title': 'The Mummy’s Hand (1940)',
37 },
38 'params': {
39 # m3u8 download
40 'skip_download': True,
41 },
42 },
43 {
44 # Youtube embedded video
45 'url': 'http://cinemassacre.com/2006/12/07/chronologically-confused-about-bad-movie-and-video-game-sequel-titles/',
46 'md5': 'ec9838a5520ef5409b3e4e42fcb0a3b9',
47 'info_dict': {
48 'id': 'OEVzPCY2T-g',
49 'ext': 'webm',
50 'title': 'AVGN: Chronologically Confused about Bad Movie and Video Game Sequel Titles',
51 'upload_date': '20061207',
52 'uploader': 'Cinemassacre',
53 'uploader_id': 'JamesNintendoNerd',
54 'description': 'md5:784734696c2b8b7f4b8625cc799e07f6',
55 }
56 },
57 {
58 # Youtube embedded video
59 'url': 'http://cinemassacre.com/2006/09/01/mckids/',
60 'md5': '7393c4e0f54602ad110c793eb7a6513a',
61 'info_dict': {
62 'id': 'FnxsNhuikpo',
63 'ext': 'webm',
64 'upload_date': '20060901',
65 'uploader': 'Cinemassacre Extra',
66 'description': 'md5:de9b751efa9e45fbaafd9c8a1123ed53',
67 'uploader_id': 'Cinemassacre',
68 'title': 'AVGN: McKids',
69 }
70 },
71 {
72 'url': 'http://cinemassacre.com/2015/05/25/mario-kart-64-nintendo-64-james-mike-mondays/',
73 'md5': '1376908e49572389e7b06251a53cdd08',
74 'info_dict': {
75 'id': 'Cinemassacre-555779690c440',
76 'ext': 'mp4',
77 '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!',
78 'title': 'Mario Kart 64 (Nintendo 64) James & Mike Mondays',
79 'upload_date': '20150525',
80 },
81 'params': {
82 # m3u8 download
83 'skip_download': True,
84 },
85 }
86 ]
87
88 def _real_extract(self, url):
89 mobj = re.match(self._VALID_URL, url)
90 display_id = mobj.group('display_id')
91 video_date = mobj.group('date_y') + mobj.group('date_m') + mobj.group('date_d')
92
93 webpage = self._download_webpage(url, display_id)
94
95 playerdata_url = self._search_regex(
96 [
97 ScreenwaveMediaIE.EMBED_PATTERN,
98 r'<iframe[^>]+src="(?P<url>(?:https?:)?//(?:[^.]+\.)?youtube\.com/.+?)"',
99 ],
100 webpage, 'player data URL', default=None, group='url')
101 if not playerdata_url:
102 raise ExtractorError('Unable to find player data')
103
104 video_title = self._html_search_regex(
105 r'<title>(?P<title>.+?)\|', webpage, 'title')
106 video_description = self._html_search_regex(
107 r'<div class="entry-content">(?P<description>.+?)</div>',
108 webpage, 'description', flags=re.DOTALL, fatal=False)
109 video_thumbnail = self._og_search_thumbnail(webpage)
110
111 return {
112 '_type': 'url_transparent',
113 'display_id': display_id,
114 'title': video_title,
115 'description': video_description,
116 'upload_date': video_date,
117 'thumbnail': video_thumbnail,
118 'url': playerdata_url,
119 }