From f6e902500b8bf325a0ff5b443e8d3e0d528ce58f Mon Sep 17 00:00:00 2001 From: A Farzat Date: Thu, 21 Aug 2025 15:27:28 +0300 Subject: Create a script that collects videos from a few channels --- data_collector.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 data_collector.py (limited to 'data_collector.py') 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) -- cgit v1.2.3-70-g09d2