Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gameChannelId, gameName, and uploadDateISO in BaseVideo #74

Open
Hello-May opened this issue Jan 30, 2023 · 0 comments
Open

Add gameChannelId, gameName, and uploadDateISO in BaseVideo #74

Hello-May opened this issue Jan 30, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@Hello-May
Copy link

Hello-May commented Jan 30, 2023

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:

  1. Game categories content below game-related videos.
    add gameChannelId and gameName fields in BaseVideo.ts

My Editor Commits War Crimes  Horizon Zero Dawn

  1. uploadDate in YYYY-MM-DD format with the same time zone.
    Two uploadDate 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant