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.

127 lines
4.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\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/play/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. vidurl = self._search_regex(
  23. r'\'vidurl\'\s*:\s*"([^"]+)"', playerdata, 'vidurl').replace('\\/', '/')
  24. videolist_url = None
  25. mobj = re.search(r"'videoserver'\s*:\s*'(?P<videoserver>[^']+)'", playerdata)
  26. if mobj:
  27. videoserver = mobj.group('videoserver')
  28. mobj = re.search(r'\'vidid\'\s*:\s*"(?P<vidid>[^\']+)"', playerdata)
  29. vidid = mobj.group('vidid') if mobj else video_id
  30. videolist_url = 'http://%s/vod/smil:%s.smil/jwplayer.smil' % (videoserver, vidid)
  31. else:
  32. mobj = re.search(r"file\s*:\s*'(?P<smil>http.+?/jwplayer\.smil)'", playerdata)
  33. if mobj:
  34. videolist_url = mobj.group('smil')
  35. if videolist_url:
  36. videolist = self._download_xml(videolist_url, video_id, 'Downloading videolist XML')
  37. formats = []
  38. baseurl = vidurl[:vidurl.rfind('/') + 1]
  39. for video in videolist.findall('.//video'):
  40. src = video.get('src')
  41. if not src:
  42. continue
  43. file_ = src.partition(':')[-1]
  44. width = int_or_none(video.get('width'))
  45. height = int_or_none(video.get('height'))
  46. bitrate = int_or_none(video.get('system-bitrate'), scale=1000)
  47. format = {
  48. 'url': baseurl + file_,
  49. 'format_id': src.rpartition('.')[0].rpartition('_')[-1],
  50. }
  51. if width or height:
  52. format.update({
  53. 'tbr': bitrate,
  54. 'width': width,
  55. 'height': height,
  56. })
  57. else:
  58. format.update({
  59. 'abr': bitrate,
  60. 'vcodec': 'none',
  61. })
  62. formats.append(format)
  63. else:
  64. formats = [{
  65. 'url': vidurl,
  66. }]
  67. self._sort_formats(formats)
  68. return {
  69. 'id': video_id,
  70. 'title': vidtitle,
  71. 'formats': formats,
  72. }
  73. class TeamFourIE(InfoExtractor):
  74. _VALID_URL = r'https?://(?:www\.)?teamfourstar\.com/video/(?P<id>[a-z0-9\-]+)/?'
  75. _TEST = {
  76. 'url': 'http://teamfourstar.com/video/a-moment-with-tfs-episode-4/',
  77. 'info_dict': {
  78. 'id': 'TeamFourStar-5292a02f20bfa',
  79. 'ext': 'mp4',
  80. 'upload_date': '20130401',
  81. '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',
  82. 'title': 'A Moment With TFS Episode 4',
  83. }
  84. }
  85. def _real_extract(self, url):
  86. display_id = self._match_id(url)
  87. webpage = self._download_webpage(url, display_id)
  88. playerdata_url = self._search_regex(
  89. r'src="(http://player\d?\.screenwavemedia\.com/(?:play/)?[a-zA-Z]+\.php\?[^"]*\bid=.+?)"',
  90. webpage, 'player data URL')
  91. video_title = self._html_search_regex(
  92. r'<div class="heroheadingtitle">(?P<title>.+?)</div>',
  93. webpage, 'title')
  94. video_date = unified_strdate(self._html_search_regex(
  95. r'<div class="heroheadingdate">(?P<date>.+?)</div>',
  96. webpage, 'date', fatal=False))
  97. video_description = self._html_search_regex(
  98. r'(?s)<div class="postcontent">(?P<description>.+?)</div>',
  99. webpage, 'description', fatal=False)
  100. video_thumbnail = self._og_search_thumbnail(webpage)
  101. return {
  102. '_type': 'url_transparent',
  103. 'display_id': display_id,
  104. 'title': video_title,
  105. 'description': video_description,
  106. 'upload_date': video_date,
  107. 'thumbnail': video_thumbnail,
  108. 'url': playerdata_url,
  109. }