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
2.1 KiB

10 years ago
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. float_or_none,
  6. )
  7. class RteIE(InfoExtractor):
  8. _VALID_URL = r'https?://(?:www\.)?rte\.ie/player/[^/]{2,3}/show/[^/]+/(?P<id>[0-9]+)'
  9. _TEST = {
  10. 'url': 'http://www.rte.ie/player/ie/show/iwitness-862/10478715/',
  11. 'info_dict': {
  12. 'id': '10478715',
  13. 'ext': 'mp4',
  14. 'title': 'Watch iWitness online',
  15. 'thumbnail': 're:^https?://.*\.jpg$',
  16. 'description': 'iWitness : The spirit of Ireland, one voice and one minute at a time.',
  17. 'duration': 60.046,
  18. },
  19. 'params': {
  20. 'skip_download': 'f4m fails with --test atm'
  21. }
  22. }
  23. def _real_extract(self, url):
  24. video_id = self._match_id(url)
  25. webpage = self._download_webpage(url, video_id)
  26. title = self._og_search_title(webpage)
  27. description = self._html_search_meta('description', webpage, 'description')
  28. duration = float_or_none(self._html_search_meta(
  29. 'duration', webpage, 'duration', fatal=False), 1000)
  30. thumbnail_id = self._search_regex(
  31. r'<meta name="thumbnail" content="uri:irus:(.*?)" />', webpage, 'thumbnail')
  32. thumbnail = 'http://img.rasset.ie/' + thumbnail_id + '.jpg'
  33. feeds_url = self._html_search_meta("feeds-prefix", webpage, 'feeds url') + video_id
  34. json_string = self._download_json(feeds_url, video_id)
  35. # f4m_url = server + relative_url
  36. f4m_url = json_string['shows'][0]['media:group'][0]['rte:server'] + json_string['shows'][0]['media:group'][0]['url']
  37. f4m_formats = self._extract_f4m_formats(f4m_url, video_id)
  38. f4m_formats = [{
  39. 'format_id': f['format_id'],
  40. 'url': f['url'],
  41. 'ext': 'mp4',
  42. 'width': f['width'],
  43. 'height': f['height'],
  44. } for f in f4m_formats]
  45. return {
  46. 'id': video_id,
  47. 'title': title,
  48. 'formats': f4m_formats,
  49. 'description': description,
  50. 'thumbnail': thumbnail,
  51. 'duration': duration,
  52. }