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.

70 lines
2.1 KiB

  1. # encoding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. unified_strdate,
  7. clean_html,
  8. int_or_none,
  9. )
  10. class TvigleIE(InfoExtractor):
  11. IE_NAME = 'tvigle'
  12. IE_DESC = 'Интернет-телевидение Tvigle.ru'
  13. _VALID_URL = r'http://(?:www\.)?tvigle\.ru/category/.+?video=(?P<id>\d+)'
  14. _TEST = {
  15. 'url': 'http://www.tvigle.ru/category/cinema/1608/?video=503081',
  16. 'md5': '09afba4616666249f087efc6dcf83cb3',
  17. 'info_dict': {
  18. 'id': '503081',
  19. 'ext': 'flv',
  20. 'title': 'Брат 2 ',
  21. 'description': 'md5:f5a42970f50648cee3d7ad740f3ae769',
  22. 'upload_date': '20110919',
  23. }
  24. }
  25. def _real_extract(self, url):
  26. mobj = re.match(self._VALID_URL, url)
  27. video_id = mobj.group('id')
  28. video_data = self._download_xml(
  29. 'http://www.tvigle.ru/xml/single.php?obj=%s' % video_id, video_id, 'Downloading video XML')
  30. video = video_data.find('./video')
  31. title = video.get('name')
  32. description = video.get('anons')
  33. if description:
  34. description = clean_html(description)
  35. thumbnail = video_data.get('img')
  36. upload_date = unified_strdate(video.get('date'))
  37. like_count = int_or_none(video.get('vtp'))
  38. formats = []
  39. for num, (format_id, format_note) in enumerate([['low_file', 'SQ'], ['file', 'HQ'], ['hd', 'HD 720']]):
  40. video_url = video.get(format_id)
  41. if not video_url:
  42. continue
  43. formats.append({
  44. 'url': video_url,
  45. 'format_id': format_id,
  46. 'format_note': format_note,
  47. 'quality': num,
  48. })
  49. self._sort_formats(formats)
  50. return {
  51. 'id': video_id,
  52. 'title': title,
  53. 'description': description,
  54. 'thumbnail': thumbnail,
  55. 'upload_date': upload_date,
  56. 'like_count': like_count,
  57. 'age_limit': 18,
  58. 'formats': formats,
  59. }