Compare commits
6 Commits
31bb81f94c
...
master
Author | SHA1 | Date | |
---|---|---|---|
0ca501f208 | |||
da690cd515 | |||
3ce51283ce | |||
f1d71ff9ef | |||
283695c586 | |||
3a3c5b5705 |
BIN
Rapport Projet.pdf
Normal file
BIN
Rapport Projet.pdf
Normal file
Binary file not shown.
282
methode1/main.py
Normal file
282
methode1/main.py
Normal file
@@ -0,0 +1,282 @@
|
||||
from tkinter import *
|
||||
from tkinter import messagebox
|
||||
import mysql.connector
|
||||
from obswebsocket import obsws, requests as obsrequests
|
||||
from twitch.helix.api import TwitchHelix
|
||||
import webbrowser
|
||||
import asyncio
|
||||
import re
|
||||
|
||||
class NouvelleFenetre:
|
||||
is_live = False
|
||||
|
||||
client_id = '6h883my3p6ndqozotnl6nsbllyyr3h' # id de l'app
|
||||
|
||||
oauth_authorization_url = f"https://id.twitch.tv/oauth2/authorize?client_id={client_id}&redirect_uri=http://localhost&response_type=token&scope=user_read"
|
||||
|
||||
def __init__(self, root, username, password):
|
||||
self.oauth_token = None
|
||||
asyncio.run(self.initialize_window(root, username, password))
|
||||
self.username = username
|
||||
self.password = password
|
||||
self.root = root
|
||||
|
||||
|
||||
|
||||
self.root.grid_rowconfigure(0, weight=0)
|
||||
self.root.grid_rowconfigure(1, weight=0)
|
||||
self.root.grid_rowconfigure(2, weight=0)
|
||||
self.root.grid_rowconfigure(3, weight=0)
|
||||
self.root.grid_rowconfigure(4, weight=0)
|
||||
self.root.grid_rowconfigure(5, weight=0)
|
||||
self.root.grid_rowconfigure(6, weight=0)
|
||||
self.root.grid_rowconfigure(7, weight=0)
|
||||
self.root.grid_rowconfigure(8, weight=0)
|
||||
self.root.grid_rowconfigure(9, weight=0)
|
||||
self.root.grid_rowconfigure(10, weight=0)
|
||||
self.root.grid_rowconfigure(11, weight=0)
|
||||
self.root.grid_rowconfigure(12, weight=0)
|
||||
self.root.grid_rowconfigure(13, weight=0)
|
||||
self.root.grid_rowconfigure(14, weight=0)
|
||||
self.root.grid_columnconfigure(0, weight=1)
|
||||
self.root.grid_columnconfigure(1, weight=0)
|
||||
self.root.grid_columnconfigure(2, weight=0)
|
||||
self.root.grid_columnconfigure(3, weight=0)
|
||||
|
||||
self.obs_host = "localhost" # Adresse IP de votre ordinateur où OBS est en cours d'exécution
|
||||
self.obs_port = 4455 # Port par défaut utilisé par OBSWebsocket
|
||||
self.obs_password = "MPcZLZfViZihHqmg" # Mot de passe OBSWebsocket
|
||||
|
||||
|
||||
self.twitch_key_from_database = self.get_twitch_key_from_database(username)
|
||||
|
||||
|
||||
|
||||
async def initialize_window(self, root, username, password):
|
||||
self.root = Toplevel(root)
|
||||
self.root.title("OBS Extension Multistreaming")
|
||||
self.root.geometry("1920x1080")
|
||||
self.username = username
|
||||
self.password = password
|
||||
|
||||
self.lancer_auth_twitch()
|
||||
|
||||
self.oauth_token = self.get_oauth_token_from_database(username)
|
||||
|
||||
await self.initialize_twitch()
|
||||
|
||||
label = Label(self.root, text=f"Bienvenue, {username}!")
|
||||
label.grid(row=0, column=0)
|
||||
|
||||
label = Label(self.root, text="Clé Twitch :")
|
||||
label.grid(row=2, column=0)
|
||||
|
||||
self.entry_twitch = Entry(self.root)
|
||||
self.entry_twitch.grid(row=3, column=0)
|
||||
|
||||
boutonvalidation = Button(self.root, text="Envoyé", command=lambda: self.set_key_twitch(username))
|
||||
boutonvalidation.grid(row=4, column=0)
|
||||
|
||||
boutondediffusiontwitch = Button(self.root, text="Diffusion de Twitch On/Off", command=lambda: asyncio.run(self.configure_obs_for_twitch(self.twitch_key_from_database)))
|
||||
boutondediffusiontwitch.grid(row=4, column=3)
|
||||
|
||||
label = Label(self.root, text="Clé Youtube :")
|
||||
label.grid(row=5, column=0)
|
||||
|
||||
self.entry_youtube = Entry(self.root)
|
||||
self.entry_youtube.grid(row=6, column=0)
|
||||
|
||||
boutonvalidation2 = Button(self.root, text="Envoyé", command=lambda: self.set_key_youtube(username))
|
||||
boutonvalidation2.grid(row=7, column=0)
|
||||
|
||||
boutondediffusionyoutube = Button(self.root, text="Diffusion de YouTube On/Off")
|
||||
boutondediffusionyoutube.grid(row=7, column=3)
|
||||
|
||||
bouton_fermer = Button(self.root, text="Fermer", command=self.fermer_et_reafficher)
|
||||
bouton_fermer.grid(row=13, column=0)
|
||||
|
||||
|
||||
|
||||
def fermer_et_reafficher(self):
|
||||
self.root.destroy()
|
||||
self.ws.disconnect()
|
||||
self.root.master.deiconify()
|
||||
|
||||
def get_key_twitch(self):
|
||||
self.twitch = self.entry_twitch.get()
|
||||
print(self.twitch)
|
||||
|
||||
def get_key_youtube(self):
|
||||
self.youtube = self.entry_youtube.get()
|
||||
print(self.youtube)
|
||||
|
||||
def set_key_twitch(self, username):
|
||||
try:
|
||||
cnx = mysql.connector.connect(user='root', password='',
|
||||
host='127.0.0.1',
|
||||
database='obs_project')
|
||||
cur = cnx.cursor()
|
||||
|
||||
query = "SELECT * FROM utilisateurs WHERE username = %s"
|
||||
cur.execute(query, (username,))
|
||||
|
||||
user = cur.fetchone()
|
||||
|
||||
if user:
|
||||
new_twitch_key = self.entry_twitch.get()
|
||||
update_query = "UPDATE twitch SET twitch_key = %s WHERE username = %s"
|
||||
cur.execute(update_query, (new_twitch_key, username))
|
||||
cnx.commit()
|
||||
print(f"La clé a été mis à jour pour {username} avec la clé {new_twitch_key}")
|
||||
else:
|
||||
print(f"Utilisateur {username} non trouvée")
|
||||
|
||||
except mysql.connector.Error as err:
|
||||
print(f"Erreur: {err}")
|
||||
messagebox.showerror("Erreur", "Une erreur a eu lieu pour mettre à jour votre clé")
|
||||
|
||||
finally:
|
||||
cur.close()
|
||||
cnx.close()
|
||||
|
||||
def set_key_youtube(self, username):
|
||||
try:
|
||||
cnx = mysql.connector.connect(user='root', password='',
|
||||
host='127.0.0.1',
|
||||
database='obs_project')
|
||||
cur = cnx.cursor()
|
||||
|
||||
query = "SELECT * FROM utilisateurs WHERE username = %s"
|
||||
cur.execute(query, (username,))
|
||||
|
||||
user = cur.fetchone()
|
||||
|
||||
if user:
|
||||
new_youtube_key = self.entry_youtube.get()
|
||||
update_query = "UPDATE youtube SET youtube_key = %s WHERE username = %s"
|
||||
cur.execute(update_query, (new_youtube_key, username))
|
||||
cnx.commit()
|
||||
print(f"La clé a été mis à jour pour {username} avec la clé {new_youtube_key}")
|
||||
else:
|
||||
print(f"Utilisateur {username} non trouvée")
|
||||
|
||||
except mysql.connector.Error as err:
|
||||
print(f"Erreur: {err}")
|
||||
messagebox.showerror("Erreur", "Une erreur a eu lieu pour mettre à jour votre clé")
|
||||
|
||||
finally:
|
||||
cur.close()
|
||||
cnx.close()
|
||||
|
||||
def get_twitch_key_from_database(self, username):
|
||||
try:
|
||||
cnx = mysql.connector.connect(user='root', password='',
|
||||
host='127.0.0.1',
|
||||
database='obs_project')
|
||||
cur = cnx.cursor()
|
||||
|
||||
query = "SELECT twitch_key FROM twitch WHERE username = %s"
|
||||
cur.execute(query, (username,))
|
||||
twitch_key = cur.fetchone()
|
||||
|
||||
if twitch_key:
|
||||
return twitch_key[0]
|
||||
else:
|
||||
print(f"Clé Twitch non trouvée pour l'utilisateur {username}")
|
||||
return None
|
||||
|
||||
except mysql.connector.Error as err:
|
||||
print(f"Erreur: {err}")
|
||||
messagebox.showerror("Erreur", "Une erreur a eu lieu pour récupérer la clé Twitch")
|
||||
|
||||
finally:
|
||||
cur.close()
|
||||
cnx.close()
|
||||
|
||||
async def configure_obs_for_twitch(self, twitch_key_from_database):
|
||||
try:
|
||||
if twitch_key_from_database is not None:
|
||||
if not self.is_live:
|
||||
print("Connexion à OBS via Websocket avec les paramètres suivants :")
|
||||
print("Host:", self.obs_host)
|
||||
print("Port:", self.obs_port)
|
||||
print("Password:", self.obs_password)
|
||||
print("Twitch Stream Key:", twitch_key_from_database)
|
||||
|
||||
self.obs_ws = obsws(self.obs_host, self.obs_port, self.obs_password)
|
||||
self.obs_ws.connect()
|
||||
|
||||
start_stream_request = obsrequests.StartStreaming(stream_key=twitch_key_from_database)
|
||||
self.obs_ws.call(start_stream_request)
|
||||
|
||||
self.is_live = True
|
||||
else:
|
||||
print("Arrêt du streaming Twitch.")
|
||||
self.obs_ws.call(obsrequests.StopStreaming())
|
||||
self.obs_ws.disconnect()
|
||||
self.is_live = False
|
||||
else:
|
||||
print("La clé Twitch est manquante.")
|
||||
except Exception as e:
|
||||
print(f"Une erreur s'est produite lors de la configuration d'OBS pour Twitch : {e}")
|
||||
|
||||
|
||||
async def initialize_twitch(self):
|
||||
try:
|
||||
if self.oauth_token:
|
||||
twitch = TwitchHelix(self.client_id, self.oauth_token)
|
||||
users = twitch.get_users()
|
||||
if users:
|
||||
print("Utilisateur Twitch trouvé:")
|
||||
print("ID:", users[0].id)
|
||||
print("Nom d'utilisateur:", users[0].display_name)
|
||||
else:
|
||||
print("Utilisateur Twitch non trouvé.")
|
||||
else:
|
||||
print("Le token OAuth Twitch n'est pas disponible. Assurez-vous de le récupérer depuis la base de données.")
|
||||
except Exception as e:
|
||||
print(f"Une erreur s'est produite lors de la récupération de l'utilisateur Twitch : {e}")
|
||||
|
||||
|
||||
def lancer_auth_twitch(self):
|
||||
oauth_token = self.get_oauth_token_from_database(self.username)
|
||||
print(f"Token OAuth récupéré pour {self.username}: {oauth_token}")
|
||||
|
||||
if oauth_token is None or oauth_token.strip() == '':
|
||||
webbrowser.open(self.oauth_authorization_url)
|
||||
messagebox.showinfo("Authentification Twitch", "Veuillez autoriser l'accès à Twitch dans le navigateur Web qui s'est ouvert.")
|
||||
else:
|
||||
messagebox.showinfo("Authentification Twitch", "L'authentification Twitch n'est pas nécessaire car le token OAuth est déjà présent dans la base de données.")
|
||||
|
||||
|
||||
def get_oauth_token_from_database(self, username):
|
||||
try:
|
||||
cnx = mysql.connector.connect(user='root', password='',
|
||||
host='127.0.0.1',
|
||||
database='obs_project')
|
||||
cur = cnx.cursor()
|
||||
|
||||
query = "SELECT OAuth_Key FROM twitch WHERE username = %s"
|
||||
cur.execute(query, (username,))
|
||||
oauth_token = cur.fetchone()
|
||||
|
||||
print(f"Résultat de la requête pour l'utilisateur {username}: {oauth_token}")
|
||||
|
||||
if oauth_token and oauth_token[0].strip():
|
||||
print(f"OAuth token trouvé pour l'utilisateur {username}: {oauth_token[0]}")
|
||||
return oauth_token[0]
|
||||
else:
|
||||
print(f"OAuth token non trouvé pour l'utilisateur {username}")
|
||||
return None
|
||||
|
||||
except mysql.connector.Error as err:
|
||||
print(f"Erreur: {err}")
|
||||
messagebox.showerror("Erreur", "Une erreur a eu lieu pour récupérer le token OAuth")
|
||||
|
||||
finally:
|
||||
cur.close()
|
||||
cnx.close()
|
||||
|
||||
|
||||
|
||||
|
94
methode1/mysqlco.py
Normal file
94
methode1/mysqlco.py
Normal file
@@ -0,0 +1,94 @@
|
||||
from main import *
|
||||
from tkinter import *
|
||||
from tkinter import messagebox
|
||||
import mysql.connector
|
||||
|
||||
class Mysql:
|
||||
|
||||
def __init__(self, root):
|
||||
self.root = root
|
||||
self.root.title("Launcher OBS Extension Multistreaming")
|
||||
self.root.geometry("400x300")
|
||||
self.root.grid_rowconfigure(0, weight=1)
|
||||
self.root.grid_rowconfigure(1, weight=1)
|
||||
self.root.grid_rowconfigure(2, weight=1)
|
||||
self.root.grid_rowconfigure(3, weight=1)
|
||||
self.root.grid_columnconfigure(0, weight=1)
|
||||
self.root.grid_columnconfigure(1, weight=0)
|
||||
self.root.grid_columnconfigure(2, weight=0)
|
||||
self.root.grid_columnconfigure(3, weight=0)
|
||||
|
||||
|
||||
def authenticate_user(self, username, password):
|
||||
try:
|
||||
|
||||
cnx = mysql.connector.connect(user='root', password='',
|
||||
host='127.0.0.1',
|
||||
database='obs_project')
|
||||
cur = cnx.cursor()
|
||||
|
||||
|
||||
query = "SELECT * FROM utilisateurs WHERE username = %s AND password = %s"
|
||||
cur.execute(query, (username, password))
|
||||
|
||||
|
||||
user = cur.fetchone()
|
||||
|
||||
if user:
|
||||
messagebox.showinfo("Validé", "Authentification réussi")
|
||||
self.ouvrir_nouvelle_fenetre(username, password)
|
||||
|
||||
else:
|
||||
messagebox.showerror("Erreur", "Authentification erroné")
|
||||
|
||||
except mysql.connector.Error as err:
|
||||
messagebox.showerror("Erreur", f"Erreur: {err}")
|
||||
|
||||
finally:
|
||||
cur.close()
|
||||
cnx.close()
|
||||
|
||||
def ouvrir_nouvelle_fenetre(self, username, password):
|
||||
if self.root.winfo_exists():
|
||||
self.root.withdraw()
|
||||
NouvelleFenetre(self.root, username, password)
|
||||
|
||||
|
||||
def click_identifiant(self, event):
|
||||
entry_identifiant.configure(state=NORMAL)
|
||||
entry_identifiant.delete(0, END)
|
||||
entry_identifiant.unbind('<Button-1>', self.click_identifiant)
|
||||
|
||||
def click_pass(self, event):
|
||||
entry_pass.configure(state=NORMAL)
|
||||
entry_pass.delete(0, END)
|
||||
entry_pass.unbind('<Button-1>', self.click_pass)
|
||||
|
||||
def msg_call_back(self):
|
||||
username = entry_identifiant.get()
|
||||
password = entry_pass.get()
|
||||
self.authenticate_user(username, password)
|
||||
|
||||
fenetre = Tk()
|
||||
obj = Mysql(fenetre)
|
||||
|
||||
label = Label(fenetre, text="Connexion")
|
||||
label.grid(row = 0, column= 0)
|
||||
|
||||
entry_identifiant = Entry(fenetre)
|
||||
entry_identifiant.grid(row = 1, column=0)
|
||||
entry_identifiant.focus()
|
||||
entry_identifiant.insert(0, "Admin")
|
||||
|
||||
entry_identifiant.bind('<Button-1>', obj.click_identifiant)
|
||||
|
||||
entry_pass = Entry(fenetre, show='*')
|
||||
entry_pass.grid(row = 2, column=0)
|
||||
entry_pass.insert(0, "Admin")
|
||||
|
||||
entry_pass.bind('<Button-1>', obj.click_pass)
|
||||
|
||||
boutonconnexion = Button(fenetre, text="Connexion", command=obj.msg_call_back, activebackground = "green")
|
||||
boutonconnexion.grid(row = 3, column = 0)
|
||||
|
||||
fenetre.mainloop()
|
130
methode1/obs_project.sql
Normal file
130
methode1/obs_project.sql
Normal file
@@ -0,0 +1,130 @@
|
||||
-- phpMyAdmin SQL Dump
|
||||
-- version 5.2.1
|
||||
-- https://www.phpmyadmin.net/
|
||||
--
|
||||
-- Hôte : 127.0.0.1
|
||||
-- Généré le : lun. 04 mars 2024 à 16:59
|
||||
-- Version du serveur : 10.4.32-MariaDB
|
||||
-- Version de PHP : 8.2.12
|
||||
|
||||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||
START TRANSACTION;
|
||||
SET time_zone = "+00:00";
|
||||
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||
/*!40101 SET NAMES utf8mb4 */;
|
||||
|
||||
--
|
||||
-- Base de données : `obs_project`
|
||||
--
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la table `twitch`
|
||||
--
|
||||
|
||||
CREATE TABLE `twitch` (
|
||||
`id` int(255) NOT NULL,
|
||||
`username` varchar(15) NOT NULL,
|
||||
`twitch_key` varchar(100) NOT NULL,
|
||||
`OAuth_Key` varchar(100) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- Déchargement des données de la table `twitch`
|
||||
--
|
||||
|
||||
INSERT INTO `twitch` (`id`, `username`, `twitch_key`, `OAuth_Key`) VALUES
|
||||
(1, 'Admin', 'live_37250428_jeHrwf8xz3MR29xLYJQarW5nH5dyOK', 'z11zvdhgxvemn2l8kjl1dvczgiyelt');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la table `utilisateurs`
|
||||
--
|
||||
|
||||
CREATE TABLE `utilisateurs` (
|
||||
`id` int(255) NOT NULL,
|
||||
`username` varchar(15) NOT NULL,
|
||||
`password` varchar(20) NOT NULL,
|
||||
`mail` varchar(30) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- Déchargement des données de la table `utilisateurs`
|
||||
--
|
||||
|
||||
INSERT INTO `utilisateurs` (`id`, `username`, `password`, `mail`) VALUES
|
||||
(1, 'admin', 'admin', 'admin@gmail.com');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la table `youtube`
|
||||
--
|
||||
|
||||
CREATE TABLE `youtube` (
|
||||
`id` int(255) NOT NULL,
|
||||
`username` varchar(15) NOT NULL,
|
||||
`youtube_key` varchar(100) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- Déchargement des données de la table `youtube`
|
||||
--
|
||||
|
||||
INSERT INTO `youtube` (`id`, `username`, `youtube_key`) VALUES
|
||||
(1, 'Admin', 'gdrthdrtbdfgbdd84');
|
||||
|
||||
--
|
||||
-- Index pour les tables déchargées
|
||||
--
|
||||
|
||||
--
|
||||
-- Index pour la table `twitch`
|
||||
--
|
||||
ALTER TABLE `twitch`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- Index pour la table `utilisateurs`
|
||||
--
|
||||
ALTER TABLE `utilisateurs`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- Index pour la table `youtube`
|
||||
--
|
||||
ALTER TABLE `youtube`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT pour les tables déchargées
|
||||
--
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT pour la table `twitch`
|
||||
--
|
||||
ALTER TABLE `twitch`
|
||||
MODIFY `id` int(255) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT pour la table `utilisateurs`
|
||||
--
|
||||
ALTER TABLE `utilisateurs`
|
||||
MODIFY `id` int(255) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT pour la table `youtube`
|
||||
--
|
||||
ALTER TABLE `youtube`
|
||||
MODIFY `id` int(255) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
|
||||
COMMIT;
|
||||
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
128
methode2/scriptboth.lua
Normal file
128
methode2/scriptboth.lua
Normal file
@@ -0,0 +1,128 @@
|
||||
obs = obslua
|
||||
|
||||
youtube_output = nil
|
||||
twitch_output = nil
|
||||
|
||||
function script_description()
|
||||
return "Multi RTMP Output - Diffusez sur plusieurs serveurs RTMP simultanément. Configurer les serveurs RTMP pour YouTube et Twitch."
|
||||
end
|
||||
|
||||
function script_properties()
|
||||
local props = obs.obs_properties_create()
|
||||
|
||||
-- Paramètres YouTube
|
||||
obs.obs_properties_add_text(props, "youtube_server", "YouTube RTMP Server", obs.OBS_TEXT_DEFAULT)
|
||||
obs.obs_properties_add_text(props, "youtube_key", "YouTube Stream Key", obs.OBS_TEXT_PASSWORD)
|
||||
|
||||
-- Paramètres Twitch
|
||||
obs.obs_properties_add_text(props, "twitch_server", "Twitch RTMP Server", obs.OBS_TEXT_DEFAULT)
|
||||
obs.obs_properties_add_text(props, "twitch_key", "Twitch Stream Key", obs.OBS_TEXT_PASSWORD)
|
||||
|
||||
obs.obs_properties_add_button(props, "start_youtube", "Commencer YouTube Streaming", start_youtube_streaming)
|
||||
obs.obs_properties_add_button(props, "stop_youtube", "Arrêter YouTube Streaming", stop_youtube_streaming)
|
||||
obs.obs_properties_add_button(props, "start_twitch", "Commencer Twitch Streaming", start_twitch_streaming)
|
||||
obs.obs_properties_add_button(props, "stop_twitch", "Arrêter Twitch Streaming", stop_twitch_streaming)
|
||||
obs.obs_properties_add_button(props, "start_both", "Commencer les deux Streaming", start_both_streaming)
|
||||
obs.obs_properties_add_button(props, "stop_both", "Arrêter les deux Streaming", stop_both_streaming)
|
||||
|
||||
return props
|
||||
end
|
||||
|
||||
function script_update(settings)
|
||||
local youtube_server = obs.obs_data_get_string(settings, "youtube_server")
|
||||
local youtube_key = obs.obs_data_get_string(settings, "youtube_key")
|
||||
local twitch_server = obs.obs_data_get_string(settings, "twitch_server")
|
||||
local twitch_key = obs.obs_data_get_string(settings, "twitch_key")
|
||||
|
||||
if youtube_server ~= "" and youtube_key ~= "" then
|
||||
local youtube_settings = obs.obs_data_create()
|
||||
obs.obs_data_set_string(youtube_settings, "server", youtube_server)
|
||||
obs.obs_data_set_string(youtube_settings, "key", youtube_key)
|
||||
|
||||
local youtube_service = obs.obs_service_create("rtmp_custom", "YouTube RTMP Service", youtube_settings, nil)
|
||||
youtube_output = obs.obs_output_create("rtmp_output", "YouTube RTMP Output", nil, nil)
|
||||
|
||||
obs.obs_output_set_service(youtube_output, youtube_service)
|
||||
obs.obs_data_release(youtube_settings)
|
||||
|
||||
obs.script_log(obs.LOG_INFO, "YouTube RTMP output configured")
|
||||
end
|
||||
|
||||
if twitch_server ~= "" and twitch_key ~= "" then
|
||||
local twitch_settings = obs.obs_data_create()
|
||||
obs.obs_data_set_string(twitch_settings, "server", twitch_server)
|
||||
obs.obs_data_set_string(twitch_settings, "key", twitch_key)
|
||||
|
||||
local twitch_service = obs.obs_service_create("rtmp_custom", "Twitch RTMP Service", twitch_settings, nil)
|
||||
twitch_output = obs.obs_output_create("rtmp_output", "Twitch RTMP Output", nil, nil)
|
||||
|
||||
obs.obs_output_set_service(twitch_output, twitch_service)
|
||||
obs.obs_data_release(twitch_settings)
|
||||
|
||||
obs.script_log(obs.LOG_INFO, "Twitch RTMP output configured")
|
||||
end
|
||||
end
|
||||
|
||||
function start_youtube_streaming(props, prop)
|
||||
if youtube_output then
|
||||
if not obs.obs_output_active(youtube_output) then
|
||||
local success = obs.obs_output_start(youtube_output)
|
||||
if success then
|
||||
obs.script_log(obs.LOG_INFO, "Started YouTube RTMP output")
|
||||
else
|
||||
obs.script_log(obs.LOG_ERROR, "Failed to start YouTube RTMP output")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function stop_youtube_streaming(props, prop)
|
||||
if youtube_output then
|
||||
if obs.obs_output_active(youtube_output) then
|
||||
obs.obs_output_stop(youtube_output)
|
||||
obs.script_log(obs.LOG_INFO, "Stopped YouTube RTMP output")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function start_twitch_streaming(props, prop)
|
||||
if twitch_output then
|
||||
if not obs.obs_output_active(twitch_output) then
|
||||
local success = obs.obs_output_start(twitch_output)
|
||||
if success then
|
||||
obs.script_log(obs.LOG_INFO, "Started Twitch RTMP output")
|
||||
else
|
||||
obs.script_log(obs.LOG_ERROR, "Failed to start Twitch RTMP output")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function stop_twitch_streaming(props, prop)
|
||||
if twitch_output then
|
||||
if obs.obs_output_active(twitch_output) then
|
||||
obs.obs_output_stop(twitch_output)
|
||||
obs.script_log(obs.LOG_INFO, "Stopped Twitch RTMP output")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function start_both_streaming(props, prop)
|
||||
start_youtube_streaming(props, prop)
|
||||
start_twitch_streaming(props, prop)
|
||||
end
|
||||
|
||||
function stop_both_streaming(props, prop)
|
||||
stop_youtube_streaming(props, prop)
|
||||
stop_twitch_streaming(props, prop)
|
||||
end
|
||||
|
||||
function script_load(settings)
|
||||
obs.obs_frontend_add_event_callback(function(event)
|
||||
if event == obs.OBS_FRONTEND_EVENT_STREAMING_STARTING then
|
||||
start_both_streaming(nil, nil)
|
||||
elseif event == obs.OBS_FRONTEND_EVENT_STREAMING_STOPPING then
|
||||
stop_both_streaming(nil, nil)
|
||||
end
|
||||
end)
|
||||
end
|
60
methode2/switchprofilstream.lua
Normal file
60
methode2/switchprofilstream.lua
Normal file
@@ -0,0 +1,60 @@
|
||||
obs = obslua
|
||||
|
||||
youtube_server = "rtmp://a.rtmp.youtube.com/live2"
|
||||
youtube_key = "VOTRE_CLE_YOUTUBE"
|
||||
twitch_server = "rtmp://live.twitch.tv/app"
|
||||
twitch_key = "VOTRE_CLE_TWITCH"
|
||||
|
||||
youtube_output = nil
|
||||
twitch_output = nil
|
||||
|
||||
function script_description()
|
||||
return "Script pour lancer des streams simultanés sur YouTube et Twitch."
|
||||
end
|
||||
|
||||
function script_properties()
|
||||
local props = obs.obs_properties_create()
|
||||
|
||||
obs.obs_properties_add_button(props, "start_both", "Lancer YouTube et Twitch", start_both_streams)
|
||||
obs.obs_properties_add_button(props, "stop_both", "Arrêter YouTube et Twitch", stop_both_streams)
|
||||
|
||||
return props
|
||||
end
|
||||
|
||||
function start_both_streams(props, p)
|
||||
start_stream(youtube_server, youtube_key, "YouTube")
|
||||
start_stream(twitch_server, twitch_key, "Twitch")
|
||||
end
|
||||
|
||||
function stop_both_streams(props, p)
|
||||
stop_stream(youtube_output)
|
||||
stop_stream(twitch_output)
|
||||
end
|
||||
|
||||
function start_stream(server, key, name)
|
||||
local settings = obs.obs_data_create()
|
||||
obs.obs_data_set_string(settings, "server", server)
|
||||
obs.obs_data_set_string(settings, "key", key)
|
||||
|
||||
local service = obs.obs_service_create("rtmp_common", "service", settings, nil)
|
||||
local output = obs.obs_output_create("rtmp_output", name, nil, nil)
|
||||
obs.obs_output_set_service(output, service)
|
||||
|
||||
obs.obs_output_start(output)
|
||||
|
||||
if name == "YouTube" then
|
||||
youtube_output = output
|
||||
elseif name == "Twitch" then
|
||||
twitch_output = output
|
||||
end
|
||||
|
||||
obs.obs_data_release(settings)
|
||||
obs.obs_service_release(service)
|
||||
end
|
||||
|
||||
function stop_stream(output)
|
||||
if output and obs.obs_output_active(output) then
|
||||
obs.obs_output_stop(output)
|
||||
obs.obs_output_release(output)
|
||||
end
|
||||
end
|
BIN
test/image.png
Normal file
BIN
test/image.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
263
test/main.py
Normal file
263
test/main.py
Normal file
@@ -0,0 +1,263 @@
|
||||
from tkinter import *
|
||||
from tkinter import messagebox
|
||||
import mysql.connector
|
||||
from obswebsocket import obsws, requests as obsrequests
|
||||
from twitch.helix.api import TwitchHelix
|
||||
import webbrowser
|
||||
import asyncio
|
||||
|
||||
class NouvelleFenetre:
|
||||
|
||||
is_live = False
|
||||
|
||||
client_id = '6h883my3p6ndqozotnl6nsbllyyr3h' # id de l'app
|
||||
oauth_token ='z11zvdhgxvemn2l8kjl1dvczgiyelt' # token de validation, à changer selon l'utilisateur
|
||||
|
||||
oauth_authorization_url = f"https://id.twitch.tv/oauth2/authorize?client_id={'6h883my3p6ndqozotnl6nsbllyyr3h'}&redirect_uri={'http://localhost'}&response_type=token&scope={'user_read'}"
|
||||
|
||||
# Fonction permettant de fermer la deuxième fenetre créee et la première fenetre de connexion de se réafficher tout en se déconnecctant d'OBS
|
||||
def fermer_et_reafficher(self):
|
||||
self.root.destroy()
|
||||
self.ws.disconnect()
|
||||
self.root.master.deiconify()
|
||||
|
||||
# Fonction permettant de récupérer la valeur de la clé twitch qui a été renseignée
|
||||
def get_key_twitch(self):
|
||||
self.twitch = self.entry_twitch.get()
|
||||
print(self.twitch)
|
||||
|
||||
# Fonction permettant de récupérer la valeur de la clé youtube qui a été renseignée
|
||||
def get_key_youtube(self):
|
||||
self.youtube = self.entry_youtube.get()
|
||||
print(self.youtube)
|
||||
|
||||
def set_key_twitch(self, username):
|
||||
try:
|
||||
# Paramètres du serveur
|
||||
cnx = mysql.connector.connect(user='root', password='',
|
||||
host='127.0.0.1',
|
||||
database='obs_project')
|
||||
cur = cnx.cursor()
|
||||
|
||||
# On lance une requête pour vérifier si l'utilisateur correspond à la base de données
|
||||
query = "SELECT * FROM utilisateurs WHERE username = %s"
|
||||
cur.execute(query, (username,))
|
||||
|
||||
# Renvoie la première ligne de la base de données qui correspond
|
||||
user = cur.fetchone()
|
||||
|
||||
if user:
|
||||
# Utilisateur trouvé, on met à jour la clé Twitch
|
||||
new_twitch_key = self.entry_twitch.get()
|
||||
update_query = "UPDATE twitch SET twitch_key = %s WHERE username = %s"
|
||||
cur.execute(update_query, (new_twitch_key, username))
|
||||
cnx.commit()
|
||||
print(f"La clé a été mis à jour pour {username} avec la clé {new_twitch_key}")
|
||||
else:
|
||||
print(f"Utilisateur {username} non trouvée")
|
||||
|
||||
except mysql.connector.Error as err:
|
||||
print(f"Erreur: {err}")
|
||||
messagebox.showerror("Erreur", "Une erreur a eu lieu pour mettre à jour votre clé")
|
||||
|
||||
finally:
|
||||
# On ferme le tout, la connexion etc...
|
||||
cur.close()
|
||||
cnx.close()
|
||||
|
||||
def set_key_youtube(self, username):
|
||||
try:
|
||||
# Paramètres du serveur
|
||||
cnx = mysql.connector.connect(user='root', password='',
|
||||
host='127.0.0.1',
|
||||
database='obs_project')
|
||||
cur = cnx.cursor()
|
||||
|
||||
# On lance une requête pour vérifier si l'utilisateur correspond à la base de données
|
||||
query = "SELECT * FROM utilisateurs WHERE username = %s"
|
||||
cur.execute(query, (username,))
|
||||
|
||||
# Renvoie la première ligne de la base de données qui correspond
|
||||
user = cur.fetchone()
|
||||
|
||||
if user:
|
||||
# Utilisateur trouvé, on met à jour la clé Twitch
|
||||
new_youtube_key = self.entry_youtube.get()
|
||||
update_query = "UPDATE youtube SET youtube_key = %s WHERE username = %s"
|
||||
cur.execute(update_query, (new_youtube_key, username))
|
||||
cnx.commit()
|
||||
print(f"La clé a été mis à jour pour {username} avec la clé {new_youtube_key}")
|
||||
else:
|
||||
print(f"Utilisateur {username} non trouvée")
|
||||
|
||||
except mysql.connector.Error as err:
|
||||
print(f"Erreur: {err}")
|
||||
messagebox.showerror("Erreur", "Une erreur a eu lieu pour mettre à jour votre clé")
|
||||
|
||||
finally:
|
||||
# On ferme le tout, la connexion etc...
|
||||
cur.close()
|
||||
cnx.close()
|
||||
|
||||
def get_twitch_key_from_database(self, username):
|
||||
try:
|
||||
# Paramètres du serveur
|
||||
cnx = mysql.connector.connect(user='root', password='',
|
||||
host='127.0.0.1',
|
||||
database='obs_project')
|
||||
cur = cnx.cursor()
|
||||
|
||||
# On lance une requête pour récupérer la clé Twitch de l'utilisateur
|
||||
query = "SELECT twitch_key FROM twitch WHERE username = %s"
|
||||
cur.execute(query, (username,))
|
||||
twitch_key = cur.fetchone()
|
||||
|
||||
if twitch_key:
|
||||
return twitch_key[0]
|
||||
else:
|
||||
print(f"Clé Twitch non trouvée pour l'utilisateur {username}")
|
||||
return None
|
||||
|
||||
except mysql.connector.Error as err:
|
||||
print(f"Erreur: {err}")
|
||||
messagebox.showerror("Erreur", "Une erreur a eu lieu pour récupérer la clé Twitch")
|
||||
|
||||
finally:
|
||||
# On ferme le tout, la connexion etc...
|
||||
cur.close()
|
||||
cnx.close()
|
||||
|
||||
async def configure_obs_for_twitch(self, twitch_key_from_database):
|
||||
try:
|
||||
if twitch_key_from_database is not None:
|
||||
if not self.is_live:
|
||||
print("Connexion à OBS via Websocket avec les paramètres suivants :")
|
||||
print("Host:", self.obs_host)
|
||||
print("Port:", self.obs_port)
|
||||
print("Password:", self.obs_password)
|
||||
print("Twitch Stream Key:", twitch_key_from_database)
|
||||
|
||||
self.obs_ws = obsws(self.obs_host, self.obs_port, self.obs_password)
|
||||
self.obs_ws.connect()
|
||||
|
||||
# Démarre le streaming sur Twitch
|
||||
start_stream_request = obsrequests.StartStreaming(stream_key=twitch_key_from_database)
|
||||
self.obs_ws.call(start_stream_request)
|
||||
|
||||
self.is_live = True
|
||||
else:
|
||||
# Si déjà en live, arrêter le streaming
|
||||
print("Arrêt du streaming Twitch.")
|
||||
self.obs_ws.call(obsrequests.StopStreaming())
|
||||
self.obs_ws.disconnect()
|
||||
self.is_live = False
|
||||
else:
|
||||
print("La clé Twitch est manquante.")
|
||||
except Exception as e:
|
||||
print(f"Une erreur s'est produite lors de la configuration d'OBS pour Twitch : {e}")
|
||||
|
||||
|
||||
async def initialize_twitch(self):
|
||||
try:
|
||||
twitch = TwitchHelix(self.client_id, self.oauth_token)
|
||||
users = twitch.get_users()
|
||||
if users:
|
||||
print("Utilisateur Twitch trouvé:")
|
||||
print("ID:", users[0].id)
|
||||
print("Nom d'utilisateur:", users[0].display_name)
|
||||
else:
|
||||
print("Utilisateur Twitch non trouvé.")
|
||||
except Exception as e:
|
||||
print(f"Une erreur s'est produite lors de la récupération de l'utilisateur Twitch : {e}")
|
||||
|
||||
async def initialize_window(self, root, username, password):
|
||||
self.root = Toplevel(root)
|
||||
self.root.title("OBS Extension Multistreaming")
|
||||
self.root.geometry("1920x1080")
|
||||
|
||||
self.lancer_auth_twitch()
|
||||
await self.initialize_twitch()
|
||||
|
||||
def __init__(self, root, username, password):
|
||||
asyncio.run(self.initialize_window(root, username, password))
|
||||
|
||||
self.root.grid_rowconfigure(0, weight=0)
|
||||
self.root.grid_rowconfigure(1, weight=0)
|
||||
self.root.grid_rowconfigure(2, weight=0)
|
||||
self.root.grid_rowconfigure(3, weight=0)
|
||||
self.root.grid_rowconfigure(4, weight=0)
|
||||
self.root.grid_rowconfigure(5, weight=0)
|
||||
self.root.grid_rowconfigure(6, weight=0)
|
||||
self.root.grid_rowconfigure(7, weight=0)
|
||||
self.root.grid_rowconfigure(8, weight=0)
|
||||
self.root.grid_rowconfigure(9, weight=0)
|
||||
self.root.grid_rowconfigure(10, weight=0)
|
||||
self.root.grid_rowconfigure(11, weight=0)
|
||||
self.root.grid_rowconfigure(12, weight=0)
|
||||
self.root.grid_rowconfigure(13, weight=0)
|
||||
self.root.grid_rowconfigure(14, weight=0)
|
||||
self.root.grid_columnconfigure(0, weight=1)
|
||||
self.root.grid_columnconfigure(1, weight=0)
|
||||
self.root.grid_columnconfigure(2, weight=0)
|
||||
self.root.grid_columnconfigure(3, weight=0)
|
||||
|
||||
# Initialisez la connexion OBS WebSocket
|
||||
self.obs_host = "localhost" # Adresse IP de votre ordinateur où OBS est en cours d'exécution
|
||||
self.obs_port = 4455 # Port par défaut utilisé par OBSWebsocket
|
||||
self.obs_password = "MPcZLZfViZihHqmg" # Mot de passe OBSWebsocket
|
||||
|
||||
|
||||
# On récupère la clé Twitch depuis la base de données
|
||||
self.twitch_key_from_database = self.get_twitch_key_from_database(username)
|
||||
|
||||
# On affiche bienvenue à la personne s'étant identifiée, en récupérant la variable lastname
|
||||
label = Label(self.root, text=f"Bienvenue, {username}!")
|
||||
label.grid(row=0, column=0)
|
||||
|
||||
label = Label(self.root, text="Clé Twitch :")
|
||||
label.grid(row=2, column=0)
|
||||
|
||||
self.entry_twitch = Entry(self.root)
|
||||
self.entry_twitch.grid(row=3, column=0)
|
||||
|
||||
# On met un bouton de validation pour garder les valeurs qu'on a rentré précédement
|
||||
boutonvalidation = Button(self.root, text="Envoyé", command=lambda: self.set_key_twitch(username))
|
||||
boutonvalidation.grid(row=4, column=0)
|
||||
|
||||
# On met un bouton de diffusion pour twitch
|
||||
boutondediffusiontwitch = Button(self.root, text="Diffusion de Twitch On/Off", command=lambda: asyncio.run(self.configure_obs_for_twitch(self.twitch_key_from_database)))
|
||||
boutondediffusiontwitch.grid(row=4, column=3)
|
||||
|
||||
label = Label(self.root, text="Clé Youtube :")
|
||||
label.grid(row=5, column=0)
|
||||
|
||||
self.entry_youtube = Entry(self.root)
|
||||
self.entry_youtube.grid(row=6, column=0)
|
||||
|
||||
# On met un bouton pour envoyer les valeurs remplies du dessus
|
||||
boutonvalidation2 = Button(self.root, text="Envoyé", command=lambda: self.set_key_youtube(username))
|
||||
boutonvalidation2.grid(row=7, column=0)
|
||||
|
||||
# On met un bouton de diffusion pour twitch
|
||||
boutondediffusionyoutube = Button(self.root, text="Diffusion de YouTube On/Off")
|
||||
boutondediffusionyoutube.grid(row=7, column=3)
|
||||
|
||||
# On met un boutton fermer, pour pouvoir fermer la page main, et repasser sur la fenetre de connexion
|
||||
bouton_fermer = Button(self.root, text="Fermer", command=self.fermer_et_reafficher)
|
||||
bouton_fermer.grid(row=13, column=0)
|
||||
|
||||
def lancer_auth_twitch(self):
|
||||
# Vérifier si la colonne OAuth est vide dans la base de données
|
||||
oauth_token = self.get_oauth_token_from_database()
|
||||
if oauth_token is None:
|
||||
# Si la colonne OAuth est vide, ouvrir la page d'authentification Twitch
|
||||
webbrowser.open(self.oauth_authorization_url)
|
||||
messagebox.showinfo("Authentification Twitch", "Veuillez autoriser l'accès à Twitch dans le navigateur Web qui s'est ouvert.")
|
||||
else:
|
||||
# Si la colonne OAuth n'est pas vide, afficher un message indiquant que l'authentification n'est pas nécessaire
|
||||
messagebox.showinfo("Authentification Twitch", "L'authentification Twitch n'est pas nécessaire car le token OAuth est déjà présent dans la base de données.")
|
||||
|
||||
def get_oauth_token_from_database(self):
|
||||
# Code pour récupérer la valeur de la colonne OAuth dans la base de données
|
||||
# Retourne la valeur de la colonne OAuth
|
||||
return "z11zvdhgxvemn2l8kjl1dvczgiyelt"
|
108
test/mysqlco.py
Normal file
108
test/mysqlco.py
Normal file
@@ -0,0 +1,108 @@
|
||||
from main import *
|
||||
from tkinter import *
|
||||
from tkinter import messagebox
|
||||
import mysql.connector
|
||||
|
||||
class Mysql:
|
||||
# On initialise une première fenêtre d'identification et de mot de passe
|
||||
def __init__(self, root):
|
||||
self.root = root
|
||||
self.root.title("Launcher OBS Extension Multistreaming")
|
||||
self.root.geometry("400x300")
|
||||
self.root.grid_rowconfigure(0, weight=1)
|
||||
self.root.grid_rowconfigure(1, weight=1)
|
||||
self.root.grid_rowconfigure(2, weight=1)
|
||||
self.root.grid_rowconfigure(3, weight=1)
|
||||
self.root.grid_columnconfigure(0, weight=1)
|
||||
self.root.grid_columnconfigure(1, weight=0)
|
||||
self.root.grid_columnconfigure(2, weight=0)
|
||||
self.root.grid_columnconfigure(3, weight=0)
|
||||
|
||||
# On vérifie sur le serveur si l'identification correspond à des utilisateurs sur le serveur
|
||||
def authenticate_user(self, username, password):
|
||||
try:
|
||||
# Paramètres du serveur
|
||||
cnx = mysql.connector.connect(user='root', password='',
|
||||
host='127.0.0.1',
|
||||
database='obs_project')
|
||||
cur = cnx.cursor()
|
||||
|
||||
# On lance une requête pour vérifier si le lastname et le service correspond à la base de donnée
|
||||
query = "SELECT * FROM utilisateurs WHERE username = %s AND password = %s"
|
||||
cur.execute(query, (username, password))
|
||||
|
||||
# Renvoie la première ligne de la base de donnée qui correspond
|
||||
user = cur.fetchone()
|
||||
|
||||
# Si c'est le cas, on affiche le message suivant et on ouvre une nouvelle fenêtre
|
||||
if user:
|
||||
messagebox.showinfo("Validé", "Authentification réussi")
|
||||
self.ouvrir_nouvelle_fenetre(username, password)
|
||||
|
||||
# Sinon on affiche un message d'erreur
|
||||
else:
|
||||
messagebox.showerror("Erreur", "Authentification erroné")
|
||||
|
||||
# Message si une erreur innatendue
|
||||
except mysql.connector.Error as err:
|
||||
messagebox.showerror("Erreur", f"Erreur: {err}")
|
||||
|
||||
# On ferme le tout, la connexion etc...
|
||||
finally:
|
||||
cur.close()
|
||||
cnx.close()
|
||||
|
||||
# On va initialiser une nouvelle fenêtre après la connexion tout en fermant la première
|
||||
def ouvrir_nouvelle_fenetre(self, username, password):
|
||||
if self.root.winfo_exists(): # Vérifie si la fenêtre principale existe toujours
|
||||
self.root.withdraw() # Fermer la fenêtre actuelle
|
||||
NouvelleFenetre(self.root, username, password) # Création de la nouvelle fenêtre avec toutes les infos, utilitées etc...
|
||||
|
||||
|
||||
# Lorsqu'on clique sur la case identifiant, le texte se supprime pour pouvoir taper le sien
|
||||
def click_identifiant(self, event):
|
||||
entry_identifiant.configure(state=NORMAL)
|
||||
entry_identifiant.delete(0, END)
|
||||
entry_identifiant.unbind('<Button-1>', self.click_identifiant)
|
||||
|
||||
# Lorsqu'on clique sur la case password, le texte se supprime pour pouvoir taper le sien
|
||||
def click_pass(self, event):
|
||||
entry_pass.configure(state=NORMAL)
|
||||
entry_pass.delete(0, END)
|
||||
entry_pass.unbind('<Button-1>', self.click_pass)
|
||||
|
||||
# On test voir si le username et le password que l'on récupére, correspond pour s'identifier
|
||||
def msg_call_back(self):
|
||||
username = entry_identifiant.get()
|
||||
password = entry_pass.get()
|
||||
self.authenticate_user(username, password)
|
||||
|
||||
# Creation de la fenetre principale
|
||||
fenetre = Tk()
|
||||
obj = Mysql(fenetre)
|
||||
|
||||
# Ajout des boutons sur la fenêtre
|
||||
label = Label(fenetre, text="Connexion")
|
||||
label.grid(row = 0, column= 0)
|
||||
|
||||
# Entrée du champs identifiant
|
||||
entry_identifiant = Entry(fenetre)
|
||||
entry_identifiant.grid(row = 1, column=0)
|
||||
entry_identifiant.focus()
|
||||
entry_identifiant.insert(0, "Admin")
|
||||
|
||||
entry_identifiant.bind('<Button-1>', obj.click_identifiant)
|
||||
|
||||
# Entrée du champs password
|
||||
entry_pass = Entry(fenetre, show='*')
|
||||
entry_pass.grid(row = 2, column=0)
|
||||
entry_pass.insert(0, "Admin")
|
||||
|
||||
entry_pass.bind('<Button-1>', obj.click_pass)
|
||||
|
||||
# Bouton de connexion avec la fonction msg_call_back
|
||||
boutonconnexion = Button(fenetre, text="Connexion", command=obj.msg_call_back, activebackground = "green")
|
||||
boutonconnexion.grid(row = 3, column = 0)
|
||||
|
||||
# Lancer l'application
|
||||
fenetre.mainloop()
|
130
test/obs_project.sql
Normal file
130
test/obs_project.sql
Normal file
@@ -0,0 +1,130 @@
|
||||
-- phpMyAdmin SQL Dump
|
||||
-- version 5.2.1
|
||||
-- https://www.phpmyadmin.net/
|
||||
--
|
||||
-- Hôte : 127.0.0.1
|
||||
-- Généré le : lun. 04 mars 2024 à 16:59
|
||||
-- Version du serveur : 10.4.32-MariaDB
|
||||
-- Version de PHP : 8.2.12
|
||||
|
||||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||
START TRANSACTION;
|
||||
SET time_zone = "+00:00";
|
||||
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||
/*!40101 SET NAMES utf8mb4 */;
|
||||
|
||||
--
|
||||
-- Base de données : `obs_project`
|
||||
--
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la table `twitch`
|
||||
--
|
||||
|
||||
CREATE TABLE `twitch` (
|
||||
`id` int(255) NOT NULL,
|
||||
`username` varchar(15) NOT NULL,
|
||||
`twitch_key` varchar(100) NOT NULL,
|
||||
`OAuth_Key` varchar(100) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- Déchargement des données de la table `twitch`
|
||||
--
|
||||
|
||||
INSERT INTO `twitch` (`id`, `username`, `twitch_key`, `OAuth_Key`) VALUES
|
||||
(1, 'Admin', 'live_37250428_jeHrwf8xz3MR29xLYJQarW5nH5dyOK', 'z11zvdhgxvemn2l8kjl1dvczgiyelt');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la table `utilisateurs`
|
||||
--
|
||||
|
||||
CREATE TABLE `utilisateurs` (
|
||||
`id` int(255) NOT NULL,
|
||||
`username` varchar(15) NOT NULL,
|
||||
`password` varchar(20) NOT NULL,
|
||||
`mail` varchar(30) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- Déchargement des données de la table `utilisateurs`
|
||||
--
|
||||
|
||||
INSERT INTO `utilisateurs` (`id`, `username`, `password`, `mail`) VALUES
|
||||
(1, 'admin', 'admin', 'admin@gmail.com');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la table `youtube`
|
||||
--
|
||||
|
||||
CREATE TABLE `youtube` (
|
||||
`id` int(255) NOT NULL,
|
||||
`username` varchar(15) NOT NULL,
|
||||
`youtube_key` varchar(100) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
--
|
||||
-- Déchargement des données de la table `youtube`
|
||||
--
|
||||
|
||||
INSERT INTO `youtube` (`id`, `username`, `youtube_key`) VALUES
|
||||
(1, 'Admin', 'gdrthdrtbdfgbdd84');
|
||||
|
||||
--
|
||||
-- Index pour les tables déchargées
|
||||
--
|
||||
|
||||
--
|
||||
-- Index pour la table `twitch`
|
||||
--
|
||||
ALTER TABLE `twitch`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- Index pour la table `utilisateurs`
|
||||
--
|
||||
ALTER TABLE `utilisateurs`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- Index pour la table `youtube`
|
||||
--
|
||||
ALTER TABLE `youtube`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT pour les tables déchargées
|
||||
--
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT pour la table `twitch`
|
||||
--
|
||||
ALTER TABLE `twitch`
|
||||
MODIFY `id` int(255) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT pour la table `utilisateurs`
|
||||
--
|
||||
ALTER TABLE `utilisateurs`
|
||||
MODIFY `id` int(255) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT pour la table `youtube`
|
||||
--
|
||||
ALTER TABLE `youtube`
|
||||
MODIFY `id` int(255) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
|
||||
COMMIT;
|
||||
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
Reference in New Issue
Block a user