godtube.py 1.7 KB

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