Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get youtube channel id using channel custom name?

My question is very similar to this one, I want to get channel id using channel custom name.

The answer on the question mentioned above which is:

GET https://www.googleapis.com/youtube/v3/search?part=id%2Csnippet&q=annacavalli&type=channel&key={YOUR_API_KEY}

doesn't work on small channels, for ex. when I run it with this channel: https://www.youtube.com/AnnaShearerfashionfettish it returns nothing.

like image 473
Mahmoud Hanafy Avatar asked Nov 03 '17 12:11

Mahmoud Hanafy


People also ask

How do I find a YouTube channel without knowing the name?

Using Search Filters. Open YouTube. If you can't remember the name of the video and couldn't find it in your history, you can use search filters within YouTube to help track it down.

Does YouTube have ID channel?

Watch Investigation Discovery on YouTube TV $64.99/mo for 85+ live channels. No contracts or hidden fees. Available nationwide.


1 Answers

It's very easy, using curl and grep.

Command

channel_name='DOVASYNDROMEYouTubeOfficial' #change this as you like
curl --silent "https://www.youtube.com/c/${channel_name}/videos" |\
    grep -o -P '(?<=canonical" href="https://www.youtube.com/channel/)[^"]*'

Output

UCq15_9MvmxT1r2-LLjtkokg
like image 121
ynn Avatar answered Oct 06 '22 23:10

ynn