-
Notifications
You must be signed in to change notification settings - Fork 59
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Hello, first and foremost, I would like to express my gratitude for creating and maintaining this fantastic library.
We have a project that requires some additional information to be crawled:
- Game categories content below game-related videos.
addgameChannelId
andgameName
fields inBaseVideo.ts
uploadDate
in YYYY-MM-DD format with the same time zone.
TwouploadDate
can be found in the json data, one of which is the original:
target.uploadDate = videoInfo.dateText.simpleText;
I guess it is the local time zone string.
The other is:
target.uploadDateISO = videoInfo.microformat.playerMicroformatRenderer.uploadDate;
Its format is always YYYY-MM-DD and I guess it's in 0 timezone.
I try to write like this as follows:
BaseVideo.ts
...
/** The date in ISO format this video is uploaded at */
uploadDateISO!: string;
/** The game's channel id that this video related */
gameChannelId!: string;
/** The game's name id that this video related */
gameName!: string;
...
BaseVideoParser.ts
static loadBaseVideo(target: BaseVideo, data: YoutubeRawData): BaseVideo {
...
target.uploadDateISO = videoInfo.microformat.playerMicroformatRenderer.uploadDate;
const { endpoint, title: gameTitle } = videoInfo.metadataRowContainer?.metadataRowContainerRenderer?.rows?.at(0)?.richMetadataRowRenderer?.contents?.at(0)?.richMetadataRenderer || {};
target.gameChannelId = endpoint?.browseEndpoint?.browseId || null;
target.gameName = gameTitle?.simpleText || null;
...
}
...
static parseRawData(data: YoutubeRawData): YoutubeRawData {
...
const { videoDetails, microformat } = data[2].playerResponse;
return { ...secondaryInfo, ...primaryInfo, videoDetails, microformat };
}
Print out the result.
const video = await youtube.getVideo("VNwldCV78fU");
console.log("===>", video.title, video.uploadDateISO, video.gameChannelId, video.gameName);
// My Editor Commits War Crimes | Horizon Zero Dawn
// 2023-01-26
// UCzdvNoUM78qdDqjPEXGq9zw
// Horizon Zero Dawn
I'm not sure the naming and writing are correct, please correct me if any wrong.
We hope that this can be implemented as a new feature in the future. Thank you!
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request