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.

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