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.

139 lines
5.1 KiB

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