Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/frantallukas10/youtu-get
youtube
https://github.com/frantallukas10/youtu-get
get id playlist title youtube ytget
Last synced: 5 days ago
JSON representation
youtube
- Host: GitHub
- URL: https://github.com/frantallukas10/youtu-get
- Owner: frantallukas10
- License: mit
- Created: 2019-11-13T20:56:58.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T02:21:03.000Z (about 2 years ago)
- Last Synced: 2024-03-25T15:09:20.047Z (10 months ago)
- Topics: get, id, playlist, title, youtube, ytget
- Language: JavaScript
- Homepage:
- Size: 614 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 21
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# youtu-get
is project which can get your all name of songs and url from your youtube playlist. It returns array with name of songs and url as objects and the returned data can be save as json file. As my example, but it is optional if you define `output` variable.
# [demo](https://youtu-get-demo.lukasfrantal.com)
![NPM](https://img.shields.io/npm/l/youtu-get)
![npm](https://img.shields.io/npm/v/youtu-get)
![npm](https://img.shields.io/npm/dt/youtu-get)
![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/frantallukas10/youtu-get)
![GitHub repo size](https://img.shields.io/github/repo-size/frantallukas10/youtu-get)
![Coverage badge](https://img.shields.io/badge/Coverage-100%25-brightgreen.svg)
## Instalation
```bash
npm i youtu-get -g
```## Example running:
```bash
ytget id="PLxQ30nUCB0uNCCKBD_JW1udM7iYH27cu2" output="/yourOutputPath/youtube-playlist.json"
```## You can use this package for your next solution like this:
```js
const { getYoutubeInfo } = require('youtu-get');const idPlaylist = 'PLxQ30nUCB0uNCCKBD_JW1udM7iYH27cu2';
getYoutubeInfo(idPlaylist).then((data) => console.log(data));
```## If you want save output data yout can do it like this:
```js
const { getYoutubeInfo } = require('youtu-get');
const path = require('path');
const username = require('os').userInfo().username;const idPlaylist = 'PLxQ30nUCB0uNCCKBD_JW1udM7iYH27cu2';
const outputPath = path.resolve(
`/Users/${username}/Downloads/`,
'youtube-playlist.json'
);getYoutubeInfo(idPlaylist).then((data) => {
fs.writeFile(outputPath, JSON.stringify(data, null, 2), (err) => {
if (err) console.error(err);
});
});
```## If you want check your youtube playlist id before running getYoutubeInfo function you can use this:
```js
const { getYoutubeInfo, isValidId } = require('youtu-get');
const path = require('path');
const username = require('os').userInfo().username;const idPlaylist = 'PLxQ30nUCB0uNCCKBD_JW1udM7iYH27cu2';
const isValid = isValidId(id)
const outputPath = path.resolve(
`/Users/${username}/Downloads/`,
'youtube-playlist.json'
);
isValid ?
getYoutubeInfo(idPlaylist).then(data => {
fs.writeFile(outputPath, JSON.stringify(data, null, 2), err => {
if (err) console.error(err);
});
});
: console.error(`This youtube playlist id is not valid: ${idPlaylist}`);
```## Expected incorrect result if you don't define your youtube playlist id:
![Alt 1](./images/1.png)
## Expected correct result if you defined correct your youtube playlist id without defined output path:
![Alt 2](./images/2.png)
## Expected correct result if you defined correct your youtube playlist id with defined output path:
![Alt 2](./images/3.png)