Skip to content

Commit

Permalink
Make an easy way to check for changes in a stream setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosuav committed Jan 8, 2025
1 parent 5ddecbb commit 9a78d09
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions utils.pike
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,27 @@ __async__ void lookup() {
}
}

@"Watch a channel for setup changes (currently just cat/title)":
__async__ void watch() {
array(string) names = G->G->args[Arg.REST];
if (!sizeof(names)) {werror("Need a username\n"); return;}
array ids = await(Concurrent.all(get_user_id(names[*])));
array prev = allocate(sizeof(ids));
while (1) {
foreach (ids; int i; int id) {
mapping data = await(twitch_api_request("https://api.twitch.tv/helix/channels?broadcaster_id=" + id));
mapping setup = data->data[0];
string cur = setup->game_name + ": " + setup->title;
if (cur != prev[i]) {
write(names[i] + ": " + string_to_utf8(cur) + "\n");
if (prev[i]) Process.create_process(({"vlc", "/home/rosuav/Music/The Kick-Q3Kvu6Kgp88.webm"}));
prev[i] = cur;
}
}
sleep(60);
}
}

@"Test MustardScript parsing and reconstitution":
__async__ void script() {
//Rather than actually load up all the builtins, just make sure the names can be validated.
Expand Down

0 comments on commit 9a78d09

Please sign in to comment.