viewer-subscriber-counter (Youtube and Twitch)

viewer-subscriber-counter (Youtube and Twitch) 0.2

sokolov.teach

New Member
sokolov.teach submitted a new resource:

OBS-channel-stats - Script to display the total number of viewers and subscribers from YouTube and Twitch

View attachment 99204

Overview​

This script for OBS displays live viewer counts on YouTube and Twitch, as well as the total number of YouTube subscribers and Twitch followers. It was originally developed for a client but I hope it will be useful for other people too.

Note: The YouTube subscriber count may not be exact for channels with over 1,000 subscribers, as the count is rounded due to limitations in Google's API. (because Google takes your data...

Read more about this resource...
 

hmeneses

Member
by any chance, do you know how to fix this

[OBS-channel-stats.py] Traceback (most recent call last):
[OBS-channel-stats.py] File "C:\Program Files/obs-studio/data/obs-plugins/frontend-tools/scripts\OBS-channel-stats.py", line 6, in <module>
[OBS-channel-stats.py] import requests
[OBS-channel-stats.py] ModuleNotFoundError: No module named 'requests'
 

sokolov.teach

New Member
by any chance, do you know how to fix this

[OBS-channel-stats.py] Traceback (most recent call last):
[OBS-channel-stats.py] File "C:\Program Files/obs-studio/data/obs-plugins/frontend-tools/scripts\OBS-channel-stats.py", line 6, in <module>
[OBS-channel-stats.py] import requests
[OBS-channel-stats.py] ModuleNotFoundError: No module named 'requests'
Yes, sorry, one thing I forgot, request module does not come with standard python library. You need to open your terminal (cmd) and type in:
pip install requests

The first command could not work, if PIP is not in the PATH, so you can try other command that can help:
python3 -m pip install requests

I hope that helps! If not, please message here, so I could fix the issue. I'll update documentation to mention this step in installation.
 

sokolov.teach

New Member
by any chance, do you know how to fix this

[OBS-channel-stats.py] Traceback (most recent call last):
[OBS-channel-stats.py] File "C:\Program Files/obs-studio/data/obs-plugins/frontend-tools/scripts\OBS-channel-stats.py", line 6, in <module>
[OBS-channel-stats.py] import requests
[OBS-channel-stats.py] ModuleNotFoundError: No module named 'requests'
Also, saw in your Youtube chat and channel updater that you use urllib.request instead, that comes with standard library. I'll try to update the script with your approach, it'll make this unnecessary installation step obsolete.
BTW, you also using lxml library , that doesn't comes with python by default, so requires manual installation.
And you using some parsing magic to find URL of the live stream. I need to look into this, so I could remove the whole finding live stream URL through search requests that costs 100 points. This way I can make updates faster than once a minute.
Even with this, getting API keys is still daunting task. Maybe better approach is to parse html page. It is inconvenient, because it'll require additional parsing library, but less inconvenient than getting API keys. On the other hand Youtube and Twitch are changing their pages so often, that it'll be hell to update script every time they making such changes.
 

sokolov.teach

New Member
sokolov.teach updated viewer-subscriber-counter (Youtube and Twitch) with a new update entry:

Separate Text Sources for YouTube & Twitch and removing 'requests' Module:

New Features:​

  1. Separate Text Sources for YouTube & Twitch: Now, you have the option to display viewer and subscriber counts for YouTube and Twitch in separate text sources in OBS. This gives you more control over how you show your stats during streams.
  2. Combined Counts: If you prefer to use the same text source for both platforms, the script will automatically combine the counts for you, giving a total view across YouTube and Twitch.
...

Read the rest of this update entry...
 

UroDoc

New Member
Our Church manually tracks Sunday streaming service viewers for both YouTube and Facebook. Is there any possibility to add Facebook to the script?
 

CraftD

New Member
Hi there. I am trying to use this but when I load the script I get this message. I'm using OBS 30.1 - I also get no options to add channel id and keys etc
[OBS-channel-stats.py] Traceback (most recent call last):
[OBS-channel-stats.py] File "C:\Program Files/obs-studio/data/obs-plugins/frontend-tools/scripts\OBS-channel-stats.py", line 47, in <module>
[OBS-channel-stats.py] logging.basicConfig(filename=log_file_path, filemode='a', format='%(asctime)s - %(message)s', level=logging.INFO)
[OBS-channel-stats.py] File "C:\Users\darre\AppData\Local\Programs\Python\Python310\lib\logging\__init__.py", line 2040, in basicConfig
[OBS-channel-stats.py] h = FileHandler(filename, mode,
[OBS-channel-stats.py] File "C:\Users\darre\AppData\Local\Programs\Python\Python310\lib\logging\__init__.py", line 1169, in __init__
[OBS-channel-stats.py] StreamHandler.__init__(self, self._open())
[OBS-channel-stats.py] File "C:\Users\darre\AppData\Local\Programs\Python\Python310\lib\logging\__init__.py", line 1201, in _open
[OBS-channel-stats.py] return open_func(self.baseFilename, self.mode,
[OBS-channel-stats.py] PermissionError: [Errno 13] Permission denied: 'C:\\Program Files\\obs-studio\\data\\obs-plugins\\frontend-tools\\scripts\\obs_channel_stats_log.txt'
 

sokolov.teach

New Member
Hi there. I am trying to use this but when I load the script I get this message. I'm using OBS 30.1 - I also get no options to add channel id and keys etc
It looks like we have a permission issue, script tries to create a log file, and don't have a permissions to do this in a folder where it's located. I can't remove logging, it's to useful to search for the bugs, so let's just move the script!
  1. Find the Script: Navigate to C:\Program Files\obs-studio\data\obs-plugins\frontend-tools\scripts\ and locate the OBS-channel-stats.py file.
  2. Move the Script: Cut and paste the file into a directory that typically doesn't require special access rights. Documents, for example, located at C:\Users\YourUsername\Documents\.
  3. Update OBS:
    • Open OBS and go to Tools > Scripts.
    • Remove the old script entry.
    • Click on the + button to add the script from its new location in the Documents folder.
  4. Test It Out: Run OBS to see if the script works without the permission error.
Let me know how it goes!
 

TJ the Tism

New Member
Hey I was wondering how I can change the text source to always say "Viewers:" before the actual viewer count? Because it keeps removing that text every time it updates. I have little very basic knowledge of Python so idk what to edit in the .py file.
 

sokolov.teach

New Member
Hey I was wondering how I can change the text source to always say "Viewers:" before the actual viewer count? Because it keeps removing that text every time it updates. I have little very basic knowledge of Python so idk what to edit in the .py file.
I would suggest using 2 different text sources for that. One for a script to update and the other just says "Viewers" as shown on the picture. Or do you mean that you want a placeholder for a number itself?

1727390866805.png
 

sokolov.teach

New Member
Can't use it on Mac??
Very limited support. I was able to run it first time on a client machine, but it took a lot of tinkering. It was required to install certain version of python (not the usual way) and make mac to use this certain version.
I do not have a mac on hands, so I can not really help here.
 
Top