]>
Commit | Line | Data |
---|---|---|
400afdda | 1 | # encoding: utf-8 |
5bb67dbf | 2 | from __future__ import unicode_literals |
d9dd3584 | 3 | |
400afdda | 4 | from .common import InfoExtractor |
5 | from ..utils import ( | |
d9dd3584 | 6 | int_or_none, |
f17e4c9c | 7 | unified_strdate, |
fa7a1cc5 | 8 | js_to_json, |
400afdda | 9 | ) |
10 | ||
ce363395 | 11 | |
f17e4c9c | 12 | class ScreenwaveMediaIE(InfoExtractor): |
7a012d5a | 13 | _VALID_URL = r'http://player\d?\.screenwavemedia\.com/(?:play/)?[a-zA-Z]+\.php\?[^"]*\bid=(?P<id>.+)' |
ce363395 | 14 | |
f17e4c9c PH |
15 | _TESTS = [{ |
16 | 'url': 'http://player.screenwavemedia.com/play/play.php?playerdiv=videoarea&companiondiv=squareAd&id=Cinemassacre-19911', | |
17 | 'only_matching': True, | |
18 | }] | |
68471207 | 19 | |
f17e4c9c PH |
20 | def _real_extract(self, url): |
21 | video_id = self._match_id(url) | |
7a012d5a S |
22 | |
23 | playerdata = self._download_webpage( | |
fa7a1cc5 | 24 | 'http://player.screenwavemedia.com/player.php?id=%s' % video_id, |
7a012d5a | 25 | video_id, 'Downloading player webpage') |
68471207 | 26 | |
27 | vidtitle = self._search_regex( | |
f17e4c9c | 28 | r'\'vidtitle\'\s*:\s*"([^"]+)"', playerdata, 'vidtitle').replace('\\/', '/') |
fa7a1cc5 | 29 | |
30 | playerconfig = self._download_webpage( | |
31 | 'http://player.screenwavemedia.com/player.js', | |
32 | video_id, 'Downloading playerconfig webpage') | |
33 | ||
9cc93c64 | 34 | videoserver = self._search_regex(r"\[ipaddress\]\s*=>\s*([\d\.]+)", playerdata, 'videoserver') |
fa7a1cc5 | 35 | |
36 | sources = self._parse_json( | |
37 | js_to_json( | |
38 | self._search_regex( | |
39 | r"sources\s*:\s*(\[[^\]]+?\])", playerconfig, | |
40 | 'sources', | |
41 | ).replace( | |
42 | "' + thisObj.options.videoserver + '", | |
43 | videoserver | |
44 | ).replace( | |
45 | "' + playerVidId + '", | |
46 | video_id | |
47 | ) | |
48 | ), | |
49 | video_id | |
50 | ) | |
51 | ||
52 | formats = [] | |
53 | for source in sources: | |
54 | if source['type'] == 'hls': | |
55 | formats.extend(self._extract_m3u8_formats(source['file'], video_id)) | |
56 | else: | |
57 | format_label = source.get('label') | |
58 | height = int_or_none(self._search_regex( | |
59 | r'^(\d+)[pP]', format_label, 'height', default=None)) | |
60 | formats.append({ | |
61 | 'url': source['file'], | |
62 | 'format': format_label, | |
63 | 'ext': source.get('type'), | |
64 | 'height': height, | |
65 | }) | |
f17e4c9c | 66 | self._sort_formats(formats) |
400afdda | 67 | |
fcc28edb | 68 | return { |
8032e31f | 69 | 'id': video_id, |
68471207 | 70 | 'title': vidtitle, |
8032e31f | 71 | 'formats': formats, |
8032e31f | 72 | } |
68471207 | 73 | |
f17e4c9c | 74 | |
f17e4c9c PH |
75 | class TeamFourIE(InfoExtractor): |
76 | _VALID_URL = r'https?://(?:www\.)?teamfourstar\.com/video/(?P<id>[a-z0-9\-]+)/?' | |
77 | _TEST = { | |
78 | 'url': 'http://teamfourstar.com/video/a-moment-with-tfs-episode-4/', | |
79 | 'info_dict': { | |
80 | 'id': 'TeamFourStar-5292a02f20bfa', | |
81 | 'ext': 'mp4', | |
82 | 'upload_date': '20130401', | |
83 | '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', | |
84 | 'title': 'A Moment With TFS Episode 4', | |
85 | } | |
86 | } | |
68471207 | 87 | |
f17e4c9c PH |
88 | def _real_extract(self, url): |
89 | display_id = self._match_id(url) | |
90 | webpage = self._download_webpage(url, display_id) | |
91 | ||
92 | playerdata_url = self._search_regex( | |
7a012d5a | 93 | r'src="(http://player\d?\.screenwavemedia\.com/(?:play/)?[a-zA-Z]+\.php\?[^"]*\bid=.+?)"', |
f17e4c9c PH |
94 | webpage, 'player data URL') |
95 | ||
96 | video_title = self._html_search_regex( | |
97 | r'<div class="heroheadingtitle">(?P<title>.+?)</div>', | |
98 | webpage, 'title') | |
99 | video_date = unified_strdate(self._html_search_regex( | |
100 | r'<div class="heroheadingdate">(?P<date>.+?)</div>', | |
101 | webpage, 'date', fatal=False)) | |
102 | video_description = self._html_search_regex( | |
103 | r'(?s)<div class="postcontent">(?P<description>.+?)</div>', | |
104 | webpage, 'description', fatal=False) | |
105 | video_thumbnail = self._og_search_thumbnail(webpage) | |
68471207 | 106 | |
f17e4c9c PH |
107 | return { |
108 | '_type': 'url_transparent', | |
109 | 'display_id': display_id, | |
110 | 'title': video_title, | |
111 | 'description': video_description, | |
112 | 'upload_date': video_date, | |
113 | 'thumbnail': video_thumbnail, | |
114 | 'url': playerdata_url, | |
115 | } |