Show DevBest [Python] YouTube subscriber watchdog

griimnak

You're a slave to the money then you die
Jul 20, 2013
955
794
ytwatchdog-py

pSsrb2K.png

This is a simple watchdog script that watches youtube subscription count by scraping channel html with .​

Source:


Usage:
python ytwatchdog.py https://youtube.com/user/PewDiePie


Config:
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
Note: Don't set the sleep time to less than 2 minutes or youtube could block your requests.


You can easily add your own events to the function below
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..")
 
Last edited:

Users who are viewing this thread

Top