From 13e5dfd94c3a0e19a71c3dc6f2d67274dfae9494 Mon Sep 17 00:00:00 2001 From: vorlie Date: Fri, 24 Jan 2025 12:15:54 +0100 Subject: [PATCH] Implement a workaround for presence images due to discords changes --- config.py | 12 +++++++++++- core/discordIntegration.py | 4 +++- core/musicPlayer.py | 13 ++++++------- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/config.py b/config.py index a55167a..89fcc09 100644 --- a/config.py +++ b/config.py @@ -11,5 +11,15 @@ "root_playlist_folder": "playlists", "default_playlist": "default", "colorization_color": "automatic", - "volume_percantage": 100 + "volume_percantage": 100, + "minimize_to_tray": False, +} + +discord_cdn_images = { + "default_image":"https://cdn.discordapp.com/app-assets/1150680286649143356/1270124442433097780.png", + "pause":"https://cdn.discordapp.com/app-assets/1150680286649143356/1273715119846850754.png", + "play": "https://cdn.discordapp.com/app-assets/1150680286649143356/1273715119691661343.png", + "repeat":"https://cdn.discordapp.com/app-assets/1150680286649143356/1273715119913959444.png", + "repeat-one":"https://cdn.discordapp.com/app-assets/1150680286649143356/1273715119733346315.png", + "stop":"https://cdn.discordapp.com/app-assets/1150680286649143356/1273717793455603743.png" } \ No newline at end of file diff --git a/core/discordIntegration.py b/core/discordIntegration.py index 8b2419d..333a012 100644 --- a/core/discordIntegration.py +++ b/core/discordIntegration.py @@ -2,6 +2,7 @@ import time, logging, json from PyQt5.QtCore import QObject, pyqtSignal from core.logger import setup_logging +from config import discord_cdn_images discord_logger = logging.getLogger('discord') @@ -14,7 +15,8 @@ def __init__(self): with open('config.json', 'r', encoding='utf-8') as f: self.config = json.load(f) self.client_id = self.config.get('discord_client_id', '1150680286649143356') - self.large_image_key = self.config.get('large_image_key', 'default_image') + #self.large_image_key = self.config.get('large_image_key', 'default_image') + self.large_image_key = discord_cdn_images.get('default_image', 'https://cdn.discordapp.com/app-assets/1150680286649143356/1270124442433097780.png') self.connect_to_discord = self.config.get('connect_to_discord', True) self.use_playing_status = self.config.get('use_playing_status', False) diff --git a/core/musicPlayer.py b/core/musicPlayer.py index b89dc6d..337c998 100644 --- a/core/musicPlayer.py +++ b/core/musicPlayer.py @@ -16,6 +16,7 @@ from core.logger import setup_logging from pycaw.pycaw import AudioUtilities, IAudioEndpointVolume from comtypes import CLSCTX_ALL +from config import discord_cdn_images class MusicPlayer(QMainWindow): def __init__(self, settings, icon_path, config_path, theme, normal): @@ -770,18 +771,16 @@ def update_song_info(self): self.setWindowTitle(f"Iota Player • {self.current_playlist} • {self.song_info_var}") # Determine loop status for Discord presence - small_image_key = "play" # Default to play icon + small_image_key = discord_cdn_images["play"] # Default to play icon small_image_text = "Playing" # Default to playing text if self.is_looping == "Song": - small_image_key = "repeat-one" # Small image key for song repeat + small_image_key = discord_cdn_images["repeat-one"] # Small image key for song repeat small_image_text = "Looping Song" # Text for song repeat elif self.is_looping == "Playlist": - small_image_key = "repeat" # Small image key for playlist repeat + small_image_key = discord_cdn_images["repeat"] # Small image key for playlist repeat small_image_text = "Looping Playlist" # Text for playlist repeat - - # Update Discord presence if self.config['connect_to_discord']: # Check if Discord connection is enabled if self.current_song["picture_link"]: # Check if there is a picture link @@ -800,7 +799,7 @@ def update_song_info(self): f"{self.current_song['title']}", f"{self.current_song['artist']}", image_text, - "pause", + discord_cdn_images["pause"], "Paused", 0, big_image, @@ -824,7 +823,7 @@ def update_song_info(self): "Nothing is playing", # Title "Literally nothing.", # Artist "No playlist", # Large image text - "stop", # Small image key + discord_cdn_images["stop"], # Small image key "Stopped", # Small image text None, # Youtube ID for button None, # Playlist image