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:

If any body can bring me some example about how to use the youtube API library or some functions It would be a great help for me, I am a beginner, Thanks guys

A good explanation by The Coding Train here.
You might want to take a look at the reference from loadJSONObject()

JSON is easier to parse than HTML.
Here is the explanation of Google, how the JSON is built.
You didn’t say by which parameter you get the channel. Probably you want this by Username, but pick yourself a parameter here.
Here is a quickstart for JAVA.

EDIT: A RPI 3 seems to be a bit overwhelming. A RPI Zero or Zero W could (probably) do it, too. But then i recommend to export it for Linux 32-bit.

2 Likes

:star_struck: I really appreciate, I’m going to take a look now, Thank you @anon68884268 for take a time to help me :sunglasses: :hugs: