2
0

rte.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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'http?://(?:www\.)?rte\.ie/player/in/show/(?P<id>[0-9]+)/'
  9. _TEST = {
  10. 'url': 'http://www.rte.ie/player/in/show/10336191/',
  11. 'info_dict': {
  12. 'id': '10336191',
  13. 'ext': 'mp4',
  14. 'title': 'Nine News',
  15. 'thumbnail': 're:^https?://.*\.jpg$',
  16. 'description': 'The One O\'Clock News followed by Weather.',
  17. 'duration': 1622.963,
  18. }
  19. }
  20. def _real_extract(self, url):
  21. video_id = self._match_id(url)
  22. webpage = self._download_webpage(url, video_id)
  23. title = self._og_search_title(webpage)
  24. description = self._search_regex(r'<meta name="description" content="(.*?)" />', webpage, 'description')
  25. duration = float_or_none(self._html_search_meta('duration', webpage, 'duration'), 1000)
  26. thumbnail_id = self._search_regex(r'<meta name="thumbnail" content="uri:irus:(.*?)" />', webpage, 'thumbnail')
  27. thumbnail = 'http://img.rasset.ie/' + thumbnail_id + '.jpg'
  28. feeds_url = self._html_search_meta("feeds-prefix", webpage, 'feeds url') + video_id
  29. json_string = self._download_json(feeds_url, video_id)
  30. # f4m_url = server + relative_url
  31. f4m_url = json_string['shows'][0]['media:group'][0]['rte:server'] + json_string['shows'][0]['media:group'][0]['url']
  32. f4m_formats = self._extract_f4m_formats(f4m_url, video_id)
  33. f4m_formats = [{
  34. 'format_id': f['format_id'],
  35. 'url': f['url'],
  36. 'ext': 'mp4',
  37. 'width': f['width'],
  38. 'height': f['height'],
  39. } for f in f4m_formats ]
  40. return {
  41. 'id': video_id,
  42. 'title': title,
  43. 'formats': f4m_formats,
  44. 'description': description,
  45. 'thumbnail': thumbnail,
  46. 'duration': duration,
  47. }