-
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.
- Add a new webhook route to receive youtube event notifications - Add a new integration called YoutubeClient to handle youtube API methods
- Loading branch information
Showing
2 changed files
with
60 additions
and
0 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,41 @@ | ||
import time | ||
|
||
|
||
class YoutubeClient: | ||
def __init__(self, bot): | ||
from app import DiscordBot | ||
self.bot: DiscordBot = bot | ||
self.token = None | ||
self.token_expiration_time = None | ||
self.webhook_url = f"{self.bot.config.WEBHOOK_URL}/youtube" | ||
|
||
def check_auth_token(func): | ||
def wrapper(self, *args, **kwargs): | ||
current_time = time.time() | ||
if not self.token_expiration_time or current_time >= self.token_expiration_time: | ||
self.authenticate() | ||
return func(self, *args, **kwargs) | ||
|
||
return wrapper | ||
|
||
def authenticate(self): | ||
pass | ||
|
||
def get_channel_by_username(self, username: str) -> dict: | ||
pass | ||
|
||
@check_auth_token | ||
def subscribe_to_new_video_event(self, user_id: str) -> None: | ||
pass | ||
|
||
@check_auth_token | ||
def unsubscribe_from_new_video_event(self, subscription_id: str) -> None: | ||
pass | ||
|
||
@check_auth_token | ||
def get_subscriptions(self) -> dict: | ||
pass | ||
|
||
@check_auth_token | ||
def get_subscription_by_user_id(self, user_id: str) -> dict: | ||
pass |
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,19 @@ | ||
from flask import request | ||
|
||
from app import logger | ||
from app.constants import LogTypes as logconstants | ||
from app.webhooks import webhooks | ||
|
||
|
||
@webhooks.route('/youtube', methods=['GET', 'POST']) | ||
def twitch_webhook(): | ||
# from app import bot | ||
|
||
challenge = request.args.get('hub.challenge') | ||
|
||
if (challenge): | ||
return challenge | ||
|
||
logger.info(f'Received Youtube webhook: {request.data}', log_type=logconstants.COMMAND_INFO_TYPE) | ||
|
||
return 'Processed', 204 |