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.

60 lines
1.8 KiB

11 years ago
11 years ago
10 years ago
11 years ago
11 years ago
10 years ago
11 years ago
  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. from ..utils import (
  4. parse_duration,
  5. )
  6. class LA7IE(InfoExtractor):
  7. IE_NAME = 'la7.tv'
  8. _VALID_URL = r'''(?x)
  9. https?://(?:www\.)?la7\.tv/
  10. (?:
  11. richplayer/\?assetid=|
  12. \?contentId=
  13. )
  14. (?P<id>[0-9]+)'''
  15. _TEST = {
  16. 'url': 'http://www.la7.tv/richplayer/?assetid=50355319',
  17. 'md5': 'ec7d1f0224d20ba293ab56cf2259651f',
  18. 'info_dict': {
  19. 'id': '50355319',
  20. 'ext': 'mp4',
  21. 'title': 'IL DIVO',
  22. 'description': 'Un film di Paolo Sorrentino con Toni Servillo, Anna Bonaiuto, Giulio Bosetti e Flavio Bucci',
  23. 'duration': 6254,
  24. },
  25. 'skip': 'Blocked in the US',
  26. }
  27. def _real_extract(self, url):
  28. video_id = self._match_id(url)
  29. xml_url = 'http://www.la7.tv/repliche/content/index.php?contentId=%s' % video_id
  30. doc = self._download_xml(xml_url, video_id)
  31. video_title = doc.find('title').text
  32. description = doc.find('description').text
  33. duration = parse_duration(doc.find('duration').text)
  34. thumbnail = doc.find('img').text
  35. view_count = int(doc.find('views').text)
  36. prefix = doc.find('.//fqdn').text.strip().replace('auto:', 'http:')
  37. formats = [{
  38. 'format': vnode.find('quality').text,
  39. 'tbr': int(vnode.find('quality').text),
  40. 'url': vnode.find('fms').text.strip().replace('mp4:', prefix),
  41. } for vnode in doc.findall('.//videos/video')]
  42. self._sort_formats(formats)
  43. return {
  44. 'id': video_id,
  45. 'title': video_title,
  46. 'description': description,
  47. 'thumbnail': thumbnail,
  48. 'duration': duration,
  49. 'formats': formats,
  50. 'view_count': view_count,
  51. }