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.

82 lines
2.5 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. get_element_by_attribute,
  6. clean_html,
  7. )
  8. class TechTalksIE(InfoExtractor):
  9. _VALID_URL = r'https?://techtalks\.tv/talks/(?:[^/]+/)?(?P<id>\d+)'
  10. _TESTS = [{
  11. 'url': 'http://techtalks.tv/talks/learning-topic-models-going-beyond-svd/57758/',
  12. 'info_dict': {
  13. 'id': '57758',
  14. 'title': 'Learning Topic Models --- Going beyond SVD',
  15. },
  16. 'playlist': [
  17. {
  18. 'info_dict': {
  19. 'id': '57758',
  20. 'ext': 'flv',
  21. 'title': 'Learning Topic Models --- Going beyond SVD',
  22. },
  23. },
  24. {
  25. 'info_dict': {
  26. 'id': '57758-slides',
  27. 'ext': 'flv',
  28. 'title': 'Learning Topic Models --- Going beyond SVD',
  29. },
  30. },
  31. ],
  32. 'params': {
  33. # rtmp download
  34. 'skip_download': True,
  35. },
  36. }, {
  37. 'url': 'http://techtalks.tv/talks/57758',
  38. 'only_matching': True,
  39. }]
  40. def _real_extract(self, url):
  41. mobj = re.match(self._VALID_URL, url)
  42. talk_id = mobj.group('id')
  43. webpage = self._download_webpage(url, talk_id)
  44. rtmp_url = self._search_regex(
  45. r'netConnectionUrl: \'(.*?)\'', webpage, 'rtmp url')
  46. play_path = self._search_regex(
  47. r'href=\'(.*?)\' [^>]*id="flowplayer_presenter"',
  48. webpage, 'presenter play path')
  49. title = clean_html(get_element_by_attribute('class', 'title', webpage))
  50. video_info = {
  51. 'id': talk_id,
  52. 'title': title,
  53. 'url': rtmp_url,
  54. 'play_path': play_path,
  55. 'ext': 'flv',
  56. }
  57. m_slides = re.search(r'<a class="slides" href=\'(.*?)\'', webpage)
  58. if m_slides is None:
  59. return video_info
  60. else:
  61. return {
  62. '_type': 'playlist',
  63. 'id': talk_id,
  64. 'title': title,
  65. 'entries': [
  66. video_info,
  67. # The slides video
  68. {
  69. 'id': talk_id + '-slides',
  70. 'title': title,
  71. 'url': rtmp_url,
  72. 'play_path': m_slides.group(1),
  73. 'ext': 'flv',
  74. },
  75. ],
  76. }