Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
[Python] YouTube subscriber watchdog
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="griimnak" data-source="post: 450216" data-attributes="member: 35695"><p style="text-align: center"><span style="font-size: 26px"><strong>ytwatchdog-py</strong></span></p> <p style="text-align: center"></p> <p style="text-align: center">[SPOILER=media]</p> <p style="text-align: center"><img src="https://i.imgur.com/pSsrb2K.png" alt="" class="fr-fic fr-dii fr-draggable " style="" /></p> <p style="text-align: center">[/SPOILER]</p> <p style="text-align: center"></p> <p style="text-align: center">This is a simple watchdog script that watches youtube subscription count by scraping channel html with <a href="https://www.crummy.com/software/BeautifulSoup/bs4/doc/" target="_blank">bs4</a>.</p><p></p><p><span style="font-size: 18px"><strong>Source:</strong></span></p><p><a href="https://github.com/griimnak/ytwatchdog-py" target="_blank">https://github.com/griimnak/ytwatchdog-py</a></p><p></p><p><span style="font-size: 18px"><strong>Usage:</strong></span></p><p><span style="font-size: 18px">[ICODE]python ytwatchdog.py https://youtube.com/user/PewDiePie[/ICODE]</span></p><p></p><p><span style="font-size: 18px"><strong>Config:</strong></span></p><p>[CODE=Python]</p><p>"""</p><p>Seconds to minutes cheat sheet</p><p>120 -> 2m</p><p>600 -> 10m</p><p>3600 -> 1hr</p><p>43200 -> 12hr</p><p>86400 -> 24hr</p><p>"""</p><p>URL = sys.argv[1] if len(sys.argv) > 1 else "https://youtube.com/user/PewDiePie" # URL = ""</p><p></p><p>watch_subs = True # or False</p><p></p><p>sleep_time = 600 # seconds</p><p></p><p>[/CODE]</p><p><span style="color: rgb(184, 49, 47)"><strong>Note: Don't set the sleep time to less than 2 minutes or youtube could block your requests.</strong></span></p><p></p><p></p><p>You can easily add your own events to the function below</p><p>[CODE=Python]</p><p>def compare_sub_count():</p><p> """ Compares sub count of subs and subs_new</p><p> """</p><p> subs = int(data["sub_count"].replace(",", "")) # current data</p><p></p><p> scrape(URL) # renew data</p><p> subs_new = int(data["sub_count"].replace(",", "")) # renewed sub count</p><p></p><p> # Subs lost</p><p> if(subs > subs_new):</p><p> print(data["channel_name"] + " lost", subs - subs_new, "subscribers :(")</p><p> print(subs_new, "-", subs,)</p><p></p><p> # Subs gained</p><p> if(subs < subs_new):</p><p> print(data["channel_name"] + " gained", subs_new - subs, "subscribers :D")</p><p></p><p> # No change</p><p> if(subs == subs_new):</p><p> print("No change in subscription count.")</p><p> print(data["sub_count"])</p><p> print("\n[" + time.ctime() +"] Subscriber watchdog renewing..")</p><p>[/CODE]</p></blockquote><p></p>
[QUOTE="griimnak, post: 450216, member: 35695"] [CENTER][SIZE=7][B]ytwatchdog-py[/B][/SIZE] [SPOILER=media] [IMG]https://i.imgur.com/pSsrb2K.png[/IMG] [/SPOILER] This is a simple watchdog script that watches youtube subscription count by scraping channel html with [URL='https://www.crummy.com/software/BeautifulSoup/bs4/doc/']bs4[/URL].[/CENTER] [SIZE=5][B]Source:[/B][/SIZE] [URL]https://github.com/griimnak/ytwatchdog-py[/URL] [SIZE=5][B]Usage:[/B] [ICODE]python ytwatchdog.py https://youtube.com/user/PewDiePie[/ICODE][/SIZE] [SIZE=5][B]Config:[/B][/SIZE] [CODE=Python] """ Seconds to minutes cheat sheet 120 -> 2m 600 -> 10m 3600 -> 1hr 43200 -> 12hr 86400 -> 24hr """ URL = sys.argv[1] if len(sys.argv) > 1 else "https://youtube.com/user/PewDiePie" # URL = "" watch_subs = True # or False sleep_time = 600 # seconds [/CODE] [COLOR=rgb(184, 49, 47)][B]Note: Don't set the sleep time to less than 2 minutes or youtube could block your requests.[/B][/COLOR] You can easily add your own events to the function below [CODE=Python] def compare_sub_count(): """ Compares sub count of subs and subs_new """ subs = int(data["sub_count"].replace(",", "")) # current data scrape(URL) # renew data subs_new = int(data["sub_count"].replace(",", "")) # renewed sub count # Subs lost if(subs > subs_new): print(data["channel_name"] + " lost", subs - subs_new, "subscribers :(") print(subs_new, "-", subs,) # Subs gained if(subs < subs_new): print(data["channel_name"] + " gained", subs_new - subs, "subscribers :D") # No change if(subs == subs_new): print("No change in subscription count.") print(data["sub_count"]) print("\n[" + time.ctime() +"] Subscriber watchdog renewing..") [/CODE] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
[Python] YouTube subscriber watchdog
Top