From 6ddc0a1728f34e1eb65bc36bb82cea40b6b8740c Mon Sep 17 00:00:00 2001 From: SeoulSKY Date: Sun, 7 Jul 2024 13:13:56 -0600 Subject: [PATCH] Update docs --- README.md | 27 ++++++++++++++++++++++----- docs/index.rst | 30 +++++++++++++++++++++++++----- 2 files changed, 47 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 8c85d1f..eae59fd 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ This library uses YouTube Data API v3 via [PubSubHubbub](https://developers.google.com/youtube/v3/guides/push_notifications) to receive push notifications, so you can receive notifications in real time without constantly polling the YouTube API. -In addition, this method doesn't require any API key, so you can use this library **without any quota limit**. +In addition, this method doesn't require any API key for YouTube Data API, so you can use this library **without any quota limit**. # 💻 Installation @@ -33,15 +33,14 @@ This library requires `Python 3.11` or higher. pip install ytnoti ``` -# 📝 Simple Example +# 📖 Simple Example -For more examples, please visit the [examples](https://github.com/SeoulSKY/ytnoti/tree/main/examples) folder. +Following is a simple example of how to use [ngrok](https://dashboard.ngrok.com/get-started/setup) to receive push notifications. ```python -from ytnoti import YouTubeNotifier, Video from pyngrok import ngrok +from ytnoti import YouTubeNotifier, Video -# Create your ngrok token free from https://dashboard.ngrok.com/get-started/setup ngrok.set_auth_token("Your ngrok token here") notifier = YouTubeNotifier() @@ -56,6 +55,24 @@ notifier.subscribe("UC9EEyg7QBL-stRX-7hTV3ng") # Channel ID of SpeedyStyle notifier.run() ``` +Following is a simple example of how to use your domain to receive push notifications. + +```python +from ytnoti import YouTubeNotifier, Video + +notifier = YouTubeNotifier(callback_url="https://yourdomain.com") + + +@notifier.upload() +async def listener(video: Video): + print(f"New video from {video.channel.name}: {video.title}") + +notifier.subscribe("UC9EEyg7QBL-stRX-7hTV3ng") # Channel ID of SpeedyStyle +notifier.run() +``` + +For more examples, please visit the [examples](https://github.com/SeoulSKY/ytnoti/tree/main/examples) folder. + # 📚 Documentation Please read the [documentation](https://ytnoti.readthedocs.io/en/latest/) before asking questions. diff --git a/docs/index.rst b/docs/index.rst index da66720..957e214 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -32,7 +32,7 @@ This library uses YouTube Data API v3 via `PubSubHubbub `_ to receive push notifications, so you can receive notifications in real-time without constantly polling the YouTube API. -In addition, this method doesn't require any API key, so you can use this library **without any quota limit**. +In addition, this method doesn't require any API key for YouTube Data API, so you can use this library **without any quota limit**. 💻 Installation ------------------ @@ -44,21 +44,38 @@ This library requires `Python 3.11` or higher. pip install ytnoti -📝 Simple Example +📖 Simple Example ------------------ -For more examples, please visit the `examples `_ folder. +Following is a simple example of how to use `ngrok `_ to receive push notifications. .. code:: python - from ytnoti import YouTubeNotifier, Video from pyngrok import ngrok + from ytnoti import YouTubeNotifier, Video - # Create your ngrok token free from https://dashboard.ngrok.com/get-started/setup 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("UC9EEyg7QBL-stRX-7hTV3ng") # Channel ID of SpeedyStyle + notifier.run() + +Following is a simple example of how to use your domain to receive push notifications. + +.. code:: python + + from ytnoti import YouTubeNotifier, Video + + notifier = YouTubeNotifier(callback_url="https://yourdomain.com") + + @notifier.upload() async def listener(video: Video): print(f"New video from {video.channel.name}: {video.title}") @@ -66,6 +83,9 @@ For more examples, please visit the `examples `_ folder. + 👥 Community -------------