-
-
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
292 additions
and
62 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
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,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() |
Oops, something went wrong.