screenwavemedia.py 7.6 KB

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