mirror of
https://github.com/skylanix/MamieHenriette.git
synced 2026-02-06 14:50:34 +01:00
Ajout de nouvelles colonnes pour la personnalisation des notifications YouTube dans la table youtube_notification, y compris le titre, la description, la couleur, le pied de page, le nom et l'icône de l'auteur, ainsi que des options pour afficher la miniature et l'image. Mise à jour de l'interface web pour permettre la configuration de ces options et ajout d'une prévisualisation de l'embed Discord.
This commit is contained in:
@@ -33,7 +33,13 @@ def _set_sqlite_pragma(dbapi_connection, connection_record):
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def _tableExists(table_name:str, cursor:Cursor) -> bool:
|
||||
cursor.execute("SELECT name FROM sqlite_master WHERE type='table' AND name=?", (table_name,))
|
||||
return cursor.fetchone() is not None
|
||||
|
||||
def _tableHaveColumn(table_name:str, column_name:str, cursor:Cursor) -> bool:
|
||||
if not _tableExists(table_name, cursor):
|
||||
return False
|
||||
cursor.execute(f'PRAGMA table_info({table_name})')
|
||||
columns = cursor.fetchall()
|
||||
return any(col[1] == column_name for col in columns)
|
||||
@@ -64,6 +70,27 @@ def _doPostImportMigration(cursor:Cursor):
|
||||
cursor.execute('INSERT INTO game_bundle(url, name, json) VALUES (?, ?, ?)', (url, name, json.dumps(json_data)))
|
||||
logging.info("suppression de la table temporaire game_bundle_old")
|
||||
_dropTable('game_bundle_old', cursor)
|
||||
|
||||
if _tableExists('youtube_notification', cursor):
|
||||
logging.info("Migration de la table youtube_notification: ajout des colonnes d'embed")
|
||||
embed_columns = [
|
||||
('embed_title', 'VARCHAR(256)'),
|
||||
('embed_description', 'VARCHAR(2000)'),
|
||||
('embed_color', 'VARCHAR(8) DEFAULT "FF0000"'),
|
||||
('embed_footer', 'VARCHAR(2048)'),
|
||||
('embed_author_name', 'VARCHAR(256)'),
|
||||
('embed_author_icon', 'VARCHAR(512)'),
|
||||
('embed_thumbnail', 'BOOLEAN DEFAULT 1'),
|
||||
('embed_image', 'BOOLEAN DEFAULT 1')
|
||||
]
|
||||
for col_name, col_type in embed_columns:
|
||||
if not _tableHaveColumn('youtube_notification', col_name, cursor):
|
||||
try:
|
||||
cursor.execute(f'ALTER TABLE youtube_notification ADD COLUMN {col_name} {col_type}')
|
||||
logging.info(f"Colonne {col_name} ajoutée à youtube_notification")
|
||||
except Exception as e:
|
||||
logging.error(f"Impossible d'ajouter la colonne {col_name}: {e}")
|
||||
raise
|
||||
|
||||
with webapp.app_context():
|
||||
with open('database/schema.sql', 'r') as f:
|
||||
|
||||
@@ -65,9 +65,17 @@ class YouTubeNotification(db.Model):
|
||||
__tablename__ = 'youtube_notification'
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
enable = db.Column(db.Boolean, default=True)
|
||||
channel_id = db.Column(db.String(128)) # ID de la chaîne YouTube
|
||||
notify_channel = db.Column(db.Integer) # ID du canal Discord
|
||||
channel_id = db.Column(db.String(128))
|
||||
notify_channel = db.Column(db.Integer)
|
||||
message = db.Column(db.String(2000))
|
||||
video_type = db.Column(db.String(16), default='all') # 'all', 'video', 'short'
|
||||
last_video_id = db.Column(db.String(128)) # ID de la dernière vidéo notifiée
|
||||
video_type = db.Column(db.String(16), default='all')
|
||||
last_video_id = db.Column(db.String(128))
|
||||
embed_title = db.Column(db.String(256))
|
||||
embed_description = db.Column(db.String(2000))
|
||||
embed_color = db.Column(db.String(8), default='FF0000')
|
||||
embed_footer = db.Column(db.String(2048))
|
||||
embed_author_name = db.Column(db.String(256))
|
||||
embed_author_icon = db.Column(db.String(512))
|
||||
embed_thumbnail = db.Column(db.Boolean, default=True)
|
||||
embed_image = db.Column(db.Boolean, default=True)
|
||||
|
||||
|
||||
@@ -84,5 +84,13 @@ CREATE TABLE IF NOT EXISTS `youtube_notification` (
|
||||
`notify_channel` INTEGER NOT NULL,
|
||||
`message` VARCHAR(2000) NOT NULL,
|
||||
`video_type` VARCHAR(16) NOT NULL DEFAULT 'all',
|
||||
`last_video_id` VARCHAR(128)
|
||||
`last_video_id` VARCHAR(128),
|
||||
`embed_title` VARCHAR(256),
|
||||
`embed_description` VARCHAR(2000),
|
||||
`embed_color` VARCHAR(8) NOT NULL DEFAULT 'FF0000',
|
||||
`embed_footer` VARCHAR(2048),
|
||||
`embed_author_name` VARCHAR(256),
|
||||
`embed_author_icon` VARCHAR(512),
|
||||
`embed_thumbnail` BOOLEAN NOT NULL DEFAULT TRUE,
|
||||
`embed_image` BOOLEAN NOT NULL DEFAULT TRUE
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user