mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-10-31 23:02:40 +00:00
parent
55f1833376
commit
29a74a6126
1 changed files with 25 additions and 20 deletions
|
@ -1,33 +1,38 @@
|
||||||
import datetime
|
|
||||||
|
|
||||||
from .common import InfoExtractor
|
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):
|
class NerdCubedFeedIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://(?:www\.)?nerdcubed\.co\.uk/feed\.json'
|
_VALID_URL = r'https?://(?:www\.)?nerdcubed\.co\.uk/?(?:$|[#?])'
|
||||||
_TEST = {
|
_TEST = {
|
||||||
'url': 'http://www.nerdcubed.co.uk/feed.json',
|
'url': 'http://www.nerdcubed.co.uk/',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': 'nerdcubed-feed',
|
'id': 'nerdcubed-feed',
|
||||||
'title': 'nerdcubed.co.uk feed',
|
'title': 'nerdcubed.co.uk feed',
|
||||||
},
|
},
|
||||||
'playlist_mincount': 1300,
|
'playlist_mincount': 5500,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
feed = self._download_json(url, url, 'Downloading NerdCubed JSON feed')
|
video_id = 'nerdcubed-feed'
|
||||||
|
feed = self._download_json('https://www.nerdcubed.co.uk/_/cdn/videos.json', video_id)
|
||||||
|
|
||||||
entries = [{
|
return self.playlist_result(
|
||||||
'_type': 'url',
|
map(self._extract_video, traverse_obj(feed, ('videos', lambda _, v: v['id']))),
|
||||||
'title': feed_entry['title'],
|
video_id, 'nerdcubed.co.uk feed')
|
||||||
'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]
|
|
||||||
|
|
||||||
return {
|
|
||||||
'_type': 'playlist',
|
|
||||||
'title': 'nerdcubed.co.uk feed',
|
|
||||||
'id': 'nerdcubed-feed',
|
|
||||||
'entries': entries,
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue