Skip to content

Commit

Permalink
Add helper decorators
Browse files Browse the repository at this point in the history
  • Loading branch information
SeoulSKY committed Jun 26, 2024
1 parent 5a1da09 commit e435eaf
Show file tree
Hide file tree
Showing 5 changed files with 292 additions and 62 deletions.
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fail-under=10
#from-stdin=

# Files or directories to be skipped. They should be base names, not paths.
ignore=CVS
ignore=CVS,build,dist

# Add files or directories matching the regex patterns to the ignore-list. The
# regex matches against paths and can be in Posix or Windows format.
Expand Down
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,55 @@
<img src="https://github.com/SeoulSKY/ytnoti/actions/workflows/pylint.yml/badge.svg">
<br>
</div>

`ytnoti` is designed to help you receive YouTube push notifications for video
upload and update in an easy and efficient way.

# How it works

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**.

# Installation

This library requires `Python 3.11` or higher.

```bash
pip install ytnoti
```

# Simple Example

For more examples, please visit the [examples](https://github.com/SeoulSKY/ytnoti/tree/main/examples) folder.

```python
from ytnoti import YouTubeNotifier, Notification

notifier = YouTubeNotifier()

@notifier.upload()
async def listener(notification: Notification):
print(f"New video from {notification.channel.name}: {notification.video.title}")

notifier.subscribe(["UC9EEyg7QBL-stRX-7hTV3ng"]) # Channel ID of SpeedyStyle
notifier.run()
```

# Documentation

Read the [wiki](https://github.com/SeoulSKY/ytnoti/wiki) for more information.

# Community

If you have any questions about this library please visit my Discord server.

<a href="https://discord.gg/kQZDJJB">
<img alt="discord invite" src="http://invidget.switchblade.xyz/kQZDJJB">
</a>

# License

This project is licensed under the MIT License - see the [LICENSE.md](https://github.com/SeoulSKY/ytnoti/blob/main/LICENSE.md) file for details.
53 changes: 53 additions & 0 deletions examples/multiple_kinds.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
"""
This is a basic example of how to use the package to get notifications when a new video is uploaded or updated.
"""


import logging

from ytnoti import YouTubeNotifier, Notification


def main():
"""
Main function
"""

logger = logging.getLogger(__name__)
notifier = YouTubeNotifier()

@notifier.any()
async def listener1(notification: Notification):
"""
Listener called when a video is uploaded or updated
"""

logger.info("listener 1 called")
logger.info(notification)

@notifier.upload()
async def listener2(notification: Notification):
"""
Listener called when a video on a specific channel is uploaded
"""

logger.info("listener 2 called")
logger.info(notification)

@notifier.edit()
async def listener3(notification: Notification):
"""
Listener called when a video is edited on a specific channel
"""

logger.info("listener 3 called")
logger.info(notification)

logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s")

notifier.subscribe(["UCupvZG-5ko_eiXAupbDfxWw", "UChLtXXpo4Ge1ReTEboVvTDg"])
notifier.run()


if __name__ == "__main__":
main()
35 changes: 0 additions & 35 deletions main.py

This file was deleted.

Loading

0 comments on commit e435eaf

Please sign in to comment.