logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

thesun.py (1402B)


  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import extract_attributes
  5. class TheSunIE(InfoExtractor):
  6. _VALID_URL = r'https://(?:www\.)?thesun\.co\.uk/[^/]+/(?P<id>\d+)'
  7. _TEST = {
  8. 'url': 'https://www.thesun.co.uk/tvandshowbiz/2261604/orlando-bloom-and-katy-perry-post-adorable-instagram-video-together-celebrating-thanksgiving-after-split-rumours/',
  9. 'info_dict': {
  10. 'id': '2261604',
  11. 'title': 'md5:cba22f48bad9218b64d5bbe0e16afddf',
  12. },
  13. 'playlist_count': 2,
  14. }
  15. BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/%s/default_default/index.html?videoId=%s'
  16. def _real_extract(self, url):
  17. article_id = self._match_id(url)
  18. webpage = self._download_webpage(url, article_id)
  19. entries = []
  20. for video in re.findall(
  21. r'<video[^>]+data-video-id-pending=[^>]+>',
  22. webpage):
  23. attrs = extract_attributes(video)
  24. video_id = attrs['data-video-id-pending']
  25. account_id = attrs.get('data-account', '5067014667001')
  26. entries.append(self.url_result(
  27. self.BRIGHTCOVE_URL_TEMPLATE % (account_id, video_id),
  28. 'BrightcoveNew', video_id))
  29. return self.playlist_result(
  30. entries, article_id, self._og_search_title(webpage, fatal=False))