]>
Commit | Line | Data |
---|---|---|
400afdda | 1 | # encoding: utf-8 |
5bb67dbf | 2 | from __future__ import unicode_literals |
d9dd3584 | 3 | |
400afdda | 4 | import re |
5 | ||
6 | from .common import InfoExtractor | |
7 | from ..utils import ( | |
d9dd3584 | 8 | int_or_none, |
f17e4c9c | 9 | unified_strdate, |
400afdda | 10 | ) |
11 | ||
ce363395 | 12 | |
f17e4c9c | 13 | class ScreenwaveMediaIE(InfoExtractor): |
7a012d5a | 14 | _VALID_URL = r'http://player\d?\.screenwavemedia\.com/(?:play/)?[a-zA-Z]+\.php\?[^"]*\bid=(?P<id>.+)' |
ce363395 | 15 | |
f17e4c9c PH |
16 | _TESTS = [{ |
17 | 'url': 'http://player.screenwavemedia.com/play/play.php?playerdiv=videoarea&companiondiv=squareAd&id=Cinemassacre-19911', | |
18 | 'only_matching': True, | |
19 | }] | |
68471207 | 20 | |
f17e4c9c PH |
21 | def _real_extract(self, url): |
22 | video_id = self._match_id(url) | |
7a012d5a S |
23 | |
24 | playerdata = self._download_webpage( | |
25 | 'http://player.screenwavemedia.com/play/player.php?id=%s' % video_id, | |
26 | video_id, 'Downloading player webpage') | |
68471207 | 27 | |
28 | vidtitle = self._search_regex( | |
f17e4c9c | 29 | r'\'vidtitle\'\s*:\s*"([^"]+)"', playerdata, 'vidtitle').replace('\\/', '/') |
8f3b5397 | 30 | vidurl = self._search_regex( |
f17e4c9c | 31 | r'\'vidurl\'\s*:\s*"([^"]+)"', playerdata, 'vidurl').replace('\\/', '/') |
8f3b5397 | 32 | |
dab647a7 | 33 | videolist_url = None |
d9dd3584 | 34 | |
dab647a7 S |
35 | mobj = re.search(r"'videoserver'\s*:\s*'(?P<videoserver>[^']+)'", playerdata) |
36 | if mobj: | |
37 | videoserver = mobj.group('videoserver') | |
38 | mobj = re.search(r'\'vidid\'\s*:\s*"(?P<vidid>[^\']+)"', playerdata) | |
68471207 | 39 | vidid = mobj.group('vidid') if mobj else video_id |
dab647a7 S |
40 | videolist_url = 'http://%s/vod/smil:%s.smil/jwplayer.smil' % (videoserver, vidid) |
41 | else: | |
42 | mobj = re.search(r"file\s*:\s*'(?P<smil>http.+?/jwplayer\.smil)'", playerdata) | |
43 | if mobj: | |
44 | videolist_url = mobj.group('smil') | |
45 | ||
46 | if videolist_url: | |
47 | videolist = self._download_xml(videolist_url, video_id, 'Downloading videolist XML') | |
48 | formats = [] | |
2514d263 | 49 | baseurl = vidurl[:vidurl.rfind('/') + 1] |
dab647a7 S |
50 | for video in videolist.findall('.//video'): |
51 | src = video.get('src') | |
52 | if not src: | |
53 | continue | |
54 | file_ = src.partition(':')[-1] | |
55 | width = int_or_none(video.get('width')) | |
56 | height = int_or_none(video.get('height')) | |
f17e4c9c | 57 | bitrate = int_or_none(video.get('system-bitrate'), scale=1000) |
dab647a7 S |
58 | format = { |
59 | 'url': baseurl + file_, | |
60 | 'format_id': src.rpartition('.')[0].rpartition('_')[-1], | |
61 | } | |
62 | if width or height: | |
63 | format.update({ | |
f17e4c9c | 64 | 'tbr': bitrate, |
dab647a7 S |
65 | 'width': width, |
66 | 'height': height, | |
67 | }) | |
68 | else: | |
69 | format.update({ | |
f17e4c9c | 70 | 'abr': bitrate, |
dab647a7 S |
71 | 'vcodec': 'none', |
72 | }) | |
73 | formats.append(format) | |
dab647a7 S |
74 | else: |
75 | formats = [{ | |
76 | 'url': vidurl, | |
77 | }] | |
f17e4c9c | 78 | self._sort_formats(formats) |
400afdda | 79 | |
fcc28edb | 80 | return { |
8032e31f | 81 | 'id': video_id, |
68471207 | 82 | 'title': vidtitle, |
8032e31f | 83 | 'formats': formats, |
8032e31f | 84 | } |
68471207 | 85 | |
f17e4c9c | 86 | |
f17e4c9c PH |
87 | class TeamFourIE(InfoExtractor): |
88 | _VALID_URL = r'https?://(?:www\.)?teamfourstar\.com/video/(?P<id>[a-z0-9\-]+)/?' | |
89 | _TEST = { | |
90 | 'url': 'http://teamfourstar.com/video/a-moment-with-tfs-episode-4/', | |
91 | 'info_dict': { | |
92 | 'id': 'TeamFourStar-5292a02f20bfa', | |
93 | 'ext': 'mp4', | |
94 | 'upload_date': '20130401', | |
95 | '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', | |
96 | 'title': 'A Moment With TFS Episode 4', | |
97 | } | |
98 | } | |
68471207 | 99 | |
f17e4c9c PH |
100 | def _real_extract(self, url): |
101 | display_id = self._match_id(url) | |
102 | webpage = self._download_webpage(url, display_id) | |
103 | ||
104 | playerdata_url = self._search_regex( | |
7a012d5a | 105 | r'src="(http://player\d?\.screenwavemedia\.com/(?:play/)?[a-zA-Z]+\.php\?[^"]*\bid=.+?)"', |
f17e4c9c PH |
106 | webpage, 'player data URL') |
107 | ||
108 | video_title = self._html_search_regex( | |
109 | r'<div class="heroheadingtitle">(?P<title>.+?)</div>', | |
110 | webpage, 'title') | |
111 | video_date = unified_strdate(self._html_search_regex( | |
112 | r'<div class="heroheadingdate">(?P<date>.+?)</div>', | |
113 | webpage, 'date', fatal=False)) | |
114 | video_description = self._html_search_regex( | |
115 | r'(?s)<div class="postcontent">(?P<description>.+?)</div>', | |
116 | webpage, 'description', fatal=False) | |
117 | video_thumbnail = self._og_search_thumbnail(webpage) | |
68471207 | 118 | |
f17e4c9c PH |
119 | return { |
120 | '_type': 'url_transparent', | |
121 | 'display_id': display_id, | |
122 | 'title': video_title, | |
123 | 'description': video_description, | |
124 | 'upload_date': video_date, | |
125 | 'thumbnail': video_thumbnail, | |
126 | 'url': playerdata_url, | |
127 | } |