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.

145 lines
5.4KB

  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. js_to_json,
  9. )
  10. class ScreenwaveMediaIE(InfoExtractor):
  11. _VALID_URL = r'https?://player\d?\.screenwavemedia\.com/(?:play/)?[a-zA-Z]+\.php\?.*\bid=(?P<id>[A-Za-z0-9-]+)'
  12. EMBED_PATTERN = r'src=(["\'])(?P<url>(?:https?:)?//player\d?\.screenwavemedia\.com/(?:play/)?[a-zA-Z]+\.php\?.*\bid=.+?)\1'
  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(
  20. 'http://player.screenwavemedia.com/player.php?id=%s' % video_id,
  21. video_id, 'Downloading player webpage')
  22. vidtitle = self._search_regex(
  23. r'\'vidtitle\'\s*:\s*"([^"]+)"', playerdata, 'vidtitle').replace('\\/', '/')
  24. playerconfig = self._download_webpage(
  25. 'http://player.screenwavemedia.com/player.js',
  26. video_id, 'Downloading playerconfig webpage')
  27. videoserver = self._search_regex(r'SWMServer\s*=\s*"([\d\.]+)"', playerdata, 'videoserver')
  28. sources = self._parse_json(
  29. js_to_json(
  30. re.sub(
  31. r'(?s)/\*.*?\*/', '',
  32. self._search_regex(
  33. r'sources\s*:\s*(\[[^\]]+?\])', playerconfig,
  34. 'sources',
  35. ).replace(
  36. "' + thisObj.options.videoserver + '",
  37. videoserver
  38. ).replace(
  39. "' + playerVidId + '",
  40. video_id
  41. )
  42. )
  43. ),
  44. video_id, fatal=False
  45. )
  46. # Fallback to hardcoded sources if JS changes again
  47. if not sources:
  48. self.report_warning('Falling back to a hardcoded list of streams')
  49. sources = [{
  50. 'file': 'http://%s/vod/%s_%s.mp4' % (videoserver, video_id, format_id),
  51. 'type': 'mp4',
  52. 'label': format_label,
  53. } for format_id, format_label in (
  54. ('low', '144p Low'), ('med', '160p Med'), ('high', '360p High'), ('hd1', '720p HD1'))]
  55. sources.append({
  56. 'file': 'http://%s/vod/smil:%s.smil/playlist.m3u8' % (videoserver, video_id),
  57. 'type': 'hls',
  58. })
  59. formats = []
  60. for source in sources:
  61. if source['type'] == 'hls':
  62. formats.extend(self._extract_m3u8_formats(source['file'], video_id, ext='mp4'))
  63. else:
  64. file_ = source.get('file')
  65. if not file_:
  66. continue
  67. format_label = source.get('label')
  68. format_id = self._search_regex(
  69. r'_(.+?)\.[^.]+$', file_, 'format id', default=None)
  70. height = int_or_none(self._search_regex(
  71. r'^(\d+)[pP]', format_label, 'height', default=None))
  72. formats.append({
  73. 'url': source['file'],
  74. 'format_id': format_id,
  75. 'format': format_label,
  76. 'ext': source.get('type'),
  77. 'height': height,
  78. })
  79. self._sort_formats(formats)
  80. return {
  81. 'id': video_id,
  82. 'title': vidtitle,
  83. 'formats': formats,
  84. }
  85. class TeamFourIE(InfoExtractor):
  86. _VALID_URL = r'https?://(?:www\.)?teamfourstar\.com/video/(?P<id>[a-z0-9\-]+)/?'
  87. _TEST = {
  88. 'url': 'http://teamfourstar.com/video/a-moment-with-tfs-episode-4/',
  89. 'info_dict': {
  90. 'id': 'TeamFourStar-5292a02f20bfa',
  91. 'ext': 'mp4',
  92. 'upload_date': '20130401',
  93. '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',
  94. 'title': 'A Moment With TFS Episode 4',
  95. },
  96. 'params': {
  97. # m3u8 download
  98. 'skip_download': True,
  99. },
  100. }
  101. def _real_extract(self, url):
  102. display_id = self._match_id(url)
  103. webpage = self._download_webpage(url, display_id)
  104. playerdata_url = self._search_regex(
  105. r'src="(http://player\d?\.screenwavemedia\.com/(?:play/)?[a-zA-Z]+\.php\?[^"]*\bid=.+?)"',
  106. webpage, 'player data URL')
  107. video_title = self._html_search_regex(
  108. r'<div class="heroheadingtitle">(?P<title>.+?)</div>',
  109. webpage, 'title')
  110. video_date = unified_strdate(self._html_search_regex(
  111. r'<div class="heroheadingdate">(?P<date>.+?)</div>',
  112. webpage, 'date', fatal=False))
  113. video_description = self._html_search_regex(
  114. r'(?s)<div class="postcontent">(?P<description>.+?)</div>',
  115. webpage, 'description', fatal=False)
  116. video_thumbnail = self._og_search_thumbnail(webpage)
  117. return {
  118. '_type': 'url_transparent',
  119. 'display_id': display_id,
  120. 'title': video_title,
  121. 'description': video_description,
  122. 'upload_date': video_date,
  123. 'thumbnail': video_thumbnail,
  124. 'url': playerdata_url,
  125. }