aboutsummaryrefslogtreecommitdiff
path: root/api/utils.py
diff options
context:
space:
mode:
authorA Farzat <a@farzat.xyz>2025-10-12 14:57:22 +0300
committerA Farzat <a@farzat.xyz>2025-10-12 14:57:22 +0300
commite4d8ae3d88aac184ba7c15c3683630ea8e182e61 (patch)
tree5dfd71824a4a33a96a73faeb8e3166aa887adcab /api/utils.py
parent20c63cb6b18ee70b874ba63c1ad6212af165b291 (diff)
downloadcsca5028-e4d8ae3d88aac184ba7c15c3683630ea8e182e61.tar.gz
csca5028-e4d8ae3d88aac184ba7c15c3683630ea8e182e61.zip
Rename wsgi directory to api (more appropriate)HEADdeploy
Diffstat (limited to 'api/utils.py')
-rw-r--r--api/utils.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/api/utils.py b/api/utils.py
new file mode 100644
index 0000000..2c9e1e5
--- /dev/null
+++ b/api/utils.py
@@ -0,0 +1,14 @@
+from typing import Any, Dict, List
+from components.subscriptions.main import Subscription
+from components.subscriptions.typing import SubsDict
+from components.videos import VideoTuple
+
+def vid_dicts_from_tuple_list(tuple_list: List[VideoTuple]) -> List[Dict[str, Any]]:
+ return [VideoTuple._make(vid)._asdict() for vid in tuple_list]
+
+def sub_info_from_dict(sub_dict: SubsDict) -> Dict[str, Any]:
+ return {
+ **sub_dict,
+ "videos": len(sub_dict["videos"]),
+ "new_vids": len(Subscription(**sub_dict).get_new_vids()),
+ }