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.

65 lines
2.1 KiB

10 years ago
  1. from __future__ import unicode_literals
  2. import re
  3. import base64
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. unified_strdate,
  7. int_or_none,
  8. )
  9. class VideoTtIE(InfoExtractor):
  10. _WORKING = False
  11. ID_NAME = 'video.tt'
  12. IE_DESC = 'video.tt - Your True Tube'
  13. _VALID_URL = r'http://(?:www\.)?video\.tt/(?:(?:video|embed)/|watch_video\.php\?v=)(?P<id>[\da-zA-Z]{9})'
  14. _TESTS = [{
  15. 'url': 'http://www.video.tt/watch_video.php?v=amd5YujV8',
  16. 'md5': 'b13aa9e2f267effb5d1094443dff65ba',
  17. 'info_dict': {
  18. 'id': 'amd5YujV8',
  19. 'ext': 'flv',
  20. 'title': 'Motivational video Change your mind in just 2.50 mins',
  21. 'description': '',
  22. 'upload_date': '20130827',
  23. 'uploader': 'joseph313',
  24. }
  25. }, {
  26. 'url': 'http://video.tt/embed/amd5YujV8',
  27. 'only_matching': True,
  28. }]
  29. def _real_extract(self, url):
  30. mobj = re.match(self._VALID_URL, url)
  31. video_id = mobj.group('id')
  32. settings = self._download_json(
  33. 'http://www.video.tt/player_control/settings.php?v=%s' % video_id, video_id,
  34. 'Downloading video JSON')['settings']
  35. video = settings['video_details']['video']
  36. formats = [
  37. {
  38. 'url': base64.b64decode(res['u'].encode('utf-8')).decode('utf-8'),
  39. 'ext': 'flv',
  40. 'format_id': res['l'],
  41. } for res in settings['res'] if res['u']
  42. ]
  43. return {
  44. 'id': video_id,
  45. 'title': video['title'],
  46. 'description': video['description'],
  47. 'thumbnail': settings['config']['thumbnail'],
  48. 'upload_date': unified_strdate(video['added']),
  49. 'uploader': video['owner'],
  50. 'view_count': int_or_none(video['view_count']),
  51. 'comment_count': None if video.get('comment_count') == '--' else int_or_none(video['comment_count']),
  52. 'like_count': int_or_none(video['liked']),
  53. 'dislike_count': int_or_none(video['disliked']),
  54. 'formats': formats,
  55. }