1.1.3 • Published 4 years ago

youtu-get v1.1.3

Weekly downloads
17
License
ISC
Repository
github
Last release
4 years ago

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

NPM npm npm GitHub code size in bytes GitHub repo size Coverage badge

Instalation

npm i youtu-get -g

Example running:

ytget id="PLxQ30nUCB0uNCCKBD_JW1udM7iYH27cu2" output="/yourOutputPath/youtube-playlist.json"

You can use this package for your next solution like this:

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:

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:

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

Expected correct result if you defined correct your youtube playlist id without defined output path:

Alt 2

Expected correct result if you defined correct your youtube playlist id with defined output path:

Alt 2

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago