npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@sugarcube/plugin-youtube

v0.42.1

Published

A SugarCube plugin to fetch videos from Youtube.

Downloads

9

Readme

@sugarcube/plugin-youtube

A plugin for SugarCube that fetches video and channel data from youtube.

Requirements

A Youtube API key is required to use these plugins. To obtain one follow those steps:

  • Use your existing Google account, or create a new account.
  • Go to the Developers Console and login with your account.
  • First create a new project. Click on Select a Project and then click on New Project.
  • Select the newly created project, and as a next step click on Enable APIS and Services.
  • Select the Youtube Data API v3 and enable it.
  • On the Youtube API page click on Create Credentials. Select the Youtube Data API v3 to use, Other UI to use it from and pick Public Data on the question what data to access. This will generate an API key for you.

Installation

npm install --save @sugarcube/plugin-youtube

Plugins

youtube_video

Fetch details for an individual video by it's id. It uses the youtube_video query type. The query can be specified either as the video id (e.g. oMOSiag3dxg) or as the full URL to the video (e.g. https://www.youtube.com/watch?v=oMOSiag3dxg).

The Youtube API key must be set as well. You can do this by setting the youtube.api_key config option:

--youtube.api_key <key>

or setting it in the JSON configuration file:

{
  "youtube": {
    "api_key": "<key>"
  }
}

Metrics:

  • total: The total number of Youtube videos fetched.
  • fail: The number of videos that failed.
  • success: The number of videos that were successfully fetched.

youtube_channel

Fetch a list of videos from a channel. A query must be configured to supply one or more channel ids.

[
  {
    "type": "youtube_channel",
    "term": "UCJkMlOu7faDgqh4PfzbpLdg"
  },
  {
    "type": "youtube_channel",
    "term": "https://www.youtube.com/channel/UC_QIfHvN9auy2CoOdSfMWDw/featured"
  }
]

The channel query can be provided either as an id (e.g. UC_QIfHvN9auy2CoOdSfMWDw) or as the full URL to the channel (e.g. https://www.youtube.com/channel/UC_QIfHvN9auy2CoOdSfMWDw/featured). The last segment of the channel URL (in this case featured) is optional. The relevant part is the /channel/<channel-id> part of the URL.

The Youtube API key must be set as well. You can do this by setting the youtube.api_key config option:

--youtube.api_key <key>

or setting it in the JSON configuration file:

{
  "youtube": {
    "api_key": "<key>"
  }
}

Other Possible config values are:

{
  "youtube": {
    "published_before": "2017-06-22",
    "published_after": "2017-06-22",
    "past_days": 30
  }
}

Setting any of these increases performance, but is capped at around 500 video results.

The following example fetches a Youtube channel and downloads all available videos. It uses the media_youtubedl plugin.

$(npm bin)/sugarcube -c config.json \
                     -q channels.json \
                     -p youtube_channel,media_youtubedl

Metrics:

  • total: The total number of Youtube channels queried.
  • fail: The number of channels that failed.
  • success: The number of channels that succeeded to download.
  • fetched: The number of videos that are fetched from the channels.

youtube_filter_failing

This plugin verifies against the Youtube API that each unit that is a Youtube video exists, and returns all failing videos as units in the envelope. It is meant as the first step in a two step process to verify the number of videos that were taken down by Youtube. The output of this plugin can be send straight to the media_youtubedl_check plugin for a more detailed check.

This plugin doesn't collect missing videos as failures, but it counts the metric.

Configuration:

  • youtube.api_key: The API key for Youtube.com. This option is required.

Example:

{
  "plugins": [
    "elastic_import",
    "youtube_filter_failing",
    "media_youtubedl_check"
  ],
  "youtube": {
    "api_key": "<key>"
  },
  "queries": [
    {"type": "glob_pattern", "term": "./es-queries/all-youtube-videos.json"}
  ]
}

Metrics:

  • total: The total number of Youtube videos queried.
  • fail: The number of videos that failed. This metric is tracked continuously as it is detected.
  • success: The number of videos that exist.
  • missing: The number of videos that failed. This metric is emitted once at the end of the plugin containing the total number of failed videos.

Feature flags

  • ncube sets the new and Ncube compatible data format. This is still optional but will become the new default in the future.
$(npm bin)/sugarcube -c config.json \
                     -Q youtube_channel:UCaLlzGqiPE2QRj6sSOawJRg \
                     -p youtube_channel \
                     -D ncube

License

GPL3 @ Christo