thesun.py 1.0 KB

123456789101112131415161718192021222324252627
  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. from .ooyala import OoyalaIE
  4. class TheSunIE(InfoExtractor):
  5. _VALID_URL = r'https://(?:www\.)?thesun\.co\.uk/\w+/(?P<id>\d+)/[\w-]'
  6. _TEST = {
  7. 'url': 'https://www.thesun.co.uk/tvandshowbiz/2261604/orlando-bloom-and-katy-perry-post-adorable-instagram-video-together-celebrating-thanksgiving-after-split-rumours/',
  8. 'md5': '5667123b24f25f43f4c4f381ef34c5c2',
  9. 'info_dict': {
  10. 'id': 'h4OXN0NzE6rv6ObkEifKcNA-gYUw4xFf',
  11. 'ext': 'mp4',
  12. 'title': 'Katy Perry and Orlando Bloom shut down split rumours with cute Thanksgiving video',
  13. 'description': 'Still going strong',
  14. 'duration': 31.28,
  15. }
  16. }
  17. def _real_extract(self, url):
  18. video_id = self._match_id(url)
  19. webpage = self._download_webpage(url, video_id)
  20. ooyala_id = self._search_regex(r'id\s*=\s*"thesun-ooyala-player-([^"]+)"', webpage, 'ooyala id')
  21. return OoyalaIE._build_url_result(ooyala_id)