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.

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