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.

79 lines
2.4 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. _TEST = {
  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. def _real_extract(self, url):
  38. mobj = re.match(self._VALID_URL, url)
  39. talk_id = mobj.group('id')
  40. webpage = self._download_webpage(url, talk_id)
  41. rtmp_url = self._search_regex(
  42. r'netConnectionUrl: \'(.*?)\'', webpage, 'rtmp url')
  43. play_path = self._search_regex(
  44. r'href=\'(.*?)\' [^>]*id="flowplayer_presenter"',
  45. webpage, 'presenter play path')
  46. title = clean_html(get_element_by_attribute('class', 'title', webpage))
  47. video_info = {
  48. 'id': talk_id,
  49. 'title': title,
  50. 'url': rtmp_url,
  51. 'play_path': play_path,
  52. 'ext': 'flv',
  53. }
  54. m_slides = re.search(r'<a class="slides" href=\'(.*?)\'', webpage)
  55. if m_slides is None:
  56. return video_info
  57. else:
  58. return {
  59. '_type': 'playlist',
  60. 'id': talk_id,
  61. 'title': title,
  62. 'entries': [
  63. video_info,
  64. # The slides video
  65. {
  66. 'id': talk_id + '-slides',
  67. 'title': title,
  68. 'url': rtmp_url,
  69. 'play_path': m_slides.group(1),
  70. 'ext': 'flv',
  71. },
  72. ],
  73. }