-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
100 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
""" | ||
This example demonstrates how to use the AsyncYouTubeNotifier to listen for new video uploads from a channel. | ||
""" | ||
|
||
import asyncio | ||
|
||
from ytnoti import AsyncYouTubeNotifier, Notification | ||
|
||
|
||
async def main(): | ||
""" | ||
Main function | ||
""" | ||
|
||
notifier = AsyncYouTubeNotifier() | ||
|
||
@notifier.upload() | ||
async def listener(notification: Notification): | ||
""" | ||
Listener called when a video is uploaded for any channel | ||
""" | ||
|
||
print(f"New video from {notification.channel.name}: {notification.video.title}") | ||
|
||
await notifier.subscribe("UC9EEyg7QBL-stRX-7hTV3ng") # Channel ID of SpeedyStyle | ||
await notifier.serve() | ||
|
||
|
||
if __name__ == "__main__": | ||
asyncio.run(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
""" | ||
This example demonstrates how to use the YouTubeNotifier to listen for new video uploads from a channel. | ||
""" | ||
|
||
from ytnoti import YouTubeNotifier, Notification | ||
|
||
|
||
def main(): | ||
""" | ||
Main function | ||
""" | ||
|
||
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() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
""" | ||
Example of a simple YouTube Notifier with logging module | ||
""" | ||
|
||
|
||
import logging | ||
|
||
from ytnoti import YouTubeNotifier, Notification | ||
|
||
|
||
def main(): | ||
""" | ||
Main function | ||
""" | ||
|
||
logger = logging.getLogger(__name__) | ||
notifier = YouTubeNotifier() | ||
|
||
@notifier.upload() | ||
async def listener(notification: Notification): | ||
""" | ||
Listener called when a video is uploaded or edited for any channel | ||
""" | ||
|
||
logger.info("New video from %s: %s", notification.channel.name, notification.video.title) | ||
|
||
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s") | ||
|
||
notifier.subscribe("UC9EEyg7QBL-stRX-7hTV3ng") # Channel ID of SpeedyStyle | ||
notifier.run() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters