Need Help! How to code a YOUTUBE subscriber counter?

Hello Friends! My name is Hugo, I’m a new for here and I’m happy to join the community. :hugs:

I would like to know how can I make a Youtube Subs Counter using processing? :star_struck:

My Idea is to use a Raspberry Pi 3, install the processing IDE and make the code but I can’t find any documentation about how to read the Youtube API? :thinking:

In fact that is my big problem, once I can read the value of the API and print it on the screen and the rest are the artistic aspects.

I hope you can help me guys, I will be happy and thankfull! :sunglasses:

Best
Hugo

One approach would be to check the YouTube API and check available examples on the web.

Kf

1 Like

Thank you @kfrajer I already check it out but I don’t have idea about how can I use it :neutral_face:. It’s because I’m asking for some help. :roll_eyes:

Can you @kfrajer send me some example? I tried with regular expressions using loadString() and indexOf(…) but I can’t make it work. @TfGuy44

This was my code.

void draw()
{
  background(20);
  textAlign(CENTER);
  textSize(width*0.2);
  String[] web = loadStrings("https://www.youtube.com/channel/UCy0YHkGM8szRMOhIkNUFwiA?view_as=subscriber"); // My Youtube profile link
  String HTML = join(web,""); //Join all HTML code as a string

  String start = "<yt-formatted-string id=\"subscriber-count\" class=\"style-scope ytd-c4-tabbed-header-renderer\">";
  String end = " suscriptores</yt-formatted-string>";
  String subs = giveMeTextBetween(HTML,start,end);
  println(subs);
  //text("100K",width/2,height/2+200);
  
}

String giveMeTextBetween(String s, String before, String after)
{
  String found = "";
  int start = s.indexOf(before);
  if(start == -1){return "Start Error";}; //If we don't find anything , send back a blank String
  start += before.length(); // Move to the end of the beginning tag
  
  int end = s.indexOf(after,start);
  if(end == -1){return "End Error";};
  
  return s.substring(start,end); //Return the text in between 
}

Thanks for help guys :grinning: