Skip to content

Commit

Permalink
Implement a workaround for presence images due to discords changes
Browse files Browse the repository at this point in the history
  • Loading branch information
vorlie committed Jan 24, 2025
1 parent 6f19a9f commit 13e5dfd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
12 changes: 11 additions & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
4 changes: 3 additions & 1 deletion core/discordIntegration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand All @@ -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)

Expand Down
13 changes: 6 additions & 7 deletions core/musicPlayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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
Expand Down

0 comments on commit 13e5dfd

Please sign in to comment.