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