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.

65 lines
2.0 KiB

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