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.

51 lines
1.8 KiB

  1. import re
  2. import os
  3. from .common import InfoExtractor
  4. class PyvideoIE(InfoExtractor):
  5. _VALID_URL = r'(?:http://)?(?:www\.)?pyvideo\.org/video/(?P<id>\d+)/(.*)'
  6. _TESTS = [{
  7. u'url': u'http://pyvideo.org/video/1737/become-a-logging-expert-in-30-minutes',
  8. u'file': u'24_4WWkSmNo.mp4',
  9. u'md5': u'de317418c8bc76b1fd8633e4f32acbc6',
  10. u'info_dict': {
  11. u"title": u"Become a logging expert in 30 minutes",
  12. u"description": u"md5:9665350d466c67fb5b1598de379021f7",
  13. u"upload_date": u"20130320",
  14. u"uploader": u"NextDayVideo",
  15. u"uploader_id": u"NextDayVideo",
  16. },
  17. u'add_ie': ['Youtube'],
  18. },
  19. {
  20. u'url': u'http://pyvideo.org/video/2542/gloriajw-spotifywitherikbernhardsson182m4v',
  21. u'md5': u'5fe1c7e0a8aa5570330784c847ff6d12',
  22. u'info_dict': {
  23. u'id': u'2542',
  24. u'ext': u'm4v',
  25. u'title': u'Gloriajw-SpotifyWithErikBernhardsson182',
  26. },
  27. },
  28. ]
  29. def _real_extract(self, url):
  30. mobj = re.match(self._VALID_URL, url)
  31. video_id = mobj.group('id')
  32. webpage = self._download_webpage(url, video_id)
  33. m_youtube = re.search(r'(https?://www\.youtube\.com/watch\?v=.*)', webpage)
  34. if m_youtube is not None:
  35. return self.url_result(m_youtube.group(1), 'Youtube')
  36. title = self._html_search_regex(r'<div class="section">.*?<h3>([^>]+?)</h3>',
  37. webpage, u'title', flags=re.DOTALL)
  38. video_url = self._search_regex([r'<source src="(.*?)"',
  39. r'<dt>Download</dt>.*?<a href="(.+?)"'],
  40. webpage, u'video url', flags=re.DOTALL)
  41. return {
  42. 'id': video_id,
  43. 'title': os.path.splitext(title)[0],
  44. 'url': video_url,
  45. }