VideoHistory

add

Add a video to the history.

has

Check if a video is in the history.

FileVideoHistory

class ytnoti.models.history.FileVideoHistory(*, dir_path: str | PathLike[str], num_videos: int = 100)

Bases: VideoHistory

Represents a file-based history of videos.

__init__(*, dir_path: str | PathLike[str], num_videos: int = 100) None

Create a new FileVideoHistory instance.

Parameters:
  • dir_path – The path to the directory to store the history files

  • num_videos – The number of videos to keep in the history file. If the number of videos exceeds this value, the oldest videos will be removed.

async add(video: Video) None

Add a video to the history.

Parameters:

video – The video to add.

async has(video: Video) bool

Check if a video is in the history.

Parameters:

video – The video to check.

Returns:

True if the video is in the history, False otherwise.

InMemoryVideoHistory

class ytnoti.models.history.InMemoryVideoHistory(*, cache_size: int = 5000)

Bases: VideoHistory

Represents an in-memory history of notifications.

__init__(*, cache_size: int = 5000) None

Create a new InMemoryVideoHistory instance.

Parameters:

cache_size – The size of the cache. If the cache is full, the oldest video will be removed.

property cache_size: int

Get the size of the cache.

Returns:

The size of the cache.

async add(video: Video) None

Add a video to the history.

Parameters:

video – The video to add.

async has(video: Video) bool

Check if a video is in the history.

Parameters:

video – The video to check.

Returns:

True if the video is in the history, False otherwise.