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.

63 lines
1.9 KiB

11 years ago
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. 'skip': 'Blocked in the US',
  26. }
  27. def _real_extract(self, url):
  28. mobj = re.match(self._VALID_URL, url)
  29. video_id = mobj.group('id')
  30. xml_url = 'http://www.la7.tv/repliche/content/index.php?contentId=%s' % video_id
  31. doc = self._download_xml(xml_url, video_id)
  32. video_title = doc.find('title').text
  33. description = doc.find('description').text
  34. duration = parse_duration(doc.find('duration').text)
  35. thumbnail = doc.find('img').text
  36. view_count = int(doc.find('views').text)
  37. prefix = doc.find('.//fqdn').text.strip().replace('auto:', 'http:')
  38. formats = [{
  39. 'format': vnode.find('quality').text,
  40. 'tbr': int(vnode.find('quality').text),
  41. 'url': vnode.find('fms').text.strip().replace('mp4:', prefix),
  42. } for vnode in doc.findall('.//videos/video')]
  43. self._sort_formats(formats)
  44. return {
  45. 'id': video_id,
  46. 'title': video_title,
  47. 'description': description,
  48. 'thumbnail': thumbnail,
  49. 'duration': duration,
  50. 'formats': formats,
  51. 'view_count': view_count,
  52. }