summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorA Farzat <a@farzat.xyz>2025-10-08 18:10:46 +0300
committerA Farzat <a@farzat.xyz>2025-10-08 18:10:46 +0300
commit1d7afc2f1372e46a102d088242bbccec5ba5af4e (patch)
treeaa0a83acedb3b4c63ebfc1478228b55e6cfa29da
parent05607dc845a1dd111fd393478acf084ca3532081 (diff)
downloadcsca5028-1d7afc2f1372e46a102d088242bbccec5ba5af4e.tar.gz
csca5028-1d7afc2f1372e46a102d088242bbccec5ba5af4e.zip
Add a title attribute to subscriptions
-rw-r--r--components/subscriptions/main.py1
-rw-r--r--components/subscriptions/typing.py1
-rwxr-xr-xreset_database.py16
-rw-r--r--tests/analyser.py6
-rw-r--r--tests/feed.py7
-rw-r--r--wsgi/__init__.py1
6 files changed, 20 insertions, 12 deletions
diff --git a/components/subscriptions/main.py b/components/subscriptions/main.py
index f9bcf21..689e1a4 100644
--- a/components/subscriptions/main.py
+++ b/components/subscriptions/main.py
@@ -14,6 +14,7 @@ from components.videos import VideoTuple
class Subscription:
_id: str
link: str
+ title: str
time_between_fetches: int
last_fetch: datetime = datetime.min.replace(tzinfo=UTC)
last_video_update: datetime = datetime.min.replace(tzinfo=UTC)
diff --git a/components/subscriptions/typing.py b/components/subscriptions/typing.py
index c16d636..3e49d53 100644
--- a/components/subscriptions/typing.py
+++ b/components/subscriptions/typing.py
@@ -6,6 +6,7 @@ from components.videos import VideoTuple
class SubsDict(TypedDict):
_id: str
link: str
+ title: str
time_between_fetches: int # In seconds.
last_fetch: datetime
last_video_update: datetime
diff --git a/reset_database.py b/reset_database.py
index 075e408..0c0d15a 100755
--- a/reset_database.py
+++ b/reset_database.py
@@ -6,11 +6,11 @@ from components.subscriptions.main import Subscription
from components.videos import VideoTuple
subscriptions.delete_many({})
-for short_id in ['fiwzLy-8yKzIbsmZTzxDgw', 'Ef0-WZoqYFzLZtx43KPvag',
- 'PF-oYb2-xN5FbCXy0167Gg', 'hlgI3UHCOnwUGzWzbJ3H5w', ]:
- sub = Subscription(
- _id='yt:channel:'+short_id,
- link='http://www.youtube.com/feeds/videos.xml?channel_id=UC'+short_id,
- time_between_fetches=300,
- )
- sub.insert()
+# for short_id in ['fiwzLy-8yKzIbsmZTzxDgw', 'Ef0-WZoqYFzLZtx43KPvag',
+# 'PF-oYb2-xN5FbCXy0167Gg', 'hlgI3UHCOnwUGzWzbJ3H5w', ]:
+# sub = Subscription(
+# _id='yt:channel:'+short_id,
+# link='http://www.youtube.com/feeds/videos.xml?channel_id=UC'+short_id,
+# time_between_fetches=300,
+# )
+# sub.insert()
diff --git a/tests/analyser.py b/tests/analyser.py
index c698942..9d5abdf 100644
--- a/tests/analyser.py
+++ b/tests/analyser.py
@@ -19,7 +19,8 @@ class TestAnalyser(TestCase):
self.sub1 = Subscription(
_id="yt:channel:hlgI3UHCOnwUGzWzbJ3H5w",
- link=r"tests/data/feed@ytnnews24@001.xml",
+ link="tests/data/feed@ytnnews24@001.xml",
+ title="YTN",
time_between_fetches=1,
)
self.sub1._collection = self.collection
@@ -84,7 +85,8 @@ class TestAnalyser(TestCase):
self.assertTrue(vid.analysed)
self.sub2 = Subscription(
_id="yt:channel:7YOGHUfC1Tb6E4pudI9STA",
- link=r"tests/data/feed@mentaloutlaw@001.xml",
+ link="tests/data/feed@mentaloutlaw@001.xml",
+ title="YTN",
time_between_fetches=1,
)
self.sub2._collection = self.collection
diff --git a/tests/feed.py b/tests/feed.py
index 97a60ef..a9856a8 100644
--- a/tests/feed.py
+++ b/tests/feed.py
@@ -16,6 +16,7 @@ class TestFeeds(TestCase):
sub = Subscription(
_id="yt:channel:bla",
link="http://www.youtube.com/feeds/videos.xml?channel_id=UCbla",
+ title="bla",
time_between_fetches=5,
)
sub._collection = self.collection
@@ -28,7 +29,8 @@ class TestFeeds(TestCase):
def test_feed_fetch(self) -> None:
sub = Subscription(
_id="yt:channel:hlgI3UHCOnwUGzWzbJ3H5w",
- link=r"tests/data/feed@ytnnews24@001.xml",
+ link="tests/data/feed@ytnnews24@001.xml",
+ title="YTN",
time_between_fetches=1,
)
sub._collection = self.collection
@@ -43,7 +45,8 @@ class TestFeeds(TestCase):
def test_feed_update(self) -> None:
sub = Subscription(
_id="yt:channel:hlgI3UHCOnwUGzWzbJ3H5w",
- link=r"tests/data/feed@ytnnews24@001.xml",
+ link="tests/data/feed@ytnnews24@001.xml",
+ title="YTN",
time_between_fetches=1,
)
sub._collection = self.collection
diff --git a/wsgi/__init__.py b/wsgi/__init__.py
index e467f82..dab7b7e 100644
--- a/wsgi/__init__.py
+++ b/wsgi/__init__.py
@@ -33,6 +33,7 @@ def add_sub() -> Dict[str, Any]:
sub = Subscription(
_id=sub_info["id"],
link=sub_info["link"],
+ title=sub_info["title"],
time_between_fetches=int(request.form["time_between_fetches"]),
)
sub.insert()