screenwavemedia.py 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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
  44. )
  45. formats = []
  46. for source in sources:
  47. if source['type'] == 'hls':
  48. formats.extend(self._extract_m3u8_formats(source['file'], video_id))
  49. else:
  50. format_label = source.get('label')
  51. height = int_or_none(self._search_regex(
  52. r'^(\d+)[pP]', format_label, 'height', default=None))
  53. formats.append({
  54. 'url': source['file'],
  55. 'format': format_label,
  56. 'ext': source.get('type'),
  57. 'height': height,
  58. })
  59. self._sort_formats(formats)
  60. return {
  61. 'id': video_id,
  62. 'title': vidtitle,
  63. 'formats': formats,
  64. }
  65. class TeamFourIE(InfoExtractor):
  66. _VALID_URL = r'https?://(?:www\.)?teamfourstar\.com/video/(?P<id>[a-z0-9\-]+)/?'
  67. _TEST = {
  68. 'url': 'http://teamfourstar.com/video/a-moment-with-tfs-episode-4/',
  69. 'info_dict': {
  70. 'id': 'TeamFourStar-5292a02f20bfa',
  71. 'ext': 'mp4',
  72. 'upload_date': '20130401',
  73. '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',
  74. 'title': 'A Moment With TFS Episode 4',
  75. }
  76. }
  77. def _real_extract(self, url):
  78. display_id = self._match_id(url)
  79. webpage = self._download_webpage(url, display_id)
  80. playerdata_url = self._search_regex(
  81. r'src="(http://player\d?\.screenwavemedia\.com/(?:play/)?[a-zA-Z]+\.php\?[^"]*\bid=.+?)"',
  82. webpage, 'player data URL')
  83. video_title = self._html_search_regex(
  84. r'<div class="heroheadingtitle">(?P<title>.+?)</div>',
  85. webpage, 'title')
  86. video_date = unified_strdate(self._html_search_regex(
  87. r'<div class="heroheadingdate">(?P<date>.+?)</div>',
  88. webpage, 'date', fatal=False))
  89. video_description = self._html_search_regex(
  90. r'(?s)<div class="postcontent">(?P<description>.+?)</div>',
  91. webpage, 'description', fatal=False)
  92. video_thumbnail = self._og_search_thumbnail(webpage)
  93. return {
  94. '_type': 'url_transparent',
  95. 'display_id': display_id,
  96. 'title': video_title,
  97. 'description': video_description,
  98. 'upload_date': video_date,
  99. 'thumbnail': video_thumbnail,
  100. 'url': playerdata_url,
  101. }