# How to code a YOUTUBE subscriber counter?

**URL:** https://discourse.processing.org/t/how-to-code-a-youtube-subscriber-counter/17004
**Category:** Project Guidance
**Created:** [January 10, 2020, 4:12pm UTC](https://discourse.processing.org/t/how-to-code-a-youtube-subscriber-counter/17004 "2020-01-10T16:12:40Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![iobotic](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/iobotic/32/7765_2.png) [@iobotic](https://discourse.processing.org/u/iobotic)
#### Post date: [January 10, 2020, 4:12pm UTC](https://discourse.processing.org/t/how-to-code-a-youtube-subscriber-counter/17004/1 "2020-01-10T16:12:40Z")

</div>

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

I would like to know **how can I make a Youtube Subs Counter using processing?** 🤩

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?** 🤔

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! 🕶

Best  
Hugo

---

<div class="post-metadata">

### Author: ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)
#### Post date: [January 14, 2020, 5:06am UTC](https://discourse.processing.org/t/how-to-code-a-youtube-subscriber-counter/17004/3 "2020-01-14T05:06:03Z")

</div>

One approach would be to check the [YouTube API](https://developers.google.com/youtube/v3/docs/subscriptions/list) and check available examples on the web.

Kf

---

<div class="post-metadata">

### Author: ![iobotic](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/iobotic/32/7765_2.png) [@iobotic](https://discourse.processing.org/u/iobotic)
#### Post date: [January 14, 2020, 10:36pm UTC](https://discourse.processing.org/t/how-to-code-a-youtube-subscriber-counter/17004/4 "2020-01-14T22:36:29Z")

</div>

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

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.

```auto
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 😀

---

<div class="post-metadata">

### Author: ![iobotic](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/iobotic/32/7765_2.png) [@iobotic](https://discourse.processing.org/u/iobotic)
#### Post date: [January 25, 2020, 11:42pm UTC](https://discourse.processing.org/t/how-to-code-a-youtube-subscriber-counter/17004/5 "2020-01-25T23:42:32Z")

</div>

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

---

<div class="post-metadata">

### Author: ![anon68884268](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@anon68884268](https://discourse.processing.org/u/anon68884268)
#### Post date: [January 26, 2020, 12:15pm UTC](https://discourse.processing.org/t/how-to-code-a-youtube-subscriber-counter/17004/6 "2020-01-26T12:15:27Z")

</div>

A good explanation by The Coding Train [here](https://youtu.be/rqROpUNb2aY).  
You might want to take a look at the reference from [loadJSONObject()](https://processing.org/reference/loadJSONObject_.html)

JSON is easier to parse than HTML.  
[Here](https://developers.google.com/youtube/v3/docs/channels) 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](https://developers.google.com/youtube/v3/code_samples/code_snippets).  
[Here](https://developers.google.com/youtube/v3/quickstart/java) 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](https://github.com/processing/processing/wiki/Export-Info-and-Tips) it for Linux 32-bit.

---

<div class="post-metadata">

### Author: ![iobotic](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/iobotic/32/7765_2.png) [@iobotic](https://discourse.processing.org/u/iobotic)
#### Post date: [January 27, 2020, 5:10pm UTC](https://discourse.processing.org/t/how-to-code-a-youtube-subscriber-counter/17004/7 "2020-01-27T17:10:25Z")

</div>

🤩 I really appreciate, I’m going to take a look now, Thank you @anon68884268 for take a time to help me 🕶 🤗
