aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsepro <4618135+seproDev@users.noreply.github.com>2024-02-23 16:59:13 +0100
committerGitHub <noreply@github.com>2024-02-23 16:59:13 +0100
commit29a74a6126101aabaa1726ae41b1ca55cf26e7a7 (patch)
tree7bc47ab34335f4c12fc52ec128d6a2559b11b07d
parent55f1833376505ed1e4be0516b09bb3ea4425e8a4 (diff)
[ie/NerdCubedFeed] Overhaul extractor (#9269)
Authored by: seproDev
-rw-r--r--yt_dlp/extractor/nerdcubed.py45
1 files changed, 25 insertions, 20 deletions
diff --git a/yt_dlp/extractor/nerdcubed.py b/yt_dlp/extractor/nerdcubed.py
index 7c801b5d3..5f5607a20 100644
--- a/yt_dlp/extractor/nerdcubed.py
+++ b/yt_dlp/extractor/nerdcubed.py
@@ -1,33 +1,38 @@
-import datetime
-
from .common import InfoExtractor
+from .youtube import YoutubeIE
+from ..utils import parse_iso8601, url_or_none
+from ..utils.traversal import traverse_obj
class NerdCubedFeedIE(InfoExtractor):
- _VALID_URL = r'https?://(?:www\.)?nerdcubed\.co\.uk/feed\.json'
+ _VALID_URL = r'https?://(?:www\.)?nerdcubed\.co\.uk/?(?:$|[#?])'
_TEST = {
- 'url': 'http://www.nerdcubed.co.uk/feed.json',
+ 'url': 'http://www.nerdcubed.co.uk/',
'info_dict': {
'id': 'nerdcubed-feed',
'title': 'nerdcubed.co.uk feed',
},
- 'playlist_mincount': 1300,
+ 'playlist_mincount': 5500,
}
- def _real_extract(self, url):
- feed = self._download_json(url, url, 'Downloading NerdCubed JSON feed')
+ 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)
- entries = [{
- '_type': 'url',
- 'title': feed_entry['title'],
- 'uploader': feed_entry['source']['name'] if feed_entry['source'] else None,
- 'upload_date': datetime.datetime.strptime(feed_entry['date'], '%Y-%m-%d').strftime('%Y%m%d'),
- 'url': 'http://www.youtube.com/watch?v=' + feed_entry['youtube_id'],
- } for feed_entry in feed]
+ def _real_extract(self, url):
+ video_id = 'nerdcubed-feed'
+ feed = self._download_json('https://www.nerdcubed.co.uk/_/cdn/videos.json', video_id)
- return {
- '_type': 'playlist',
- 'title': 'nerdcubed.co.uk feed',
- 'id': 'nerdcubed-feed',
- 'entries': entries,
- }
+ return self.playlist_result(
+ map(self._extract_video, traverse_obj(feed, ('videos', lambda _, v: v['id']))),
+ video_id, 'nerdcubed.co.uk feed')