fix: handle YouTube deleted video (#1804)
This commit is contained in:
parent
c464ef5967
commit
2ee701030d
|
|
@ -12,18 +12,20 @@ module.exports = async (ctx) => {
|
|||
title: `${data[0].snippet.channelTitle} 的 Youtube 视频`,
|
||||
link: `https://www.youtube.com/channel/${id}`,
|
||||
description: `${data[0].snippet.channelTitle} 的 Youtube 视频`,
|
||||
item: data.map((item) => {
|
||||
const snippet = item.snippet;
|
||||
const videoId = snippet.resourceId.videoId;
|
||||
const img = utils.getThumbnail(snippet.thumbnails);
|
||||
return {
|
||||
title: snippet.title,
|
||||
description: `${embed ? '<iframe id="ytplayer" type="text/html" width="640" height="360" src="https://www.youtube.com/embed/' + videoId + '" frameborder="0" allowfullscreen></iframe>' : ''}${utils.formatDescription(
|
||||
snippet.description
|
||||
)}<img referrerpolicy="no-referrer" src="${img.url}">`,
|
||||
pubDate: new Date(snippet.publishedAt).toUTCString(),
|
||||
link: `https://www.youtube.com/watch?v=${videoId}`,
|
||||
};
|
||||
}),
|
||||
item: data
|
||||
.filter((d) => d.snippet.title !== 'Private video' && d.snippet.title !== 'Deleted video')
|
||||
.map((item) => {
|
||||
const snippet = item.snippet;
|
||||
const videoId = snippet.resourceId.videoId;
|
||||
const img = utils.getThumbnail(snippet.thumbnails);
|
||||
return {
|
||||
title: snippet.title,
|
||||
description: `${
|
||||
embed ? '<iframe id="ytplayer" type="text/html" width="640" height="360" src="https://www.youtube.com/embed/' + videoId + '" frameborder="0" allowfullscreen></iframe>' : ''
|
||||
}${utils.formatDescription(snippet.description)}<img referrerpolicy="no-referrer" src="${img.url}">`,
|
||||
pubDate: new Date(snippet.publishedAt).toUTCString(),
|
||||
link: `https://www.youtube.com/watch?v=${videoId}`,
|
||||
};
|
||||
}),
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ module.exports = async (ctx) => {
|
|||
link: `https://www.youtube.com/playlist?list=${id}`,
|
||||
description: `Playlist: ${playlistTitle} by ${data[0].snippet.channelTitle}`,
|
||||
item: data
|
||||
.filter((d) => d.snippet.title !== 'Private video')
|
||||
.filter((d) => d.snippet.title !== 'Private video' && d.snippet.title !== 'Deleted video')
|
||||
.map((item) => {
|
||||
const snippet = item.snippet;
|
||||
const videoId = snippet.resourceId.videoId;
|
||||
|
|
|
|||
|
|
@ -12,18 +12,20 @@ module.exports = async (ctx) => {
|
|||
title: `${username} 的 Youtube 视频`,
|
||||
link: `https://www.youtube.com/user/${username}`,
|
||||
description: `${username} 的 Youtube 视频`,
|
||||
item: data.map((item) => {
|
||||
const snippet = item.snippet;
|
||||
const videoId = snippet.resourceId.videoId;
|
||||
const img = utils.getThumbnail(snippet.thumbnails);
|
||||
return {
|
||||
title: snippet.title,
|
||||
description: `${embed ? '<iframe id="ytplayer" type="text/html" width="640" height="360" src="https://www.youtube.com/embed/' + videoId + '" frameborder="0" allowfullscreen></iframe>' : ''}${utils.formatDescription(
|
||||
snippet.description
|
||||
)}<img referrerpolicy="no-referrer" src="${img.url}">`,
|
||||
pubDate: new Date(snippet.publishedAt).toUTCString(),
|
||||
link: `https://www.youtube.com/watch?v=${videoId}`,
|
||||
};
|
||||
}),
|
||||
item: data
|
||||
.filter((d) => d.snippet.title !== 'Private video' && d.snippet.title !== 'Deleted video')
|
||||
.map((item) => {
|
||||
const snippet = item.snippet;
|
||||
const videoId = snippet.resourceId.videoId;
|
||||
const img = utils.getThumbnail(snippet.thumbnails);
|
||||
return {
|
||||
title: snippet.title,
|
||||
description: `${
|
||||
embed ? '<iframe id="ytplayer" type="text/html" width="640" height="360" src="https://www.youtube.com/embed/' + videoId + '" frameborder="0" allowfullscreen></iframe>' : ''
|
||||
}${utils.formatDescription(snippet.description)}<img referrerpolicy="no-referrer" src="${img.url}">`,
|
||||
pubDate: new Date(snippet.publishedAt).toUTCString(),
|
||||
link: `https://www.youtube.com/watch?v=${videoId}`,
|
||||
};
|
||||
}),
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue