# Allow people to vote in videos/streams on youtube

**URL:** <https://discourse.processing.org/t/allow-people-to-vote-in-videos-streams-on-youtube/15594>\
**Category:** Libraries\
**Created:** [November 17, 2019, 5:51pm UTC](https://discourse.processing.org/t/allow-people-to-vote-in-videos-streams-on-youtube/15594 "2019-11-17T17:51:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![HAL989](https://avatars.discourse-cdn.com/v4/letter/h/6de8d8/32.png) [@HAL989](https://discourse.processing.org/u/HAL989)\
**Post date:** [November 17, 2019, 5:51pm UTC](https://discourse.processing.org/t/allow-people-to-vote-in-videos-streams-on-youtube/15594/1 "2019-11-17T17:51:16Z")

</div>

Hello. I currently have some code working that reads a discussion page and looks for a keyword (!type), i’m wondering how exactly would i turn it into a thing to read: (preferably stream comments) or video comments.

```auto
import processing.net.*;
int counter = 0;
void setup(){size(1600,1000);}
void draw(){
counter = 0;
String[] page = loadStrings("REPLACE THIS WITH DISCUSSION URL");
for (int i = 0; i < page.length; i++){
String search = "!type ";
String toBeSearched = page[i];
int index = toBeSearched.indexOf(search);
String search2 = "comment-text-toggle hid";
int index2 = toBeSearched.indexOf(search2);
if(index>0) search = "comment-renderer-text-content";
if(index>0) index = toBeSearched.indexOf(search);
if(index>0){counter++;}
if(index>0){text(page[i].substring(index+30, index2-18),100,counter*50);}
}
}

```

It works well with the discussion page, I just want something less permanent to allow viewers to use

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [November 22, 2019, 9:46pm UTC](https://discourse.processing.org/t/allow-people-to-vote-in-videos-streams-on-youtube/15594/2 "2019-11-22T21:46:19Z")

</div>

> [@HAL989](#):
>
> i’m wondering how exactly would i turn it into a thing to read: (preferably stream comments) or video comments.

I’m not sure what you mean by stream comments – are you trying to create a bot that reads YouTube comments and then posts the responses to YouTube? Or are you trying to compile a report on something (like the keyword “shoes”) and then put the information… where?

---

<div class="post-metadata">

**Author:** ![HAL989](https://avatars.discourse-cdn.com/v4/letter/h/6de8d8/32.png) [@HAL989](https://discourse.processing.org/u/HAL989)\
**Post date:** [November 23, 2019, 12:04am UTC](https://discourse.processing.org/t/allow-people-to-vote-in-videos-streams-on-youtube/15594/3 "2019-11-23T00:04:58Z")

</div>

Never mind, I managed to get a version of this to work for youtube comments:

```auto
import processing.net.*;
int counter = 0;
int minute;
int[] counts = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int[] resetcounts = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
String[] names = {"flip","regeneration","zombie","witch","spider","creeper","skeleton","blindness","levitation","slowness","poison"};
String[] commands = {
"tp @a ~ ~ ~ ~180 ~",
"effect give @a minecraft:regeneration 10 1",
"execute at @a as @a run summon minecraft:zombie",
"execute at @a as @a run summon minecraft:witch",
"execute at @a as @a run summon minecraft:spider",
"execute at @a as @a run summon minecraft:creeper",
"execute at @a as @a run summon minecraft:skeleton",
"effect give @a minecraft:blindness 20 1",
"effect give @a minecraft:levitation 1 10",
"effect give @a minecraft:slowness 20 0",
"effect give @a minecraft:poison 10 0"};
String desiredname;
int desiredid;
String[] temporary;
void setup(){size(10,10);
String[] page = loadStrings("https://www.youtube.com/watch?v=CKuK41VMv0E&lc=all");
minute = minute();
counts = resetcounts;

counter = 0;
for (int i = 0; i < page.length; i++){
for (int x = 0; x < counts.length; x++){
String prefix = "!";
String search = prefix + names[x];
String toBeSearched = page[i];
int index = toBeSearched.indexOf(search);
String search2 = "seconds ago";
if (index>0) index = toBeSearched.indexOf(search2);
if(index>0){counts[x]++;}
}
}
int desiredvalue = max(counts);
if (desiredvalue>0){
for (int x = 0; x < counts.length; x++){
if (counts[x] == desiredvalue){desiredname = names[x];}
if (counts[x] == desiredvalue){desiredid = x;}  
}
print(desiredname);
println(" has been chosen to run");
}
if (desiredvalue==0){print("No votes in the past minute.");}
if (desiredvalue>0){temporary = split(commands[desiredid], '#');}
if (desiredvalue>0){saveStrings("/Users/mac/Library/Application Support/minecraft/saves/Datapack test/datapacks/demo/data/demo/functions/init.mcfunction",temporary);}
}

```

Thanks for trying to help me anyways though
