YouTube API examples & templates
Use these vals as a playground to view and fork YouTube API examples and templates on Val Town. Run any example below or find templates that can be used as a pre-built solution.
nbbaier
getVideoInfo
Script
Get YT Video Information Given a youtube video url, this val returns a small amount of information about the video: title, channel title, and the description. It uses the Youtube Data API v3, so you need to bring your own API key to get it to work (see here about setting up an API key).
0
pdebie
publishYoutubeToLemmy
Script
Publish a Youtube feed to Lemmy This allows you to automatically publish a Youtube channel to to a Lemmy community. Example usage: async function publishMyFeed() {
try {
return @pdebie.publishYoutubeToLemmy({
instance: "lemm.ee",
auth: @me.secrets.lemmee,
communityId: 23316,
youtubeChannelId: "UChZgikssAJkmiQOv_sO-ngQ",
lastSyncTime: @pdebie.spacexLemmyDb.lastSync,
});
}
finally {
@pdebie.spacexLemmyDb.lastSync = new Date().toISOString();
}
} Get a Youtube channel ID here . Make sure to set your lastSync properly, since otherwise you'll keep publishing new posts!
3