4 from .common
import InfoExtractor
13 from ..utils
.traversal
import find_element
, traverse_obj
16 class LearningOnScreenIE(InfoExtractor
):
17 _VALID_URL
= r
'https?://learningonscreen\.ac\.uk/ondemand/index\.php/prog/(?P<id>\w+)'
19 'url': 'https://learningonscreen.ac.uk/ondemand/index.php/prog/005D81B2?bcast=22757013',
23 'title': 'Planet Earth',
25 'timestamp': 1164567600.0,
26 'upload_date': '20061126',
27 'thumbnail': 'https://stream.learningonscreen.ac.uk/trilt-cover-images/005D81B2-Planet-Earth-2006-11-26T190000Z-BBC4.jpg',
31 def _real_initialize(self
):
32 if not self
._get
_cookies
('https://learningonscreen.ac.uk/').get('PHPSESSID-BOB-LIVE'):
33 self
.raise_login_required(method
='session_cookies')
35 def _real_extract(self
, url
):
36 video_id
= self
._match
_id
(url
)
37 webpage
= self
._download
_webpage
(url
, video_id
)
39 details
= traverse_obj(webpage
, (
40 {find_element(id='programme-details', html
=True)}, {
41 'title': ({find_element(tag
='h2')}, {clean_html}
),
43 {find_element(cls
='broadcast-date')},
44 {functools
.partial(re
.match
, r
'([^<]+)')}, 1, {unified_timestamp}
),
46 {find_element(cls
='prog-running-time')}, {clean_html}
, {parse_duration}
),
49 title
= details
.pop('title', None) or traverse_obj(webpage
, (
50 {find_element(id='add-to-existing-playlist', html
=True)},
51 {extract_attributes}
, 'data-record-title', {clean_html}
))
53 entries
= self
._parse
_html
5_media
_entries
(
54 'https://stream.learningonscreen.ac.uk', webpage
, video_id
, m3u8_id
='hls', mpd_id
='dash',
55 _headers
={'Origin': 'https://learningonscreen.ac.uk', 'Referer': 'https://learningonscreen.ac.uk/'})
57 raise ExtractorError('No video found')
60 duration
= details
.pop('duration', None)
61 for idx
, entry
in enumerate(entries
, start
=1):
63 entry
['id'] = join_nonempty(video_id
, idx
)
64 entry
['title'] = join_nonempty(title
, idx
)
65 return self
.playlist_result(entries
, video_id
, title
, duration
=duration
)