]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/screenwavemedia.py
debian/gbp.conf: Change to new git-buildpackage syntax.
[youtubedl] / youtube_dl / extractor / screenwavemedia.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 (
8 int_or_none,
9 unified_strdate,
10 )
11
12
13 class ScreenwaveMediaIE(InfoExtractor):
14 _VALID_URL = r'http://player\.screenwavemedia\.com/play/[a-zA-Z]+\.php\?[^"]*\bid=(?P<id>.+)'
15
16 _TESTS = [{
17 'url': 'http://player.screenwavemedia.com/play/play.php?playerdiv=videoarea&companiondiv=squareAd&id=Cinemassacre-19911',
18 'only_matching': True,
19 }]
20
21 def _real_extract(self, url):
22 video_id = self._match_id(url)
23 playerdata = self._download_webpage(url, video_id, 'Downloading player webpage')
24
25 vidtitle = self._search_regex(
26 r'\'vidtitle\'\s*:\s*"([^"]+)"', playerdata, 'vidtitle').replace('\\/', '/')
27 vidurl = self._search_regex(
28 r'\'vidurl\'\s*:\s*"([^"]+)"', playerdata, 'vidurl').replace('\\/', '/')
29
30 videolist_url = None
31
32 mobj = re.search(r"'videoserver'\s*:\s*'(?P<videoserver>[^']+)'", playerdata)
33 if mobj:
34 videoserver = mobj.group('videoserver')
35 mobj = re.search(r'\'vidid\'\s*:\s*"(?P<vidid>[^\']+)"', playerdata)
36 vidid = mobj.group('vidid') if mobj else video_id
37 videolist_url = 'http://%s/vod/smil:%s.smil/jwplayer.smil' % (videoserver, vidid)
38 else:
39 mobj = re.search(r"file\s*:\s*'(?P<smil>http.+?/jwplayer\.smil)'", playerdata)
40 if mobj:
41 videolist_url = mobj.group('smil')
42
43 if videolist_url:
44 videolist = self._download_xml(videolist_url, video_id, 'Downloading videolist XML')
45 formats = []
46 baseurl = vidurl[:vidurl.rfind('/') + 1]
47 for video in videolist.findall('.//video'):
48 src = video.get('src')
49 if not src:
50 continue
51 file_ = src.partition(':')[-1]
52 width = int_or_none(video.get('width'))
53 height = int_or_none(video.get('height'))
54 bitrate = int_or_none(video.get('system-bitrate'), scale=1000)
55 format = {
56 'url': baseurl + file_,
57 'format_id': src.rpartition('.')[0].rpartition('_')[-1],
58 }
59 if width or height:
60 format.update({
61 'tbr': bitrate,
62 'width': width,
63 'height': height,
64 })
65 else:
66 format.update({
67 'abr': bitrate,
68 'vcodec': 'none',
69 })
70 formats.append(format)
71 else:
72 formats = [{
73 'url': vidurl,
74 }]
75 self._sort_formats(formats)
76
77 return {
78 'id': video_id,
79 'title': vidtitle,
80 'formats': formats,
81 }
82
83
84 class CinemassacreIE(InfoExtractor):
85 _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>[^?#/]+)'
86 _TESTS = [
87 {
88 'url': 'http://cinemassacre.com/2012/11/10/avgn-the-movie-trailer/',
89 'md5': 'fde81fbafaee331785f58cd6c0d46190',
90 'info_dict': {
91 'id': 'Cinemassacre-19911',
92 'ext': 'mp4',
93 'upload_date': '20121110',
94 'title': '“Angry Video Game Nerd: The Movie” – Trailer',
95 'description': 'md5:fb87405fcb42a331742a0dce2708560b',
96 },
97 },
98 {
99 'url': 'http://cinemassacre.com/2013/10/02/the-mummys-hand-1940',
100 'md5': 'd72f10cd39eac4215048f62ab477a511',
101 'info_dict': {
102 'id': 'Cinemassacre-521be8ef82b16',
103 'ext': 'mp4',
104 'upload_date': '20131002',
105 'title': 'The Mummy’s Hand (1940)',
106 },
107 }
108 ]
109
110 def _real_extract(self, url):
111 mobj = re.match(self._VALID_URL, url)
112 display_id = mobj.group('display_id')
113 video_date = mobj.group('date_y') + mobj.group('date_m') + mobj.group('date_d')
114
115 webpage = self._download_webpage(url, display_id)
116
117 playerdata_url = self._search_regex(
118 r'src="(http://player\.screenwavemedia\.com/play/[a-zA-Z]+\.php\?[^"]*\bid=.+?)"',
119 webpage, 'player data URL')
120 video_title = self._html_search_regex(
121 r'<title>(?P<title>.+?)\|', webpage, 'title')
122 video_description = self._html_search_regex(
123 r'<div class="entry-content">(?P<description>.+?)</div>',
124 webpage, 'description', flags=re.DOTALL, fatal=False)
125 video_thumbnail = self._og_search_thumbnail(webpage)
126
127 return {
128 '_type': 'url_transparent',
129 'display_id': display_id,
130 'title': video_title,
131 'description': video_description,
132 'upload_date': video_date,
133 'thumbnail': video_thumbnail,
134 'url': playerdata_url,
135 }
136
137
138 class TeamFourIE(InfoExtractor):
139 _VALID_URL = r'https?://(?:www\.)?teamfourstar\.com/video/(?P<id>[a-z0-9\-]+)/?'
140 _TEST = {
141 'url': 'http://teamfourstar.com/video/a-moment-with-tfs-episode-4/',
142 'info_dict': {
143 'id': 'TeamFourStar-5292a02f20bfa',
144 'ext': 'mp4',
145 'upload_date': '20130401',
146 'description': 'Check out this and more on our website: http://teamfourstar.com\nTFS Store: http://sharkrobot.com/team-four-star\nFollow on Twitter: http://twitter.com/teamfourstar\nLike on FB: http://facebook.com/teamfourstar',
147 'title': 'A Moment With TFS Episode 4',
148 }
149 }
150
151 def _real_extract(self, url):
152 display_id = self._match_id(url)
153 webpage = self._download_webpage(url, display_id)
154
155 playerdata_url = self._search_regex(
156 r'src="(http://player\.screenwavemedia\.com/play/[a-zA-Z]+\.php\?[^"]*\bid=.+?)"',
157 webpage, 'player data URL')
158
159 video_title = self._html_search_regex(
160 r'<div class="heroheadingtitle">(?P<title>.+?)</div>',
161 webpage, 'title')
162 video_date = unified_strdate(self._html_search_regex(
163 r'<div class="heroheadingdate">(?P<date>.+?)</div>',
164 webpage, 'date', fatal=False))
165 video_description = self._html_search_regex(
166 r'(?s)<div class="postcontent">(?P<description>.+?)</div>',
167 webpage, 'description', fatal=False)
168 video_thumbnail = self._og_search_thumbnail(webpage)
169
170 return {
171 '_type': 'url_transparent',
172 'display_id': display_id,
173 'title': video_title,
174 'description': video_description,
175 'upload_date': video_date,
176 'thumbnail': video_thumbnail,
177 'url': playerdata_url,
178 }