diff options
| author | A Farzat <a@farzat.xyz> | 2025-08-21 15:27:28 +0300 |
|---|---|---|
| committer | A Farzat <a@farzat.xyz> | 2025-08-21 15:27:28 +0300 |
| commit | f6e902500b8bf325a0ff5b443e8d3e0d528ce58f (patch) | |
| tree | ce9c8f666334aefa0270100cbe3c5327771abb65 | |
| parent | a9b512db0db44170afd96b6b4547594286425f81 (diff) | |
| download | csca5028-f6e902500b8bf325a0ff5b443e8d3e0d528ce58f.tar.gz csca5028-f6e902500b8bf325a0ff5b443e8d3e0d528ce58f.zip | |
Create a script that collects videos from a few channels
| -rwxr-xr-x | data_collector.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/data_collector.py b/data_collector.py new file mode 100755 index 0000000..9da9404 --- /dev/null +++ b/data_collector.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python + +from time import sleep +from components.database import subscriptions +from components.subscriptions.main import Subscription, default_scheduler + +subs_to_fetch = ["fiwzLy-8yKzIbsmZTzxDgw", "Ef0-WZoqYFzLZtx43KPvag", + "PF-oYb2-xN5FbCXy0167Gg", "hlgI3UHCOnwUGzWzbJ3H5w", ] +for id in subs_to_fetch: + sub_dict = subscriptions.find_one({"_id": "yt:channel:"+id}) + if sub_dict: + sub = Subscription(**sub_dict) + else: + sub = Subscription( + _id="yt:channel:"+id, + link="http://www.youtube.com/feeds/videos.xml?channel_id=UC"+id, + time_between_fetches=5, + ) + sub.insert() + sub.initialise_job() + +while True: + default_scheduler.run_pending() + sleep(60) |
