Thing that counts things like [X] in the comments of YouTube videos.
For any case, the first steps:
- Install Node.js
- Download this code (or git clone it if you know how and care).
- Create a Google API project
- Enable the YouTube Data API v3.
- Copy
config.example.toml
toconfig.toml
. - Open
config.toml
in a text editor (eg Notepad, TextEdit, Visual Studio Code) and set the settings to what you need them to be (there are explanations in the file) - Run in a command prompt / terminal in the Bracketcounter folder (if you don't know what the command prompt is, Google it):
npm install --dev
npx tsc
The next setup stage depends on what you want to use Bracketcounter to do. If you want to count other people's videos, or if you want to count your own videos, but aren't bothered about counting votes caught in the "Held for review" section of YouTube Studio, go with the easy setup. If you need to count held comments on your own videos, you'll have to use the harder setup.
This is the easiest setup, and it should be accurate enough for most cases. This is also the best setup for counting on other people's videos since you can't look at other people's spam comments anyway.
However, the drawback of this API-key based setup is that it isn't authenticated, therefore it isn't able to count comments that are "Held for review" in YouTube Studio on your own videos. You might want this, but often this results in legitimate votes being caught in the filters, so it's best to go through them manually and approve real vote comments. If this isn't viable you should use the slightly less easy setup below which can count comments in all 3 tabs.
- Go here, click Create Credentials and pick "API key".
- Copy the API key into the
key
section of the config file. Make sureisAuthenticated
isfalse
.
This allows you to count "held for review" comments, but it is slightly harder to set up. Note: Do not use this method when you are counting videos not uploaded by you, or you will get errors!
- Go here, click Create Credentials and pick "OAuth client ID". Set the type to "Desktop app".
- Copy the client ID and secret into the
clientId
andclientSecret
section of the config file, and setisAuthenticated
totrue
. - The first time you run Bracketcounter you will be asked to paste in a link to your browser (or it might open automatically), where you can sign in with Google. Make sure to pick the YouTube channel where you uploaded the videos to. The result of this is saved to
authdata.json
, don't share it! Note: You may see a "Google hasn't verified this app" screen, you can ignore it by going to Advanced and then "Go to app (unsafe)**.
Once you've done the setup, run, node dist/yt-comments.js
in the terminal. Once the results are done counting they should appear in the command prompt/terminal window. Press Ctrl+C to exit safely once the count is complete. For the most accurate numbers and data analysis, you should process savestate.json
with the data tools.
If you're having any trouble feel free to ask me.
- If you pin a comment written by someone other than whoever uploaded the video, then live updating will not work. Videos with pinned comments by the uploader and no pinned comment work fine. This also doesn't cause any problems if you aren't using live counting functionality. (Technical explanation: The "fast reload" works by scanning comments until it finds one that it has already seen. Since pinned comments are... pinned, they will always appear first and therefore be seen and stop the scanning. There is a workaround in the code which doesn't stop scanning if the reply is by the uploader of the video, but there is no way to check if a comment is pinned in the YouTube API, so other pinned comments don't work and break the counter.)
- The code is very messy :P
This is completely optional, and you don't need to do it if you just want voting results, but if you want your own "live counting" style website like the old figgyc's Bracketcounter website, then you can set it up. This requires technical knowledge of network administration.
- Set
liveMode
totrue
in the config file. - Clone bracketcounter-web.
- Run
cd bracketcounter-web; npm i --dev; tsc
in a command prompt/terminal. - Set up a "reverse proxy" server, like Caddy or Nginx, as follows:
- Proxy the websocket (default port 9764) to
/socket
. - Serve the bracketcounter-web
dist
folder at/
(the web root)
- Proxy the websocket (default port 9764) to
- Run your web server and
node dist/yt-comments.js
at the same time.