From f2cd19a0532428febde77990a914d7527fb9c904 Mon Sep 17 00:00:00 2001
From: Mow910
+ Liste des chaînes YouTube surveillées pour les notifications de nouvelles vidéos.
+
+ Le bot vérifie toutes les 5 minutes les nouvelles vidéos des chaînes en dessous.
+ Quand une nouvelle vidéo est détectée, le bot enverra une notification sur Discord.
+
Notifications YouTube
+
+{% if msg %}
+Notifications
+
+
+
+{% endif %}
+
+
+
+
+
+ {% for notification in notifications %}
+ Chaîne YouTube
+ Canal Discord
+ Type
+ Message
+ #
+
+
+ {% endfor %}
+
+{{notification.channel_id}}
+ {{notification.notify_channel_name}}
+
+ {% if notification.video_type == 'all' %}
+ Toutes
+ {% elif notification.video_type == 'video' %}
+ Vidéos uniquement
+ {% elif notification.video_type == 'short' %}
+ Shorts uniquement
+ {% endif %}
+
+ {{notification.message}}
+
+ {{ '✅' if notification.enable else '❌' }}
+ ✐
+ 🗑
+
+ {{ 'Editer une notification' if notification else 'Ajouter une notification YouTube' }}
+
+ Pour le message vous avez accès à ces variables : +
{channel_name} : nom de la chaîne YouTube{video_title} : titre de la vidéo{video_url} : lien vers la vidéo{video_id} : ID de la vidéo{thumbnail} : URL de la miniature{published_at} : date de publication{is_short} : True si c'est un short, False sinon🎥 Nouvelle vidéo de {channel_name} : [{video_title}]({video_url})
+
+
+
+{% endblock %}
diff --git a/webapp/youtube.py b/webapp/youtube.py
new file mode 100644
index 0000000..0e70118
--- /dev/null
+++ b/webapp/youtube.py
@@ -0,0 +1,157 @@
+import re
+import requests
+from urllib.parse import urlencode
+from flask import render_template, request, redirect, url_for
+
+from webapp import webapp
+from database import db
+from database.models import YouTubeNotification
+from discordbot import bot
+
+
+def extract_channel_id(channel_input: str) -> str:
+ """Extrait l'ID de la chaîne YouTube depuis différents formats"""
+ if not channel_input:
+ return None
+
+ channel_input = channel_input.strip()
+
+ if channel_input.startswith('UC') and len(channel_input) == 24:
+ return channel_input
+
+ if '/channel/' in channel_input:
+ match = re.search(r'/channel/([a-zA-Z0-9_-]{24})', channel_input)
+ if match:
+ return match.group(1)
+
+ if '/c/' in channel_input or '/user/' in channel_input:
+ parts = channel_input.split('/')
+ for i, part in enumerate(parts):
+ if part in ['c', 'user'] and i + 1 < len(parts):
+ handle = parts[i + 1].split('?')[0].split('&')[0]
+ channel_id = _get_channel_id_from_handle(handle)
+ if channel_id:
+ return channel_id
+
+ if '@' in channel_input:
+ handle = re.search(r'@([a-zA-Z0-9_-]+)', channel_input)
+ if handle:
+ channel_id = _get_channel_id_from_handle(handle.group(1))
+ if channel_id:
+ return channel_id
+
+ return None
+
+
+def _get_channel_id_from_handle(handle: str) -> str:
+ """Récupère l'ID de la chaîne depuis un handle en utilisant le flux RSS"""
+ try:
+ url = f"https://www.youtube.com/@{handle}"
+ response = requests.get(url, timeout=10, allow_redirects=True)
+
+ if response.status_code == 200:
+ channel_id_match = re.search(r'"channelId":"([^"]{24})"', response.text)
+ if channel_id_match:
+ return channel_id_match.group(1)
+
+ canonical_match = re.search(r'")
+def toggleYouTube(id):
+ notification: YouTubeNotification = YouTubeNotification.query.get_or_404(id)
+ notification.enable = not notification.enable
+ db.session.commit()
+ return redirect(url_for("openYouTube"))
+
+
+@webapp.route("/youtube/edit/+ Variables disponibles pour l'embed : +
{channel_name} : nom de la chaîne YouTube{video_title} : titre de la vidéo{video_url} : lien vers la vidéo{video_id} : ID de la vidéo{thumbnail} : URL de la miniature{published_at} : date de publication{is_short} : True si c'est un short, False sinonNous devons définir ce que nous souhaitons afficher sur la page d'accueil. Peut-être l'historique des dernières - modifications ? de la modération ?
-{% endblock %} \ No newline at end of file ++ Gérez les fonctionnalités de votre bot Discord et Twitch depuis cette interface. +
+Serveurs connectés
+{{ discord_guild_count }}
+Sanctions enregistrées
+{{ sanctions_count }}
+Canal connecté
+{% if twitch_channel_name %}{{ twitch_channel_name }}{% else %}—{% endif %}
+Sanctions
+—
+À venir
+Intégrations du bot Twitch à venir.
++ Mamie Henriette est un bot open source pour Discord et Twitch, développé par la communauté. + Cette interface vous permet de configurer et gérer toutes les fonctionnalités. +
++ Historique des actions de modération sur le serveur Discord. +
+- Historique des actions de modération effectuées sur le serveur Discord. +
Utilisateurs les plus sanctionnés
+Staff ayant effectué le plus d'actions
+| Commande | -Description | -
|---|---|
| !averto @utilisateur raison Alias : !warn, !av, !avertissement |
- Avertit un utilisateur et enregistre l'avertissement dans la base de données | -
| !delaverto id Alias : !removewarn, !delwarn |
- Retire un avertissement en utilisant son numéro d'ID | -
| !warnings ou !warnings @utilisateur Alias : !listevent, !listwarn |
- Affiche la liste des événements de modération (tous ou pour un utilisateur spécifique) | -
| !inspect @utilisateur ou !inspect id | -Affiche des informations détaillées sur un utilisateur : création du compte, date d'arrivée, historique de modération | -
| !kick @utilisateur raison | -Expulse un utilisateur du serveur | -
| !ban @utilisateur raison | -Bannit définitivement un utilisateur du serveur | -
| !unban discord_id ou !unban #sanction_id raison | -Révoque le bannissement d'un utilisateur et lui envoie une invitation | -
| !banlist | -Affiche la liste des utilisateurs actuellement bannis du serveur | -
| !aide Alias : !help |
- Affiche l'aide avec toutes les commandes disponibles | -
!averto @user raison
+ Avertit un utilisateur
+ !delaverto id
+ Retire un avertissement
+ !warnings [@user]
+ Liste les événements de modération
+ !inspect @user
+ Informations sur un utilisateur
+ !kick @user raison
+ Expulse un utilisateur
+ !ban @user raison
+ Bannit un utilisateur
+ !unban id
+ Révoque un bannissement
+ !banlist
+ Liste des utilisateurs bannis
+ | Type | -Utilisateur | -Discord ID | -Date & Heure | -Raison | -Staff | -# | -
|---|---|---|---|---|---|---|
| {{ mod_event.type }} | -{{ mod_event.username }} | -{{ mod_event.discord_id }} | -{{ mod_event.created_at.strftime('%d/%m/%Y %H:%M') if mod_event.created_at else 'N/A' }} | -{{ mod_event.reason }} | -{{ mod_event.staff_name }} | -- ✐ - 🗑 - | -
| Type | +Utilisateur | +Date | +Raison | +Staff | +Actions | +
|---|---|---|---|---|---|
| + {% if mod_event.type == 'ban' %} + Ban + {% elif mod_event.type == 'kick' %} + Kick + {% elif mod_event.type == 'warn' or mod_event.type == 'warning' %} + Warn + {% elif mod_event.type == 'unban' %} + Unban + {% else %} + {{ mod_event.type }} + {% endif %} + | +
+
+ {{ mod_event.username }}
+ {{ mod_event.discord_id }}
+
+ |
+ + {{ mod_event.created_at.strftime('%d/%m/%Y %H:%M') if mod_event.created_at else 'N/A' }} + | +
+ {{ mod_event.reason }}
+ |
+ + {{ mod_event.staff_name }} + | +
+
+
+ Modifier
+
+
+ Supprimer
+
+
+ |
+
| + Aucun événement de modération + | +|||||