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.

115 lines
4.1 KiB

  1. # encoding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. int_or_none,
  6. unified_strdate,
  7. js_to_json,
  8. )
  9. class ScreenwaveMediaIE(InfoExtractor):
  10. _VALID_URL = r'http://player\d?\.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(
  18. 'http://player.screenwavemedia.com/player.php?id=%s' % video_id,
  19. video_id, 'Downloading player webpage')
  20. vidtitle = self._search_regex(
  21. r'\'vidtitle\'\s*:\s*"([^"]+)"', playerdata, 'vidtitle').replace('\\/', '/')
  22. playerconfig = self._download_webpage(
  23. 'http://player.screenwavemedia.com/player.js',
  24. video_id, 'Downloading playerconfig webpage')
  25. videoserver = self._search_regex(r"\[ipaddress\]\s*=>\s*([\d\.]+)", playerdata, 'videoserver')
  26. sources = self._parse_json(
  27. js_to_json(
  28. self._search_regex(
  29. r"sources\s*:\s*(\[[^\]]+?\])", playerconfig,
  30. 'sources',
  31. ).replace(
  32. "' + thisObj.options.videoserver + '",
  33. videoserver
  34. ).replace(
  35. "' + playerVidId + '",
  36. video_id
  37. )
  38. ),
  39. video_id
  40. )
  41. formats = []
  42. for source in sources:
  43. if source['type'] == 'hls':
  44. formats.extend(self._extract_m3u8_formats(source['file'], video_id))
  45. else:
  46. format_label = source.get('label')
  47. height = int_or_none(self._search_regex(
  48. r'^(\d+)[pP]', format_label, 'height', default=None))
  49. formats.append({
  50. 'url': source['file'],
  51. 'format': format_label,
  52. 'ext': source.get('type'),
  53. 'height': height,
  54. })
  55. self._sort_formats(formats)
  56. return {
  57. 'id': video_id,
  58. 'title': vidtitle,
  59. 'formats': formats,
  60. }
  61. class TeamFourIE(InfoExtractor):
  62. _VALID_URL = r'https?://(?:www\.)?teamfourstar\.com/video/(?P<id>[a-z0-9\-]+)/?'
  63. _TEST = {
  64. 'url': 'http://teamfourstar.com/video/a-moment-with-tfs-episode-4/',
  65. 'info_dict': {
  66. 'id': 'TeamFourStar-5292a02f20bfa',
  67. 'ext': 'mp4',
  68. 'upload_date': '20130401',
  69. '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',
  70. 'title': 'A Moment With TFS Episode 4',
  71. }
  72. }
  73. def _real_extract(self, url):
  74. display_id = self._match_id(url)
  75. webpage = self._download_webpage(url, display_id)
  76. playerdata_url = self._search_regex(
  77. r'src="(http://player\d?\.screenwavemedia\.com/(?:play/)?[a-zA-Z]+\.php\?[^"]*\bid=.+?)"',
  78. webpage, 'player data URL')
  79. video_title = self._html_search_regex(
  80. r'<div class="heroheadingtitle">(?P<title>.+?)</div>',
  81. webpage, 'title')
  82. video_date = unified_strdate(self._html_search_regex(
  83. r'<div class="heroheadingdate">(?P<date>.+?)</div>',
  84. webpage, 'date', fatal=False))
  85. video_description = self._html_search_regex(
  86. r'(?s)<div class="postcontent">(?P<description>.+?)</div>',
  87. webpage, 'description', fatal=False)
  88. video_thumbnail = self._og_search_thumbnail(webpage)
  89. return {
  90. '_type': 'url_transparent',
  91. 'display_id': display_id,
  92. 'title': video_title,
  93. 'description': video_description,
  94. 'upload_date': video_date,
  95. 'thumbnail': video_thumbnail,
  96. 'url': playerdata_url,
  97. }