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.

58 lines
1.8 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. parse_duration,
  6. parse_iso8601,
  7. )
  8. class GodTubeIE(InfoExtractor):
  9. _VALID_URL = r'https?://(?:www\.)?godtube\.com/watch/\?v=(?P<id>[\da-zA-Z]+)'
  10. _TESTS = [
  11. {
  12. 'url': 'https://www.godtube.com/watch/?v=0C0CNNNU',
  13. 'md5': '77108c1e4ab58f48031101a1a2119789',
  14. 'info_dict': {
  15. 'id': '0C0CNNNU',
  16. 'ext': 'mp4',
  17. 'title': 'Woman at the well.',
  18. 'duration': 159,
  19. 'timestamp': 1205712000,
  20. 'uploader': 'beverlybmusic',
  21. 'upload_date': '20080317',
  22. 'thumbnail': 're:^https?://.*\.jpg$',
  23. },
  24. },
  25. ]
  26. def _real_extract(self, url):
  27. mobj = re.match(self._VALID_URL, url)
  28. video_id = mobj.group('id')
  29. config = self._download_xml(
  30. 'http://www.godtube.com/resource/mediaplayer/%s.xml' % video_id.lower(),
  31. video_id, 'Downloading player config XML')
  32. video_url = config.find('.//file').text
  33. uploader = config.find('.//author').text
  34. timestamp = parse_iso8601(config.find('.//date').text)
  35. duration = parse_duration(config.find('.//duration').text)
  36. thumbnail = config.find('.//image').text
  37. media = self._download_xml(
  38. 'http://www.godtube.com/media/xml/?v=%s' % video_id, video_id, 'Downloading media XML')
  39. title = media.find('.//title').text
  40. return {
  41. 'id': video_id,
  42. 'url': video_url,
  43. 'title': title,
  44. 'thumbnail': thumbnail,
  45. 'timestamp': timestamp,
  46. 'uploader': uploader,
  47. 'duration': duration,
  48. }