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.

62 lines
1.8 KiB

11 years ago
11 years ago
  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. parse_duration,
  6. )
  7. class LA7IE(InfoExtractor):
  8. IE_NAME = 'la7.tv'
  9. _VALID_URL = r'''(?x)
  10. https?://(?:www\.)?la7\.tv/
  11. (?:
  12. richplayer/\?assetid=|
  13. \?contentId=
  14. )
  15. (?P<id>[0-9]+)'''
  16. _TEST = {
  17. 'url': 'http://www.la7.tv/richplayer/?assetid=50355319',
  18. 'file': '50355319.mp4',
  19. 'md5': 'ec7d1f0224d20ba293ab56cf2259651f',
  20. 'info_dict': {
  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. }
  26. def _real_extract(self, url):
  27. mobj = re.match(self._VALID_URL, url)
  28. video_id = mobj.group('id')
  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. }