]>
Commit | Line | Data |
---|---|---|
400afdda | 1 | # encoding: utf-8 |
5bb67dbf | 2 | from __future__ import unicode_literals |
d9dd3584 | 3 | |
7fc18d93 S |
4 | import re |
5 | ||
400afdda | 6 | from .common import InfoExtractor |
7 | from ..utils import ( | |
d9dd3584 | 8 | int_or_none, |
f17e4c9c | 9 | unified_strdate, |
fa7a1cc5 | 10 | js_to_json, |
400afdda | 11 | ) |
12 | ||
ce363395 | 13 | |
f17e4c9c | 14 | class ScreenwaveMediaIE(InfoExtractor): |
678d3329 | 15 | _VALID_URL = r'https?://player\d?\.screenwavemedia\.com/(?:play/)?[a-zA-Z]+\.php\?.*\bid=(?P<id>[A-Za-z0-9-]+)' |
5e58956d | 16 | EMBED_PATTERN = r'src=(["\'])(?P<url>(?:https?:)?//player\d?\.screenwavemedia\.com/(?:play/)?[a-zA-Z]+\.php\?.*\bid=.+?)\1' |
f17e4c9c PH |
17 | _TESTS = [{ |
18 | 'url': 'http://player.screenwavemedia.com/play/play.php?playerdiv=videoarea&companiondiv=squareAd&id=Cinemassacre-19911', | |
19 | 'only_matching': True, | |
20 | }] | |
68471207 | 21 | |
f17e4c9c PH |
22 | def _real_extract(self, url): |
23 | video_id = self._match_id(url) | |
7a012d5a S |
24 | |
25 | playerdata = self._download_webpage( | |
fa7a1cc5 | 26 | 'http://player.screenwavemedia.com/player.php?id=%s' % video_id, |
7a012d5a | 27 | video_id, 'Downloading player webpage') |
68471207 | 28 | |
29 | vidtitle = self._search_regex( | |
f17e4c9c | 30 | r'\'vidtitle\'\s*:\s*"([^"]+)"', playerdata, 'vidtitle').replace('\\/', '/') |
fa7a1cc5 | 31 | |
32 | playerconfig = self._download_webpage( | |
33 | 'http://player.screenwavemedia.com/player.js', | |
34 | video_id, 'Downloading playerconfig webpage') | |
35 | ||
9b22cb10 | 36 | videoserver = self._search_regex(r'SWMServer\s*=\s*"([\d\.]+)"', playerdata, 'videoserver') |
fa7a1cc5 | 37 | |
38 | sources = self._parse_json( | |
39 | js_to_json( | |
7fc18d93 S |
40 | re.sub( |
41 | r'(?s)/\*.*?\*/', '', | |
42 | self._search_regex( | |
43 | r"sources\s*:\s*(\[[^\]]+?\])", playerconfig, | |
44 | 'sources', | |
45 | ).replace( | |
46 | "' + thisObj.options.videoserver + '", | |
47 | videoserver | |
48 | ).replace( | |
49 | "' + playerVidId + '", | |
50 | video_id | |
51 | ) | |
fa7a1cc5 | 52 | ) |
53 | ), | |
8626b23e | 54 | video_id, fatal=False |
fa7a1cc5 | 55 | ) |
56 | ||
8626b23e S |
57 | # Fallback to hardcoded sources if JS changes again |
58 | if not sources: | |
e276fd2c | 59 | self.report_warning('Falling back to a hardcoded list of streams') |
8626b23e S |
60 | sources = [{ |
61 | 'file': 'http://%s/vod/%s_%s.mp4' % (videoserver, video_id, format_id), | |
62 | 'type': 'mp4', | |
63 | 'label': format_label, | |
64 | } for format_id, format_label in ( | |
65 | ('low', '144p Low'), ('med', '160p Med'), ('high', '360p High'), ('hd1', '720p HD1'))] | |
66 | sources.append({ | |
67 | 'file': 'http://%s/vod/smil:%s.smil/playlist.m3u8' % (videoserver, video_id), | |
68 | 'type': 'hls', | |
69 | }) | |
70 | ||
fa7a1cc5 | 71 | formats = [] |
72 | for source in sources: | |
73 | if source['type'] == 'hls': | |
809e1857 | 74 | formats.extend(self._extract_m3u8_formats(source['file'], video_id, ext='mp4')) |
fa7a1cc5 | 75 | else: |
8626b23e S |
76 | file_ = source.get('file') |
77 | if not file_: | |
78 | continue | |
fa7a1cc5 | 79 | format_label = source.get('label') |
8626b23e S |
80 | format_id = self._search_regex( |
81 | r'_(.+?)\.[^.]+$', file_, 'format id', default=None) | |
fa7a1cc5 | 82 | height = int_or_none(self._search_regex( |
83 | r'^(\d+)[pP]', format_label, 'height', default=None)) | |
84 | formats.append({ | |
85 | 'url': source['file'], | |
8626b23e | 86 | 'format_id': format_id, |
fa7a1cc5 | 87 | 'format': format_label, |
88 | 'ext': source.get('type'), | |
89 | 'height': height, | |
90 | }) | |
f17e4c9c | 91 | self._sort_formats(formats) |
400afdda | 92 | |
fcc28edb | 93 | return { |
8032e31f | 94 | 'id': video_id, |
68471207 | 95 | 'title': vidtitle, |
8032e31f | 96 | 'formats': formats, |
8032e31f | 97 | } |
68471207 | 98 | |
f17e4c9c | 99 | |
f17e4c9c PH |
100 | class TeamFourIE(InfoExtractor): |
101 | _VALID_URL = r'https?://(?:www\.)?teamfourstar\.com/video/(?P<id>[a-z0-9\-]+)/?' | |
102 | _TEST = { | |
103 | 'url': 'http://teamfourstar.com/video/a-moment-with-tfs-episode-4/', | |
104 | 'info_dict': { | |
105 | 'id': 'TeamFourStar-5292a02f20bfa', | |
106 | 'ext': 'mp4', | |
107 | 'upload_date': '20130401', | |
108 | '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', | |
109 | 'title': 'A Moment With TFS Episode 4', | |
809e1857 YCH |
110 | }, |
111 | 'params': { | |
112 | # m3u8 download | |
113 | 'skip_download': True, | |
114 | }, | |
f17e4c9c | 115 | } |
68471207 | 116 | |
f17e4c9c PH |
117 | def _real_extract(self, url): |
118 | display_id = self._match_id(url) | |
119 | webpage = self._download_webpage(url, display_id) | |
120 | ||
121 | playerdata_url = self._search_regex( | |
7a012d5a | 122 | r'src="(http://player\d?\.screenwavemedia\.com/(?:play/)?[a-zA-Z]+\.php\?[^"]*\bid=.+?)"', |
f17e4c9c PH |
123 | webpage, 'player data URL') |
124 | ||
125 | video_title = self._html_search_regex( | |
126 | r'<div class="heroheadingtitle">(?P<title>.+?)</div>', | |
127 | webpage, 'title') | |
128 | video_date = unified_strdate(self._html_search_regex( | |
129 | r'<div class="heroheadingdate">(?P<date>.+?)</div>', | |
130 | webpage, 'date', fatal=False)) | |
131 | video_description = self._html_search_regex( | |
132 | r'(?s)<div class="postcontent">(?P<description>.+?)</div>', | |
133 | webpage, 'description', fatal=False) | |
134 | video_thumbnail = self._og_search_thumbnail(webpage) | |
68471207 | 135 | |
f17e4c9c PH |
136 | return { |
137 | '_type': 'url_transparent', | |
138 | 'display_id': display_id, | |
139 | 'title': video_title, | |
140 | 'description': video_description, | |
141 | 'upload_date': video_date, | |
142 | 'thumbnail': video_thumbnail, | |
143 | 'url': playerdata_url, | |
144 | } |