diff options
| author | A Farzat <a@farzat.xyz> | 2025-10-06 13:14:34 +0300 |
|---|---|---|
| committer | A Farzat <a@farzat.xyz> | 2025-10-06 13:14:34 +0300 |
| commit | 6e2520431a8108c5cc310d94b60aa47218c87787 (patch) | |
| tree | e8ac7a7e99dc70a12900a2b4babdccce5d5eac33 /wsgi/utils.py | |
| parent | 4434445995512c68ac5a0aa6c81450142bb1e100 (diff) | |
| download | csca5028-6e2520431a8108c5cc310d94b60aa47218c87787.tar.gz csca5028-6e2520431a8108c5cc310d94b60aa47218c87787.zip | |
Add new Flask routes to get subscriptions info
Diffstat (limited to 'wsgi/utils.py')
| -rw-r--r-- | wsgi/utils.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/wsgi/utils.py b/wsgi/utils.py new file mode 100644 index 0000000..2c9e1e5 --- /dev/null +++ b/wsgi/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()), + } |
