Skip to content
This repository has been archived by the owner on Mar 5, 2024. It is now read-only.

sulfureux/get-youtube-channel-id

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Get Youtube Channel Id

Get Youtube channel ID from Youtube's URL (async/await)

Install

npm install get-youtube-channel-id

Usage

parameters

Field Description
url Required Youtube's URL
const getYoutubeChannelId = require('./index');

var url = 'https://www.youtube.com/user/JustaTeeMusic';
// or var url = 'https://www.youtube.com/channel/UCVfTp0vAXnuDL8SSI8tPYGA';


var result = false;

(async function() {
  result = await getYoutubeChannelId(url);
  console.log(result);
  
  if (result !== false) {
    if (result.error) {
      console.log(`Have a error, try again`);
    } else {
      console.log(`Channel ID: ${result.id}`);
    }
  } else {
    console.log('Invalid youtube channel URL');
  }
})();


/* Result
https://www.youtube.com/user/JustaTeeMusic

{
  id: 'UC_Eqg-tBPUUvA0heBZfdu6Q',
  username: 'JustaTeeMusic',
  error: false
}

https://www.youtube.com/channel/UCVfTp0vAXnuDL8SSI8tPYGA

{
  id: 'UCVfTp0vAXnuDL8SSI8tPYGA',
  username: false,
  error: false
}

https://google.com/

false

*/

License

MIT

Releases

No releases published

Packages

No packages published