### Basic YouTubeNotifier Usage Example Source: https://ytnoti.readthedocs.io/en/latest/quickstart.html An example demonstrating how to initialize YouTubeNotifier, set up an asynchronous listener for new video uploads, and subscribe to a channel. ```python from pyngrok import ngrok from ytnoti import YouTubeNotifier, Video ngrok.set_auth_token("Your ngrok token here") notifier = YouTubeNotifier() @notifier.upload() async def listener(video: Video): print(f"New video from {video.channel.name}: {video.title}") notifier.subscribe("UCuFFtHWoLl5fauMMD5Ww2jA") # Channel ID of CBC News notifier.run() ``` -------------------------------- ### Install ytnoti Source: https://ytnoti.readthedocs.io/en/latest/index.html Install the ytnoti library using pip. This library requires Python 3.11 or higher. ```bash pip install ytnoti ``` -------------------------------- ### Simple Example with ngrok Source: https://ytnoti.readthedocs.io/en/latest/index.html This example demonstrates how to use ytnoti with ngrok to receive video upload notifications. It sets up a listener for a specific channel and prints new video information. ngrok is not recommended for production environments. ```python from pyngrok import ngrok from ytnoti import YouTubeNotifier, Video ngrok.set_auth_token("Your ngrok token here") notifier = YouTubeNotifier() @notifier.upload() async def listener(video: Video) -> None: print(f"New video from {video.channel.name}: {video.title}") notifier.subscribe("UCuFFtHWoLl5fauMMD5Ww2jA") # Channel ID of CBC News notifier.run() ``` -------------------------------- ### Simple Example with Custom Domain Source: https://ytnoti.readthedocs.io/en/latest/index.html This example shows how to use ytnoti with a custom domain to receive video upload notifications. It configures the notifier with a callback URL and sets up a listener for a specific channel. ```python from ytnoti import YouTubeNotifier, Video notifier = YouTubeNotifier(callback_url="https://yourdomain.com") @notifier.upload() async def listener(video: Video) -> None: print(f"New video from {video.channel.name}: {video.title}") notifier.subscribe("UCuFFtHWoLl5fauMMD5Ww2jA") # Channel ID of CBC News notifier.run() ``` -------------------------------- ### run Source: https://ytnoti.readthedocs.io/en/latest/classes/youtube_notifier.html Starts the FastAPI server to receive push notifications. This method is used for running the notifier in the foreground. ```APIDOC ## run ### Description Starts the FastAPI server to receive push notifications. This method is used for running the notifier in the foreground. ### Method Not specified (likely a method call within the SDK) ### Endpoint Not applicable (SDK method) ### Parameters None explicitly documented for this method signature. ``` -------------------------------- ### AsyncYouTubeNotifier.run Source: https://ytnoti.readthedocs.io/en/latest/_autosummary/ytnoti.AsyncYouTubeNotifier.run.html Starts the FastAPI server to receive push notifications in an existing event loop and waits until the server stops. ```APIDOC ## AsyncYouTubeNotifier.run() ### Description Starts the FastAPI server to receive push notifications in an existing event loop and waits until the server stops. ### Method Asynchronous function call ### Parameters #### Keyword-only Parameters * **host** (str) - Optional - The host to run the FastAPI server on. Defaults to '0.0.0.0'. * **port** (int) - Optional - The port to run the FastAPI server on. Defaults to 8000. * **log_level** (int) - Optional - The log level to use for the uvicorn server. Defaults to 30. * **app** (FastAPI | None) - Optional - The FastAPI app instance to use. If not provided, a new instance will be created. * **configs** (object) - Optional - Additional arguments to pass to the Config class of uvicorn. ### Raises * **ValueError** - If the given app instance has a route that conflicts with the notifier’s routes. ``` -------------------------------- ### YouTubeNotifier.run Source: https://ytnoti.readthedocs.io/en/latest/_autosummary/ytnoti.YouTubeNotifier.run.html Starts the FastAPI server to receive push notifications in the current thread and waits until the server stops. ```APIDOC ## YouTubeNotifier.run ### Description Starts the FastAPI server to receive push notifications in the current thread and waits until the server stops. ### Method Not applicable (this is a Python method call). ### Endpoint Not applicable (this is a Python method call). ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **host** (str) - Optional - The host to run the FastAPI server on. Defaults to '0.0.0.0'. * **port** (int) - Optional - The port to run the FastAPI server on. Defaults to 8000. * **app** (FastAPI | None) - Optional - The FastAPI app instance to use. If not provided, a new instance will be created. * **log_level** (int) - Optional - The log level to use for the uvicorn server. Defaults to 30. * **configs** (object) - Optional - Additional arguments to pass to the Config class of uvicorn. ### Request Example ```python notifier = YouTubeNotifier() notifier.run() ``` ### Response #### Success Response None (This method runs a server and does not return a value upon successful execution, it runs until the server stops). #### Response Example None ``` -------------------------------- ### run_in_background Source: https://ytnoti.readthedocs.io/en/latest/classes/youtube_notifier.html Starts the FastAPI server to receive push notifications in a separate process. This allows the main application to continue execution. ```APIDOC ## run_in_background ### Description Starts the FastAPI server to receive push notifications in a separate process. This allows the main application to continue execution. ### Method Not specified (likely a method call within the SDK) ### Endpoint Not applicable (SDK method) ### Parameters None explicitly documented for this method signature. ``` -------------------------------- ### add_upload_listener Source: https://ytnoti.readthedocs.io/en/latest/classes/youtube_notifier.html Adds a listener for when a video is uploaded or a live stream is started. This method captures both new content uploads and live stream initiations. ```APIDOC ## add_upload_listener ### Description Adds a listener for when a video is uploaded or a live stream is started. This method captures both new content uploads and live stream initiations. ### Method Not specified (likely a method call within the SDK) ### Endpoint Not applicable (SDK method) ### Parameters None explicitly documented for this method signature. ``` -------------------------------- ### YouTubeNotifier.run_in_background Source: https://ytnoti.readthedocs.io/en/latest/_autosummary/ytnoti.YouTubeNotifier.run_in_background.html Starts the FastAPI server in a separate thread to receive push notifications and returns immediately. This method is useful for running the notification server in the background without blocking the main program execution. ```APIDOC ## YouTubeNotifier.run_in_background ### Description Starts the FastAPI server to receive push notifications in a separate thread and returns immediately. ### Method Signature `run_in_background(_*_ , _host : str = '0.0.0.0'_, _port : int = 8000_, _app : FastAPI | None = None_, _log_level : int = 30_, _** configs: object_) → Iterator[Thread]` ### Parameters #### Keyword-only Parameters * **host** (str) - Optional - The host to run the FastAPI server on. Defaults to '0.0.0.0'. * **port** (int) - Optional - The port to run the FastAPI server on. Defaults to 8000. * **log_level** (int) - Optional - The log level to use for the uvicorn server. Defaults to 30. * **app** (FastAPI | None) - Optional - The FastAPI app instance to use. If not provided, a new instance will be created. * **configs** (object) - Additional arguments to pass to the Config class of uvicorn. ### Returns * Iterator[Thread] - A thread that runs the FastAPI server in the background. ### Raises * **ValueError** - If the given app instance has a route that conflicts with the notifier’s routes. ``` -------------------------------- ### YouTubeNotifier.callback_url Source: https://ytnoti.readthedocs.io/en/latest/_autosummary/ytnoti.YouTubeNotifier.callback_url.html Retrieves the callback URL for the YouTubeNotifier. This URL is only available after the notifier instance has been started. ```APIDOC ## YouTubeNotifier.callback_url ### Description Get the callback URL. If the callback URL was not provided when creating the instance, it will become available after the notifier is started. ### Returns - **callback_url** (str | None) - The callback URL. ``` -------------------------------- ### add_upload_listener Source: https://ytnoti.readthedocs.io/en/latest/_autosummary/ytnoti.AsyncYouTubeNotifier.add_upload_listener.html Adds a listener function to be called when a video is uploaded or a live stream starts on specified YouTube channels. The listener function receives a Video object and must be an awaitable coroutine. If no channel IDs are provided, the listener will be triggered for all channels. ```APIDOC ## AsyncYouTubeNotifier.add_upload_listener ### Description Adds a listener function to be called when a video is uploaded or a live stream starts on specified YouTube channels. The listener function receives a Video object and must be an awaitable coroutine. If no channel IDs are provided, the listener will be triggered for all channels. ### Method Signature `add_upload_listener(_func : Callable[[Video], Awaitable[None]]_, _channel_ids : str | Iterable[str] | None = None_) -> Self` ### Parameters #### func - **_func** (Callable[[Video], Awaitable[None]]) - Required - The listener function to add. This function must be an awaitable coroutine that accepts a Video object. #### channel_ids - **_channel_ids** (str | Iterable[str] | None) - Optional - The channel ID(s) to listen for. If not provided, the listener will be called for all channels. ### Returns - **Self** - The YouTubeNotifier instance to allow for method chaining. ``` -------------------------------- ### AsyncYouTubeNotifier.callback_url Source: https://ytnoti.readthedocs.io/en/latest/_autosummary/ytnoti.AsyncYouTubeNotifier.callback_url.html Retrieves the callback URL associated with the AsyncYouTubeNotifier. This URL is accessible after the notifier has been started, especially if it was not initially provided during the object's creation. ```APIDOC ## AsyncYouTubeNotifier.callback_url ### Description Get the callback URL. If the callback URL was not provided when creating the instance, it will become available after the notifier is started. ### Method GET (Implicit) ### Endpoint N/A (Property Access) ### Parameters None ### Response #### Success Response - **callback_url** (str | None) - The callback URL. This will be None if the notifier has not yet started and the URL was not provided during instantiation. ``` -------------------------------- ### YouTubeNotifier.stop() Source: https://ytnoti.readthedocs.io/en/latest/_autosummary/ytnoti.YouTubeNotifier.stop.html Gracefully stops the YouTube notifier and any ngrok processes that may have been started. If the notifier is not currently running, this method has no effect. ```APIDOC ## YouTubeNotifier.stop() ### Description Gracefully stop the notifier and ngrok (if used). If the notifier is not running, this method will do nothing. ### Method `YouTubeNotifier.stop()` ### Returns None ``` -------------------------------- ### YouTubeNotifier.add_upload_listener Source: https://ytnoti.readthedocs.io/en/latest/_autosummary/ytnoti.YouTubeNotifier.add_upload_listener.html Adds a listener function to be called when a video is uploaded or a live stream starts on specified YouTube channels. The listener function receives a Video object and should be an awaitable callable. If no channel IDs are provided, the listener will be triggered for all channels. ```APIDOC ## YouTubeNotifier.add_upload_listener ### Description Add a listener for when a video is uploaded or a live stream is started. ### Method Signature `YouTubeNotifier.add_upload_listener(_func : Callable[[Video], Awaitable[None]]_, _channel_ids : str | Iterable[str] | None = None_) -> Self` ### Parameters #### `func` - **Type**: `Callable[[Video], Awaitable[None]]` - **Description**: The listener function to add. This function must be an awaitable callable that accepts a `Video` object. #### `channel_ids` - **Type**: `str | Iterable[str] | None` - **Description**: The channel ID(s) to listen for. If not provided (None), the listener will be called for all channels. ### Returns - **Type**: `Self` - **Description**: The YouTubeNotifier instance, allowing for method chaining. ``` -------------------------------- ### Configure Ngrok Authentication Source: https://ytnoti.readthedocs.io/en/latest/quickstart.html Set your ngrok authentication token before running the YouTubeNotifier. This is necessary if you do not have a dedicated IP address or domain. ```python from pyngrok import ngrok ngrok.set_auth_token("Your ngrok token here") ``` -------------------------------- ### Implement Custom Video History Class Source: https://ytnoti.readthedocs.io/en/latest/advanced.html Create a custom video history class by inheriting from VideoHistory and implementing the 'add' and 'has' methods. This provides full control over how video history is managed. ```python from ytnoti import YouTubeNotifier, Video, VideoHistory class MyVideoHistory(VideoHistory): async def add(self, video: Video) -> None: pass async def has(self, video: Video) -> bool: return False notifier = YouTubeNotifier(video_history=MyVideoHistory()) ``` -------------------------------- ### is_ready Source: https://ytnoti.readthedocs.io/en/latest/classes/youtube_notifier.html Checks if the notifier is ready to receive push notifications. This is useful for ensuring the service is operational before sending data. ```APIDOC ## is_ready ### Description Checks if the notifier is ready to receive push notifications. This is useful for ensuring the service is operational before sending data. ### Method Not specified (likely a method call within the SDK) ### Endpoint Not applicable (SDK method) ### Parameters None explicitly documented for this method signature. ### Response #### Success Response (Boolean) - **ready** (boolean) - True if the notifier is ready, false otherwise. ``` -------------------------------- ### Configure Uvicorn Host and Port Source: https://ytnoti.readthedocs.io/en/latest/advanced.html Override the default host and port for the uvicorn server used by YouTubeNotifier. This allows you to specify where the server listens for connections. ```python notifier.run(host="123.456.789.012", port=5000) ``` -------------------------------- ### AsyncYouTubeNotifier.is_ready Source: https://ytnoti.readthedocs.io/en/latest/_autosummary/ytnoti.AsyncYouTubeNotifier.is_ready.html Checks if the notifier is ready to receive push notifications. This is a property that returns a boolean value. ```APIDOC ## AsyncYouTubeNotifier.is_ready ### Description Check if the notifier is ready to receive push notifications. ### Returns - **bool**: True if the notifier is ready, False otherwise. ``` -------------------------------- ### YouTubeNotifier.is_ready Source: https://ytnoti.readthedocs.io/en/latest/_autosummary/ytnoti.YouTubeNotifier.is_ready.html Checks if the YouTube notifier is ready to receive push notifications. This is a boolean property that returns `True` if the notifier is ready and `False` otherwise. ```APIDOC ## YouTubeNotifier.is_ready ### Description Checks if the notifier is ready to receive push notifications. ### Returns - **bool**: `True` if the notifier is ready, `False` otherwise. ``` -------------------------------- ### VideoHistory.add Source: https://ytnoti.readthedocs.io/en/latest/_autosummary/ytnoti.models.history.VideoHistory.add.html Adds a video to the history. This method is an abstract asynchronous method. ```APIDOC ## VideoHistory.add ### Description Adds a video to the history. ### Method Asynchronous method (indicated by `async` and `_abstractmethod`) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **video** (_Video_) - The video to add. ### Response #### Success Response None (returns None) #### Response Example None ``` -------------------------------- ### Set Custom Callback URL with IP Address Source: https://ytnoti.readthedocs.io/en/latest/advanced.html Use your own domain or server IP address for the callback URL instead of ngrok. This ensures notifications are sent directly to your server. ```python notifier = YouTubeNotifier(callback_url="https://123.456.789.012") ``` -------------------------------- ### AsyncYouTubeNotifier Methods Source: https://ytnoti.readthedocs.io/en/latest/classes/async_youtube_notifier.html This section details the methods available on the AsyncYouTubeNotifier class for managing YouTube push notifications. ```APIDOC ## AsyncYouTubeNotifier Class Methods ### `add_any_listener` #### Description Adds a listener for any kind of push notification. ### `add_delete_listener` #### Description Adds a listener for when a video is deleted. ### `add_edit_listener` #### Description Adds a listener for when a video is edited. ### `add_upload_listener` #### Description Adds a listener for when a video is uploaded or a live stream is started. ### `any` #### Description Decorates a function to add a listener for any kind of push notification. ### `callback_url` #### Description Gets the callback URL used by the notifier. ### `delete` #### Description Decorates a function to add a listener for when a video is deleted. ### `edit` #### Description Decorates a function to add a listener for when a video is edited. ### `is_ready` #### Description Checks if the notifier is ready to receive push notifications. ### `run` #### Description Starts the FastAPI server to receive push notifications within an existing event loop. ### `run_in_background` #### Description Runs the FastAPI server in an existing event loop and returns immediately. ### `stop` #### Description Gracefully stops the notifier and ngrok if it was used. ### `subscribe` #### Description Subscribes to YouTube channels to receive push notifications. ### `upload` #### Description Decorates a function to add a listener for when a video is uploaded. ``` -------------------------------- ### AsyncYouTubeNotifier.any Source: https://ytnoti.readthedocs.io/en/latest/_autosummary/ytnoti.AsyncYouTubeNotifier.any.html Decorates a function to add a listener for any kind of push notification from YouTube channels. This listener can be configured to monitor specific channel IDs or all channels. ```APIDOC ## AsyncYouTubeNotifier.any ### Description Decorate the function to add a listener for any kind of push notification. ### Method Signature `AsyncYouTubeNotifier.any(_*_ , _channel_ids : str | Iterable[str] | None = None_) → Callable[[Callable[[Video | DeletedVideo], Awaitable[None]]], Callable[[Video | DeletedVideo], Awaitable[None]]]` ### Parameters #### Keyword-Only Parameters * **channel_ids** (str | Iterable[str] | None) - Optional - The channel ID(s) to listen for. If not provided, the listener will be called for all channels. ### Returns The decorator function. ``` -------------------------------- ### AsyncYouTubeNotifier.run_in_background Source: https://ytnoti.readthedocs.io/en/latest/_autosummary/ytnoti.AsyncYouTubeNotifier.run_in_background.html Runs the FastAPI server in an existing event loop and returns immediately. This method is designed for background execution. ```APIDOC ## AsyncYouTubeNotifier.run_in_background ### Description Runs the FastAPI server in an existing event loop and returns immediately. ### Method Signature `run_in_background(_*_ , _host : str = '0.0.0.0'_, _port : int = 8000_, _app : FastAPI | None = None_, _log_level : int = 30_, _** configs: object_) → AsyncIterator[Task]` ### Parameters #### Keyword-Only Parameters * **host** (str) - Optional - The host IP address to bind the server. * **port** (int) - Optional - The port number to bind the server. * **app** (FastAPI | None) - Optional - The FastAPI application to use for serving the server. * **log_level** (int) - Optional - The log level to use for the server. * **configs** (object) - Optional - Additional configurations to pass to the server. ### Returns An asynchronous iterator yielding Tasks. ``` -------------------------------- ### Update Listener Type Hint for @notifier.any() Source: https://ytnoti.readthedocs.io/en/latest/migration.html When using the @notifier.any() decorator, update the type hint for the first argument to accept Video or DeletedVideo. ```python from ytnoti import Video, DeletedVideo @notifier.any() async def listener(video: Video | DeletedVideo) -> None: if isinstance(video, DeletedVideo): return print(video) ``` -------------------------------- ### Integrate with Existing FastAPI Instance Source: https://ytnoti.readthedocs.io/en/latest/advanced.html Pass an existing FastAPI application instance to YouTubeNotifier to integrate it with your current web framework. This allows you to add custom routes and logic to your application. ```python from fastapi import FastAPI from ytnoti import YouTubeNotifier app = FastAPI() # Do whatever you want with the app, like adding routes @app.get("/hello") async def hello(): return {"message": "Hello World"} notifier = YouTubeNotifier(app=app) @notifier.upload() async def listener(video): print(f"New video from {video.channel.name}: {video.title}") notifier.subscribe("UCuFFtHWoLl5fauMMD5Ww2jA") # Channel ID of CBC News notifier.run() ``` -------------------------------- ### YouTubeNotifier.upload Source: https://ytnoti.readthedocs.io/en/latest/_autosummary/ytnoti.YouTubeNotifier.upload.html The `upload` method is a decorator used to register a listener function that will be called whenever a new video is uploaded to one or more specified YouTube channels. If no channel IDs are provided, the listener will be invoked for uploads from any channel. ```APIDOC ## YouTubeNotifier.upload ### Description Decorates a function to add a listener for when a video is uploaded. This listener can be configured to monitor specific YouTube channel IDs or all channels. ### Method Signature `YouTubeNotifier.upload(_*_, channel_ids: str | Iterable[str] | None = None)` ### Parameters #### Keyword-Only Parameters * **channel_ids** (str | Iterable[str] | None) - Optional - The channel ID(s) to listen for. If not provided, the listener will be called for all channels. ### Returns * **Callable[[Callable[[Video], Awaitable[None]]], Callable[[Video], Awaitable[None]]])** - The decorator function, which takes a listener function and returns a wrapped listener function. ``` -------------------------------- ### InMemoryVideoHistory.add Source: https://ytnoti.readthedocs.io/en/latest/classes/video_history.html Adds a video to the in-memory history. If the cache size is exceeded, the oldest video is removed. ```APIDOC ## InMemoryVideoHistory.add ### Description Adds a video to the in-memory history. If the cache size is exceeded, the oldest video is removed. ### Method ASYNC POST ### Endpoint /history/memory/add ### Parameters #### Request Body - **video** (Video) - Required - The video object to add to the history. ``` -------------------------------- ### AsyncYouTubeNotifier.upload Source: https://ytnoti.readthedocs.io/en/latest/_autosummary/ytnoti.AsyncYouTubeNotifier.upload.html Decorates a function to add a listener that is called when a video is uploaded to specified YouTube channels. If no channel IDs are provided, the listener is invoked for uploads from all channels. ```APIDOC ## AsyncYouTubeNotifier.upload ### Description Decorates a function to add a listener for when a video is uploaded. If `channel_ids` is not provided, the listener will be called for all channels. ### Method Decorator ### Parameters #### Keyword-only Parameters * **channel_ids** (str | Iterable[str] | None) - Optional - The channel ID(s) to listen for. If not provided, the listener will be called for all channels. ### Returns * Callable[[Callable[[Video], Awaitable[None]]], Callable[[Video], Awaitable[None]]] - The decorator function. ``` -------------------------------- ### Set Custom Callback URL with Domain Source: https://ytnoti.readthedocs.io/en/latest/advanced.html Configure the notifier to use a custom domain for receiving callback notifications. This is useful for production environments. ```python notifier = YouTubeNotifier(callback_url="https://yourdomain.com") ``` -------------------------------- ### Combine Multiple Decorators for Event Handling Source: https://ytnoti.readthedocs.io/en/latest/quickstart.html Combine different decorators like `@notifier.edit()` and `@notifier.upload()` to create listeners that respond to multiple types of events, optionally filtering by channel. ```python @notifier.edit() @notifier.upload(channel_ids="UCuFFtHWoLl5fauMMD5Ww2jA") async def listener(video: Video): print(f"New video from CBC News: {video.title}") ``` -------------------------------- ### Use File-Based Video History Source: https://ytnoti.readthedocs.io/en/latest/advanced.html Utilize the FileVideoHistory class to persist video history to files, preventing duplicate notifications for edited videos. Specify the directory path for storing history files. ```python from ytnoti import YouTubeNotifier, FileVideoHistory notifier = YouTubeNotifier(video_history=FileVideoHistory(dir_path="video_history")) ``` -------------------------------- ### add_any_listener Source: https://ytnoti.readthedocs.io/en/latest/classes/youtube_notifier.html Adds a listener for any kind of push notification. This is a general-purpose method for capturing all notification types. ```APIDOC ## add_any_listener ### Description Adds a listener for any kind of push notification. This is a general-purpose method for capturing all notification types. ### Method Not specified (likely a method call within the SDK) ### Endpoint Not applicable (SDK method) ### Parameters None explicitly documented for this method signature. ``` -------------------------------- ### subscribe Source: https://ytnoti.readthedocs.io/en/latest/classes/youtube_notifier.html Subscribes to YouTube channels to receive push notifications. This is the primary method for setting up notifications for specific channels. ```APIDOC ## subscribe ### Description Subscribes to YouTube channels to receive push notifications. This is the primary method for setting up notifications for specific channels. ### Method Not specified (likely a method call within the SDK) ### Endpoint Not applicable (SDK method) ### Parameters None explicitly documented for this method signature. ``` -------------------------------- ### add_any_listener Source: https://ytnoti.readthedocs.io/en/latest/_autosummary/ytnoti.AsyncYouTubeNotifier.add_any_listener.html Adds a listener function to be called when any push notification is received for the specified YouTube channels. If no channel IDs are provided, the listener will be invoked for all channels. ```APIDOC ## AsyncYouTubeNotifier.add_any_listener ### Description Adds a listener function to be called when any push notification is received for the specified YouTube channels. If no channel IDs are provided, the listener will be invoked for all channels. ### Method N/A (This is a Python method call) ### Signature `add_any_listener(_func : Callable[[Video | DeletedVideo], Awaitable[None]]_, _channel_ids : str | Iterable[str] | None = None_) -> Self` ### Parameters #### Positional Parameters * **_func** (Callable[[Video | DeletedVideo], Awaitable[None]]) - Required - The listener function to add. * **_channel_ids** (str | Iterable[str] | None) - Optional - The channel ID(s) to listen for. If not provided, the listener will be called for all channels. ### Returns * **Self** - The YouTubeNotifier instance to allow for method chaining. ``` -------------------------------- ### subscribe Source: https://ytnoti.readthedocs.io/en/latest/_autosummary/ytnoti.AsyncYouTubeNotifier.subscribe.html Subscribes to one or more YouTube channels. The subscription is lazy and occurs when the notifier is ready, or immediately if it's already prepared. This method supports method chaining. ```APIDOC ## subscribe ### Description Subscribe to YouTube channels to receive push notifications. This is lazy and will subscribe when the notifier is ready. If the notifier is already ready, it will subscribe immediately. ### Method Signature `async _AsyncYouTubeNotifier.subscribe(_channel_ids : str | Iterable[str]_) → Self` ### Parameters #### Path Parameters * **channel_ids** (str | Iterable[str]) - Required - The channel ID(s) to subscribe to. ### Returns * **Self** - The current instance for method chaining. ### Raises * **ValueError** - If the channel ID is invalid. * **HTTPError** - If failed to verify the channel ID or failed to subscribe due to an HTTP error. ``` -------------------------------- ### YouTubeNotifier.any Source: https://ytnoti.readthedocs.io/en/latest/_autosummary/ytnoti.YouTubeNotifier.any.html Decorates a function to add a listener for any kind of push notification from YouTube channels. If channel IDs are not provided, the listener is called for all channels. ```APIDOC ## YouTubeNotifier.any ### Description Decorate the function to add a listener for any kind of push notification. ### Method Decorator ### Parameters #### Keyword-Only Parameters * **channel_ids** (str | Iterable[str] | None) - Optional - The channel ID(s) to listen for. If not provided, the listener will be called for all channels. ### Returns * Callable[[Callable[[Video | DeletedVideo], Awaitable[None]]], Callable[[Video | DeletedVideo], Awaitable[None]]] - The decorator function. ``` -------------------------------- ### FileVideoHistory.add Source: https://ytnoti.readthedocs.io/en/latest/classes/video_history.html Adds a video to the file-based history. If the history exceeds the configured number of videos, the oldest videos are removed. ```APIDOC ## FileVideoHistory.add ### Description Adds a video to the file-based history. If the history exceeds the configured number of videos, the oldest videos are removed. ### Method ASYNC POST ### Endpoint /history/file/add ### Parameters #### Request Body - **video** (Video) - Required - The video object to add to the history. ``` -------------------------------- ### AsyncYouTubeNotifier.delete Source: https://ytnoti.readthedocs.io/en/latest/_autosummary/ytnoti.AsyncYouTubeNotifier.delete.html Decorate the function to add a listener for when a video is deleted. If `channel_ids` is not provided, the listener will be called for all channels. ```APIDOC ## AsyncYouTubeNotifier.delete ### Description Decorate the function to add a listener for when a video is deleted. ### Method Decorator ### Parameters #### Keyword-only Parameters - **channel_ids** (str | Iterable[str] | None) - Optional - The channel ID(s) to listen for. If not provided, the listener will be called for all channels. ### Returns - Callable[[Callable[[DeletedVideo], Awaitable[None]]], Callable[[DeletedVideo], Awaitable[None]]] - The decorator function. ``` -------------------------------- ### YouTubeNotifier.subscribe Source: https://ytnoti.readthedocs.io/en/latest/_autosummary/ytnoti.YouTubeNotifier.subscribe.html Subscribe to YouTube channels to receive push notifications. This is lazy and will subscribe when the notifier is ready. If the notifier is already ready, it will subscribe immediately. ```APIDOC ## YouTubeNotifier.subscribe ### Description Subscribe to YouTube channels to receive push notifications. This is lazy and will subscribe when the notifier is ready. If the notifier is already ready, it will subscribe immediately. ### Method `YouTubeNotifier.subscribe(_channel_ids : str | Iterable[str]_)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **channel_ids** (str | Iterable[str]) - Required - The channel ID(s) to subscribe to. ### Returns * **Self** - The current instance for method chaining. ### Raises * **ValueError** - If the channel ID is invalid. * **HTTPError** - If failed to verify the channel ID or failed to subscribe due to an HTTP error. ``` -------------------------------- ### AsyncYouTubeNotifier.stop() Source: https://ytnoti.readthedocs.io/en/latest/_autosummary/ytnoti.AsyncYouTubeNotifier.stop.html Gracefully stop the notifier and ngrok (if used). If the notifier is not running, this method will do nothing. ```APIDOC ## AsyncYouTubeNotifier.stop() ### Description Gracefully stop the notifier and ngrok (if used). If the notifier is not running, this method will do nothing. ### Method Asynchronous method call ### Parameters This method does not accept any parameters. ### Response This method does not return any value (None). ``` -------------------------------- ### Upload Event Listener with Specific Channel Source: https://ytnoti.readthedocs.io/en/latest/quickstart.html Use the `@notifier.upload` decorator to trigger a listener function specifically for new uploads from a defined list of channel IDs. ```python @notifier.upload(channel_ids="UCuFFtHWoLl5fauMMD5Ww2jA") async def listener(video: Video): print(f"New video from CBC News: {video.title}") ``` -------------------------------- ### Set Custom Callback URL with Endpoint Source: https://ytnoti.readthedocs.io/en/latest/advanced.html Specify a custom endpoint within your domain for receiving callback notifications. The notifier will use this specific path for all communication. ```python notifier = YouTubeNotifier(callback_url="https://yourdomain.com/endpoint") ``` -------------------------------- ### YouTubeNotifier.add_any_listener Source: https://ytnoti.readthedocs.io/en/latest/_autosummary/ytnoti.YouTubeNotifier.add_any_listener.html Adds a listener function that will be called for any push notification from specified or all YouTube channels. This method returns the YouTubeNotifier instance for chaining. ```APIDOC ## YouTubeNotifier.add_any_listener ### Description Adds a listener function to receive notifications for any video event (new video or deleted video) from specified YouTube channels or all channels if none are specified. The listener function must be an awaitable callable. ### Method This is a method of the `YouTubeNotifier` class. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **func** (Callable[[Video | DeletedVideo], Awaitable[None]]) - Required - The listener function to add. This function will be called with either a `Video` or `DeletedVideo` object and must be an awaitable. * **channel_ids** (str | Iterable[str] | None) - Optional - The channel ID(s) to listen for. If `None`, the listener will be called for all channels. ### Returns * **Self** - The YouTubeNotifier instance, allowing for method chaining. ``` -------------------------------- ### Configure Uvicorn Workers Source: https://ytnoti.readthedocs.io/en/latest/advanced.html Set the number of worker processes for the uvicorn server. This can be used to improve performance and handle more concurrent requests. ```python notifier.run(workers=3) ``` -------------------------------- ### InMemoryVideoHistory.has Source: https://ytnoti.readthedocs.io/en/latest/classes/video_history.html Checks if a specific video is present in the in-memory history. ```APIDOC ## InMemoryVideoHistory.has ### Description Checks if a specific video is present in the in-memory history. ### Method ASYNC GET ### Endpoint /history/memory/has ### Parameters #### Query Parameters - **video** (Video) - Required - The video object to check for in the history. ``` -------------------------------- ### VideoHistory.has Source: https://ytnoti.readthedocs.io/en/latest/_autosummary/ytnoti.models.history.VideoHistory.has.html Checks if a specific video is present in the history. This is an abstract method intended to be implemented by subclasses. ```APIDOC ## VideoHistory.has ### Description Checks if a video is in the history. ### Method Signature `async _VideoHistory.has(_video: Video_) -> bool` ### Parameters #### Path Parameters - **_video** (Video_) - Description: The video to check. ### Returns - **bool** - True if the video is in the history, False otherwise. ``` -------------------------------- ### FileVideoHistory.has Source: https://ytnoti.readthedocs.io/en/latest/classes/video_history.html Checks if a specific video is present in the file-based history. ```APIDOC ## FileVideoHistory.has ### Description Checks if a specific video is present in the file-based history. ### Method ASYNC GET ### Endpoint /history/file/has ### Parameters #### Query Parameters - **video** (Video) - Required - The video object to check for in the history. ``` -------------------------------- ### add_delete_listener Source: https://ytnoti.readthedocs.io/en/latest/classes/youtube_notifier.html Adds a listener specifically for when a video is deleted. This allows for targeted handling of deletion events. ```APIDOC ## add_delete_listener ### Description Adds a listener for when a video is deleted. This allows for targeted handling of deletion events. ### Method Not specified (likely a method call within the SDK) ### Endpoint Not applicable (SDK method) ### Parameters None explicitly documented for this method signature. ``` -------------------------------- ### stop Source: https://ytnoti.readthedocs.io/en/latest/classes/youtube_notifier.html Gracefully stops the notifier and any associated ngrok instances. This ensures a clean shutdown of the service. ```APIDOC ## stop ### Description Gracefully stops the notifier and any associated ngrok instances. This ensures a clean shutdown of the service. ### Method Not specified (likely a method call within the SDK) ### Endpoint Not applicable (SDK method) ### Parameters None explicitly documented for this method signature. ``` -------------------------------- ### add_edit_listener Source: https://ytnoti.readthedocs.io/en/latest/_autosummary/ytnoti.AsyncYouTubeNotifier.add_edit_listener.html Adds a listener function to be called when a video is edited. The listener can be configured to trigger for specific channel IDs or for all channels. ```APIDOC ## AsyncYouTubeNotifier.add_edit_listener ### Description Adds a listener function that is called when a video is edited. This function can be set to trigger for specific channel IDs or for all channels. ### Method This is a method of the `AsyncYouTubeNotifier` class. ### Parameters #### Parameters - **func** (Callable[[Video], Awaitable[None]]) - Required - The listener function to add. This function should accept a Video object and return an awaitable. - **channel_ids** (str | Iterable[str] | None) - Optional - The channel ID(s) to listen for. If not provided, the listener will be called for all channels. ### Returns - **Self** - The YouTubeNotifier instance, allowing for method chaining. ``` -------------------------------- ### AsyncYouTubeNotifier.add_delete_listener Source: https://ytnoti.readthedocs.io/en/latest/_autosummary/ytnoti.AsyncYouTubeNotifier.add_delete_listener.html Registers a listener function to be called when a video is deleted from one or more YouTube channels. The listener function will receive a `DeletedVideo` object as an argument. If `channel_ids` is not specified, the listener will be invoked for deletions across all channels managed by the notifier. ```APIDOC ## AsyncYouTubeNotifier.add_delete_listener ### Description Adds a listener for when a video is deleted. ### Method Signature `AsyncYouTubeNotifier.add_delete_listener(_func : Callable[[DeletedVideo], Awaitable[None]]_, _channel_ids : str | Iterable[str] | None = None_) -> Self` ### Parameters #### `func` - **Type**: `Callable[[DeletedVideo], Awaitable[None]]` - **Description**: The listener function to add. This function should accept a `DeletedVideo` object and return an `Awaitable[None]`. #### `channel_ids` - **Type**: `str | Iterable[str] | None` - **Description**: The channel ID(s) to listen for. If not provided (None), the listener will be called for all channels. ### Returns - **Type**: `Self` - **Description**: The YouTubeNotifier instance to allow for method chaining. ``` -------------------------------- ### AsyncYouTubeNotifier.edit Source: https://ytnoti.readthedocs.io/en/latest/_autosummary/ytnoti.AsyncYouTubeNotifier.edit.html Decorates a function to add a listener for when a video is edited. This method can filter edits by specific channel IDs. ```APIDOC ## AsyncYouTubeNotifier.edit ### Description Decorate the function to add a listener for when a video is edited. ### Method Decorator ### Endpoint N/A (Method Decorator) ### Parameters #### Path Parameters None #### Query Parameters None #### Keyword-Only Parameters * **channel_ids** (str | Iterable[str] | None) - Optional - The channel ID(s) to listen for. If not provided, the listener will be called for all channels. ### Request Example ```python @notifier.edit(channel_ids='UCxxxxxxxxxxxxxxx') async def my_video_edit_listener(video): # Handle video edit event pass ``` ### Response #### Success Response Returns a decorator function that wraps the provided listener function. #### Response Example ```python # The decorator returns a callable that accepts the listener function # and returns a wrapped listener function. ``` ``` -------------------------------- ### callback_url Source: https://ytnoti.readthedocs.io/en/latest/classes/youtube_notifier.html Retrieves the callback URL used by the notifier to receive push notifications. ```APIDOC ## callback_url ### Description Gets the callback URL that the notifier uses to receive push notifications. ### Method Not specified (likely a method call within the SDK) ### Endpoint Not applicable (SDK method) ### Parameters None explicitly documented for this method signature. ``` -------------------------------- ### YouTubeNotifier.edit Source: https://ytnoti.readthedocs.io/en/latest/_autosummary/ytnoti.YouTubeNotifier.edit.html Decorates a function to add a listener for video edits. The listener can be configured to trigger for all channels or specific channel IDs. ```APIDOC ## YouTubeNotifier.edit ### Description Decorates a function to add a listener for when a video is edited. If `channel_ids` is not provided, the listener will be called for all channels. ### Method Signature `edit(_*_ , _channel_ids : str | Iterable[str] | None = None_)` ### Parameters #### Keyword-Only Parameters * **channel_ids** (str | Iterable[str] | None) - Optional - The channel ID(s) to listen for. If not provided, the listener will be called for all channels. ### Returns * Callable[[Callable[[Video], Awaitable[None]]], Callable[[Video], Awaitable[None]]] - The decorator function. ``` -------------------------------- ### YouTubeNotifier.delete Source: https://ytnoti.readthedocs.io/en/latest/_autosummary/ytnoti.YouTubeNotifier.delete.html Decorates a function to add a listener for when a video is deleted. The listener is called for all channels if channel_ids is not provided. ```APIDOC ## YouTubeNotifier.delete ### Description Decorate the function to add a listener for when a video is deleted. The listener will be called for all channels if `channel_ids` is not provided. ### Method Decorator ### Parameters #### Keyword-Only Parameters * **channel_ids** (str | Iterable[str] | None) - Optional - The channel ID(s) to listen for. If not provided, the listener will be called for all channels. ### Returns * Callable[[Callable[[DeletedVideo], Awaitable[None]]], Callable[[DeletedVideo], Awaitable[None]]] - The decorator function. ``` -------------------------------- ### YouTubeNotifier.add_delete_listener Source: https://ytnoti.readthedocs.io/en/latest/_autosummary/ytnoti.YouTubeNotifier.add_delete_listener.html Adds a listener function to be called when a video is deleted from specified YouTube channels. The listener can be configured to monitor all channels or a specific set of channel IDs. ```APIDOC ## YouTubeNotifier.add_delete_listener ### Description Adds a listener function to be called when a video is deleted from specified YouTube channels. The listener can be configured to monitor all channels or a specific set of channel IDs. ### Method `add_delete_listener` ### Signature `YouTubeNotifier.add_delete_listener(_func : Callable[[DeletedVideo], Awaitable[None]]_, _channel_ids : str | Iterable[str] | None = None_) -> Self` ### Parameters #### Parameters - **_func** (Callable[[DeletedVideo], Awaitable[None]]) - Required - The listener function to add. - **_channel_ids** (str | Iterable[str] | None) - Optional - The channel ID(s) to listen for. If not provided, the listener will be called for all channels. ### Returns - **Self** - The YouTubeNotifier instance to allow for method chaining. ``` -------------------------------- ### YouTubeNotifier.add_edit_listener Source: https://ytnoti.readthedocs.io/en/latest/_autosummary/ytnoti.YouTubeNotifier.add_edit_listener.html Adds a listener function that will be called when a video is edited. The listener can be configured to trigger for specific channel IDs or all channels. ```APIDOC ## YouTubeNotifier.add_edit_listener ### Description Adds a listener for when a video is edited. The listener function will be invoked with the edited video object. ### Method `YouTubeNotifier.add_edit_listener(_func : Callable[[Video], Awaitable[None]]_, _channel_ids : str | Iterable[str] | None = None_) -> Self` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **func** (`Callable[[Video], Awaitable[None]]`) - The listener function to add. This function should accept a `Video` object and return an `Awaitable[None]`. * **channel_ids** (`str | Iterable[str] | None`, optional) - The channel ID(s) to listen for. If not provided, the listener will be called for all channels. Defaults to None. ### Returns * **Self** - The YouTubeNotifier instance to allow for method chaining. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.