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.

40 lines
1.3 KiB

11 years ago
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. from .common import InfoExtractor
  3. from ..utils import xpath_text
  4. class TruTubeIE(InfoExtractor):
  5. _VALID_URL = r'https?://(?:www\.)?trutube\.tv/(?:video/|nuevo/player/embed\.php\?v=)(?P<id>[0-9]+)'
  6. _TESTS = [{
  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. 'url': 'https://trutube.tv/nuevo/player/embed.php?v=14880',
  17. 'only_matching': True,
  18. }]
  19. def _real_extract(self, url):
  20. video_id = self._match_id(url)
  21. config = self._download_xml(
  22. 'https://trutube.tv/nuevo/player/config.php?v=%s' % video_id,
  23. video_id, transform_source=lambda s: s.strip())
  24. # filehd is always 404
  25. video_url = xpath_text(config, './file', 'video URL', fatal=True)
  26. title = xpath_text(config, './title', 'title').strip()
  27. thumbnail = xpath_text(config, './image', ' thumbnail')
  28. return {
  29. 'id': video_id,
  30. 'url': video_url,
  31. 'title': title,
  32. 'thumbnail': thumbnail,
  33. }