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.

44 lines
1.4 KiB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. class TruTubeIE(InfoExtractor):
  5. _VALID_URL = r'https?://(?:www\.)?trutube\.tv/video/(?P<id>[0-9]+)/.*'
  6. _TEST = {
  7. 'url': 'http://trutube.tv/video/14880/Ramses-II-Proven-To-Be-A-Red-Headed-Caucasoid-',
  8. 'md5': 'c5b6e301b0a2040b074746cbeaa26ca1',
  9. 'info_dict': {
  10. 'id': '14880',
  11. 'ext': 'flv',
  12. 'title': 'Ramses II - Proven To Be A Red Headed Caucasoid',
  13. 'thumbnail': 're:^http:.*\.jpg$',
  14. }
  15. }
  16. def _real_extract(self, url):
  17. mobj = re.match(self._VALID_URL, url)
  18. video_id = mobj.group('id')
  19. webpage = self._download_webpage(url, video_id)
  20. video_title = self._og_search_title(webpage).strip()
  21. thumbnail = self._search_regex(
  22. r"var splash_img = '([^']+)';", webpage, 'thumbnail', fatal=False)
  23. all_formats = re.finditer(
  24. r"var (?P<key>[a-z]+)_video_file\s*=\s*'(?P<url>[^']+)';", webpage)
  25. formats = [{
  26. 'format_id': m.group('key'),
  27. 'quality': -i,
  28. 'url': m.group('url'),
  29. } for i, m in enumerate(all_formats)]
  30. self._sort_formats(formats)
  31. return {
  32. 'id': video_id,
  33. 'title': video_title,
  34. 'formats': formats,
  35. 'thumbnail': thumbnail,
  36. }