Refresh older sub first + save subscriptions
This commit is contained in:
parent
a1c07d2aac
commit
693564bb04
4 changed files with 128 additions and 85 deletions
|
|
@ -1,3 +1,5 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
|
||||
from .youtube_objects import ChannelSnippet, SearchResultItem
|
||||
|
|
@ -12,6 +14,17 @@ class SubscriptionInfo:
|
|||
shorts_list: list[SearchResultItem] = field(default_factory=list)
|
||||
video_list: list[SearchResultItem] = field(default_factory=list)
|
||||
|
||||
@staticmethod
|
||||
def from_dict(info: dict) -> SubscriptionInfo:
|
||||
channel_info: dict | None = info.get('channel_info')
|
||||
return SubscriptionInfo(
|
||||
name=info['name'],
|
||||
channel_id=info['channel_id'],
|
||||
last_update=info['last_update'],
|
||||
channel_info=ChannelSnippet.from_dict(channel_info) if channel_info is not None else None,
|
||||
shorts_list=[SearchResultItem.from_dict(s) for s in info['shorts_list']],
|
||||
video_list=[SearchResultItem.from_dict(s) for s in info['video_list']])
|
||||
|
||||
|
||||
Subscriptions = dict[str, SubscriptionInfo]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue