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.

83 lines
2.7 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/.+?[\?&]v(?:ideo)?=(?P<id>\d+)'
  14. _TESTS = [
  15. {
  16. 'url': 'http://www.tvigle.ru/category/cinema/1608/?video=503081',
  17. 'md5': '09afba4616666249f087efc6dcf83cb3',
  18. 'info_dict': {
  19. 'id': '503081',
  20. 'ext': 'flv',
  21. 'title': 'Брат 2 ',
  22. 'description': 'md5:f5a42970f50648cee3d7ad740f3ae769',
  23. 'upload_date': '20110919',
  24. },
  25. },
  26. {
  27. 'url': 'http://www.tvigle.ru/category/men/vysotskiy_vospominaniya02/?flt=196&v=676433',
  28. 'md5': 'e7efe5350dd5011d0de6550b53c3ba7b',
  29. 'info_dict': {
  30. 'id': '676433',
  31. 'ext': 'flv',
  32. 'title': 'Ведущий телепрограммы «60 минут» (США) о Владимире Высоцком',
  33. 'description': 'md5:027f7dc872948f14c96d19b4178428a4',
  34. 'upload_date': '20121218',
  35. },
  36. },
  37. ]
  38. def _real_extract(self, url):
  39. mobj = re.match(self._VALID_URL, url)
  40. video_id = mobj.group('id')
  41. video_data = self._download_xml(
  42. 'http://www.tvigle.ru/xml/single.php?obj=%s' % video_id, video_id, 'Downloading video XML')
  43. video = video_data.find('./video')
  44. title = video.get('name')
  45. description = video.get('anons')
  46. if description:
  47. description = clean_html(description)
  48. thumbnail = video_data.get('img')
  49. upload_date = unified_strdate(video.get('date'))
  50. like_count = int_or_none(video.get('vtp'))
  51. formats = []
  52. for num, (format_id, format_note) in enumerate([['low_file', 'SQ'], ['file', 'HQ'], ['hd', 'HD 720']]):
  53. video_url = video.get(format_id)
  54. if not video_url:
  55. continue
  56. formats.append({
  57. 'url': video_url,
  58. 'format_id': format_id,
  59. 'format_note': format_note,
  60. 'quality': num,
  61. })
  62. self._sort_formats(formats)
  63. return {
  64. 'id': video_id,
  65. 'title': title,
  66. 'description': description,
  67. 'thumbnail': thumbnail,
  68. 'upload_date': upload_date,
  69. 'like_count': like_count,
  70. 'age_limit': 18,
  71. 'formats': formats,
  72. }