2014-12-19 05:28:13 +01:00
|
|
|
from .common import InfoExtractor
|
2024-02-23 16:59:13 +01:00
|
|
|
from .youtube import YoutubeIE
|
|
|
|
from ..utils import parse_iso8601, url_or_none
|
|
|
|
from ..utils.traversal import traverse_obj
|
2014-12-19 05:28:13 +01:00
|
|
|
|
|
|
|
|
|
|
|
class NerdCubedFeedIE(InfoExtractor):
|
2024-02-23 16:59:13 +01:00
|
|
|
_VALID_URL = r'https?://(?:www\.)?nerdcubed\.co\.uk/?(?:$|[#?])'
|
2014-12-19 05:28:13 +01:00
|
|
|
_TEST = {
|
2024-02-23 16:59:13 +01:00
|
|
|
'url': 'http://www.nerdcubed.co.uk/',
|
2014-12-19 05:28:13 +01:00
|
|
|
'info_dict': {
|
2015-02-01 12:11:20 +01:00
|
|
|
'id': 'nerdcubed-feed',
|
2014-12-19 05:28:13 +01:00
|
|
|
'title': 'nerdcubed.co.uk feed',
|
|
|
|
},
|
2024-02-23 16:59:13 +01:00
|
|
|
'playlist_mincount': 5500,
|
2014-12-19 05:28:13 +01:00
|
|
|
}
|
|
|
|
|
2024-02-23 16:59:13 +01:00
|
|
|
def _extract_video(self, feed_entry):
|
|
|
|
return self.url_result(
|
|
|
|
f'https://www.youtube.com/watch?v={feed_entry["id"]}', YoutubeIE,
|
|
|
|
**traverse_obj(feed_entry, {
|
|
|
|
'id': ('id', {str}),
|
|
|
|
'title': ('title', {str}),
|
|
|
|
'description': ('description', {str}),
|
|
|
|
'timestamp': ('publishedAt', {parse_iso8601}),
|
|
|
|
'channel': ('source', 'name', {str}),
|
|
|
|
'channel_id': ('source', 'id', {str}),
|
|
|
|
'channel_url': ('source', 'url', {str}),
|
|
|
|
'thumbnail': ('thumbnail', 'source', {url_or_none}),
|
|
|
|
}), url_transparent=True)
|
2014-12-21 15:22:30 +01:00
|
|
|
|
2024-02-23 16:59:13 +01:00
|
|
|
def _real_extract(self, url):
|
|
|
|
video_id = 'nerdcubed-feed'
|
|
|
|
feed = self._download_json('https://www.nerdcubed.co.uk/_/cdn/videos.json', video_id)
|
2014-12-19 05:28:13 +01:00
|
|
|
|
2024-02-23 16:59:13 +01:00
|
|
|
return self.playlist_result(
|
|
|
|
map(self._extract_video, traverse_obj(feed, ('videos', lambda _, v: v['id']))),
|
|
|
|
video_id, 'nerdcubed.co.uk feed')
|