node-youtube-video-fetcher
v1.0.81
Published
A simple npm package to fetch YouTube video information
Downloads
12
Maintainers
Readme
YouTube Data API Integration Script Overview
This script utilizes Node.js to interface with the YouTube Data API, providing functions to fetch video data, obtain channel IDs, and perform channel-specific video searches. In addition, The script tracks API usage and generates HTML markup from the fetched data.
Version : 1.0.8
Prerequisites
- Node.js: download from Node.js official website.
- YouTube Data API Key: create a project in the Google Developers Console, enable the YouTube Data API v3, and then generate an API key. The maximum request is 10,000 requests per day.
Setup (Git)
- Clone or download script files.
- Install dependencies running
npm install
in the script's directory via terminal or command prompt. - Create a `config.mjs' file in the script's directory and add the following code:
export function apiKey() {
return 'YOUR_API_KEY';
}
Replace 'YOUR_API_KEY' with your YouTube Data API key.
Setup (Npm Package)
- Install the package using
npx node-youtube-video-fetcher-setup
in your project directory. - Create a `config.mjs' file in the script's directory and add the following code:
export function apiKey() {
return 'YOUR_API_KEY';
}
- Replace 'YOUR_API_KEY' with your YouTube Data API key.
- Run
npx node-youtube-video-fetcher-setup
to create the necessary files and directories.
Script Usage
Run the script using Node.js via terminal or command prompt:
node script.mjs
Inputs required:
- API Key: enter your YouTube Data API key for required authentication.
- Task: select the task ranging from fetching videos from a playlist (1), obtaining a channel ID (2), or performing a general channel search (3).
- Depending on the task, enter additional information like Playlist ID, Channel Query, or Channel ID and Timeframe.
- Choose the output format (JSON or CSV).
- The script checks the quota usage and warns about potential quota violations.
Output
- For tasks 1 and 3: a JSON or CSV file with the fetched video details is generated.
- For task 2: the script outputs the channel ID on the terminal.
Generating and Viewing HTML
- Open the project folder in an environment like Live Server, XAMPP, or MAMP.
- Use tags like &title& and &link& in your HTML template. These will be replaced by actual data from the file.
- Select JSON or CSV as source.
- Use the “Copy code” button to copy the HTML output.
- Preview the generated HTML output by clicking on the Results tab.
Important Notes
- Be cautious of the YouTube Data API quota limits.
- Keep your API key secure.
- You will need to enter the API key each time you run the script. Unless you want to hardcode it, but keep in mind that for any future changes, you will need to edit the script.
Troubleshooting
- For errors relating to quota or invalid parameters, check your API key and input parameters.
- Ensure stable internet connection.
- For unhandled exceptions, refer to the error messages in the terminal.
Support
For additional help or to report issues, please contact the script maintainer or developer.
- Developer: JeremiahK