trutube.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import re
  2. from .common import InfoExtractor
  3. from ..utils import (
  4. ExtractorError,
  5. )
  6. class TruTubeIE(InfoExtractor):
  7. _VALID_URL = r'(?:https?://)?(?:www\.)?(?P<url>trutube\.tv/video/(?P<videoid>.*/.*))'
  8. _TEST = {
  9. 'url': ('http://www.trutube.tv/video/20814/Ernst-Zundel-met-les-Jui'
  10. 'fs-en-guarde-VOSTFR'),
  11. 'md5': '9973aa3c2870626799d2ac4e36cfc3dc',
  12. 'info_dict': {
  13. u"title": u"TruTube.TV - Spitting in the face of die-versity",
  14. u"ext": u"mp4"
  15. }
  16. }
  17. def _real_extract(self, url):
  18. mobj = re.match(self._VALID_URL, url)
  19. video_id = mobj.group('videoid')
  20. # Get webpage content
  21. webpage = self._download_webpage(url, video_id)
  22. # Get the video title
  23. video_title = self._html_search_regex(r'<title>(?P<title>.*)</title>',
  24. webpage, 'title').strip()
  25. video_url = self._search_regex(r'(http://.*\.(?:mp4|flv))',
  26. webpage, u'video URL')
  27. ext = video_url[-3:]
  28. return {
  29. 'id': video_id,
  30. 'url': video_url,
  31. 'title': video_title,
  32. 'ext': ext
  33. }