summaryrefslogtreecommitdiffstats
path: root/yt_dlp/extractor/ukcolumn.py
blob: f141804c801e7bbb3af2427dffe06359d21ae1f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
from .common import InfoExtractor
from .vimeo import VimeoIE
from .youtube import YoutubeIE
from ..utils import (
    ExtractorError,
    unescapeHTML,
    urljoin,
)


class UkColumnIE(InfoExtractor):
    _WORKING = False
    IE_NAME = 'ukcolumn'
    _VALID_URL = r'(?i)https?://(?:www\.)?ukcolumn\.org(/index\.php)?/(?:video|ukcolumn-news)/(?P<id>[-a-z0-9]+)'

    _TESTS = [{
        'url': 'https://www.ukcolumn.org/ukcolumn-news/uk-column-news-28th-april-2021',
        'info_dict': {
            'id': '541632443',
            'ext': 'mp4',
            'title': 'UK Column News - 28th April 2021',
            'uploader_id': 'ukcolumn',
            'uploader': 'UK Column',
        },
        'add_ie': [VimeoIE.ie_key()],
        'expected_warnings': ['Unable to download JSON metadata'],
        'params': {
            'skip_download': 'Handled by Vimeo',
        },
    }, {
        'url': 'https://www.ukcolumn.org/video/insight-eu-military-unification',
        'info_dict': {
            'id': 'Fzbnb9t7XAw',
            'ext': 'mp4',
            'title': 'Insight: EU Military Unification',
            'uploader_id': 'ukcolumn',
            'description': 'md5:29a207965271af89baa0bc191f5de576',
            'uploader': 'UK Column',
            'upload_date': '20170514',
        },
        'add_ie': [YoutubeIE.ie_key()],
        'params': {
            'skip_download': 'Handled by Youtube',
        },
    }, {
        'url': 'https://www.ukcolumn.org/index.php/ukcolumn-news/uk-column-news-30th-april-2021',
        'only_matching': True,
    }]

    def _real_extract(self, url):
        display_id = self._match_id(url)
        webpage = self._download_webpage(url, display_id)

        oembed_url = urljoin(url, unescapeHTML(self._search_regex(
            r'<iframe[^>]+src=(["\'])(?P<url>/media/oembed\?url=.+?)\1',
            webpage, 'OEmbed URL', group='url')))
        oembed_webpage = self._download_webpage(
            oembed_url, display_id, note='Downloading OEmbed page')

        ie, video_url = YoutubeIE, YoutubeIE._extract_url(oembed_webpage)
        if not video_url:
            ie, video_url = VimeoIE, VimeoIE._extract_url(url, oembed_webpage)
        if not video_url:
            raise ExtractorError('No embedded video found')

        return {
            '_type': 'url_transparent',
            'title': self._og_search_title(webpage),
            'url': video_url,
            'ie_key': ie.ie_key(),
        }