You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

180 lines
6.8 KiB

10 years ago
  1. # encoding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. ExtractorError,
  7. int_or_none,
  8. month_by_name,
  9. unified_strdate,
  10. )
  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. def _real_extract(self, url):
  99. mobj = re.match(self._VALID_URL, url)
  100. display_id = mobj.group('display_id')
  101. video_date = mobj.group('date_y') + mobj.group('date_m') + mobj.group('date_d')
  102. webpage = self._download_webpage(url, display_id)
  103. playerdata_url = self._search_regex(
  104. r'src="(http://player\.screenwavemedia\.com/play/[a-zA-Z]+\.php\?[^"]*\bid=.+?)"',
  105. webpage, 'player data URL')
  106. video_title = self._html_search_regex(
  107. r'<title>(?P<title>.+?)\|', webpage, 'title')
  108. video_description = self._html_search_regex(
  109. r'<div class="entry-content">(?P<description>.+?)</div>',
  110. webpage, 'description', flags=re.DOTALL, fatal=False)
  111. video_thumbnail = self._og_search_thumbnail(webpage)
  112. return {
  113. '_type': 'url_transparent',
  114. 'display_id': display_id,
  115. 'title': video_title,
  116. 'description': video_description,
  117. 'upload_date': video_date,
  118. 'thumbnail': video_thumbnail,
  119. 'url': playerdata_url,
  120. }
  121. class TeamFourIE(InfoExtractor):
  122. _VALID_URL = r'https?://(?:www\.)?teamfourstar\.com/video/(?P<id>[a-z0-9\-]+)/?'
  123. _TEST = {
  124. 'url': 'http://teamfourstar.com/video/a-moment-with-tfs-episode-4/',
  125. 'info_dict': {
  126. 'id': 'TeamFourStar-5292a02f20bfa',
  127. 'ext': 'mp4',
  128. 'upload_date': '20130401',
  129. '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',
  130. 'title': 'A Moment With TFS Episode 4',
  131. }
  132. }
  133. def _real_extract(self, url):
  134. display_id = self._match_id(url)
  135. webpage = self._download_webpage(url, display_id)
  136. playerdata_url = self._search_regex(
  137. r'src="(http://player\.screenwavemedia\.com/play/[a-zA-Z]+\.php\?[^"]*\bid=.+?)"',
  138. webpage, 'player data URL')
  139. video_title = self._html_search_regex(
  140. r'<div class="heroheadingtitle">(?P<title>.+?)</div>',
  141. webpage, 'title')
  142. video_date = unified_strdate(self._html_search_regex(
  143. r'<div class="heroheadingdate">(?P<date>.+?)</div>',
  144. webpage, 'date', fatal=False))
  145. video_description = self._html_search_regex(
  146. r'(?s)<div class="postcontent">(?P<description>.+?)</div>',
  147. webpage, 'description', fatal=False)
  148. video_thumbnail = self._og_search_thumbnail(webpage)
  149. return {
  150. '_type': 'url_transparent',
  151. 'display_id': display_id,
  152. 'title': video_title,
  153. 'description': video_description,
  154. 'upload_date': video_date,
  155. 'thumbnail': video_thumbnail,
  156. 'url': playerdata_url,
  157. }