rte.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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': 1622963.0,
  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'))
  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. for f in f4m_formats:
  34. del f['tbr']
  35. return {
  36. 'id': video_id,
  37. 'title': title,
  38. 'formats': f4m_formats,
  39. 'description': description,
  40. 'thumbnail': thumbnail,
  41. 'duration': duration,
  42. }