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.

114 lines
4.2 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..compat import (
  5. compat_parse_qs,
  6. compat_urllib_request,
  7. )
  8. from ..utils import (
  9. ExtractorError,
  10. )
  11. class ScreencastIE(InfoExtractor):
  12. _VALID_URL = r'https?://(?:www\.)?screencast\.com/t/(?P<id>[a-zA-Z0-9]+)'
  13. _TESTS = [{
  14. 'url': 'http://www.screencast.com/t/3ZEjQXlT',
  15. 'md5': '917df1c13798a3e96211dd1561fded83',
  16. 'info_dict': {
  17. 'id': '3ZEjQXlT',
  18. 'ext': 'm4v',
  19. 'title': 'Color Measurement with Ocean Optics Spectrometers',
  20. 'description': 'md5:240369cde69d8bed61349a199c5fb153',
  21. 'thumbnail': r're:^https?://.*\.(?:gif|jpg)$',
  22. }
  23. }, {
  24. 'url': 'http://www.screencast.com/t/V2uXehPJa1ZI',
  25. 'md5': 'e8e4b375a7660a9e7e35c33973410d34',
  26. 'info_dict': {
  27. 'id': 'V2uXehPJa1ZI',
  28. 'ext': 'mov',
  29. 'title': 'The Amadeus Spectrometer',
  30. 'description': 're:^In this video, our friends at.*To learn more about Amadeus, visit',
  31. 'thumbnail': r're:^https?://.*\.(?:gif|jpg)$',
  32. }
  33. }, {
  34. 'url': 'http://www.screencast.com/t/aAB3iowa',
  35. 'md5': 'dedb2734ed00c9755761ccaee88527cd',
  36. 'info_dict': {
  37. 'id': 'aAB3iowa',
  38. 'ext': 'mp4',
  39. 'title': 'Google Earth Export',
  40. 'description': 'Provides a demo of a CommunityViz export to Google Earth, one of the 3D viewing options.',
  41. 'thumbnail': r're:^https?://.*\.(?:gif|jpg)$',
  42. }
  43. }, {
  44. 'url': 'http://www.screencast.com/t/X3ddTrYh',
  45. 'md5': '669ee55ff9c51988b4ebc0877cc8b159',
  46. 'info_dict': {
  47. 'id': 'X3ddTrYh',
  48. 'ext': 'wmv',
  49. 'title': 'Toolkit 6 User Group Webinar (2014-03-04) - Default Judgment and First Impression',
  50. 'description': 'md5:7b9f393bc92af02326a5c5889639eab0',
  51. 'thumbnail': r're:^https?://.*\.(?:gif|jpg)$',
  52. }
  53. }, {
  54. 'url': 'http://screencast.com/t/aAB3iowa',
  55. 'only_matching': True,
  56. }]
  57. def _real_extract(self, url):
  58. video_id = self._match_id(url)
  59. webpage = self._download_webpage(url, video_id)
  60. video_url = self._html_search_regex(
  61. r'<embed name="Video".*?src="([^"]+)"', webpage,
  62. 'QuickTime embed', default=None)
  63. if video_url is None:
  64. flash_vars_s = self._html_search_regex(
  65. r'<param name="flashVars" value="([^"]+)"', webpage, 'flash vars',
  66. default=None)
  67. if not flash_vars_s:
  68. flash_vars_s = self._html_search_regex(
  69. r'<param name="initParams" value="([^"]+)"', webpage, 'flash vars',
  70. default=None)
  71. if flash_vars_s:
  72. flash_vars_s = flash_vars_s.replace(',', '&')
  73. if flash_vars_s:
  74. flash_vars = compat_parse_qs(flash_vars_s)
  75. video_url_raw = compat_urllib_request.quote(
  76. flash_vars['content'][0])
  77. video_url = video_url_raw.replace('http%3A', 'http:')
  78. if video_url is None:
  79. video_meta = self._html_search_meta(
  80. 'og:video', webpage, default=None)
  81. if video_meta:
  82. video_url = self._search_regex(
  83. r'src=(.*?)(?:$|&)', video_meta,
  84. 'meta tag video URL', default=None)
  85. if video_url is None:
  86. raise ExtractorError('Cannot find video')
  87. title = self._og_search_title(webpage, default=None)
  88. if title is None:
  89. title = self._html_search_regex(
  90. [r'<b>Title:</b> ([^<]+)</div>',
  91. r'class="tabSeperator">></span><span class="tabText">(.+?)<',
  92. r'<title>([^<]+)</title>'],
  93. webpage, 'title')
  94. thumbnail = self._og_search_thumbnail(webpage)
  95. description = self._og_search_description(webpage, default=None)
  96. if description is None:
  97. description = self._html_search_meta('description', webpage)
  98. return {
  99. 'id': video_id,
  100. 'url': video_url,
  101. 'title': title,
  102. 'description': description,
  103. 'thumbnail': thumbnail,
  104. }