From 0e35d892a13c7cbafc48fc61e44869ab0d0f1eee Mon Sep 17 00:00:00 2001 From: vorlie Date: Mon, 2 Sep 2024 19:02:34 +0200 Subject: [PATCH] Comment out broken code parts. --- .gitignore | 3 ++ .vscode/c_cpp_properties.json | 21 +++++++++++ .vscode/settings.json | 67 +++++++++++++++++++++++++++++++++++ .vscode/tasks.json | 29 +++++++++++++++ core/discordIntegration.py | 21 +++++++++-- core/musicPlayer.py | 8 ++--- 6 files changed, 142 insertions(+), 7 deletions(-) create mode 100644 .vscode/c_cpp_properties.json create mode 100644 .vscode/settings.json create mode 100644 .vscode/tasks.json diff --git a/.gitignore b/.gitignore index 043bda2..fb5820d 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,6 @@ __pycache__/ *.log test.py venv/ + +# Ignore this folder because it doesn't even work, contains cpp version of filerenamer.py +FileRenamer/ \ No newline at end of file diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..c78c930 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,21 @@ +{ + "configurations": [ + { + "name": "Win32", + "includePath": [ + "${workspaceFolder}/**" + ], + "defines": [ + "_DEBUG", + "UNICODE", + "_UNICODE" + ], + "windowsSdkVersion": "10.0.22000.0", + "compilerPath": "cl.exe", + "cStandard": "c17", + "cppStandard": "c++17", + "intelliSenseMode": "windows-msvc-x64" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..6b8fd08 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,67 @@ +{ + "files.associations": { + "iostream": "cpp", + "algorithm": "cpp", + "atomic": "cpp", + "bit": "cpp", + "cctype": "cpp", + "charconv": "cpp", + "chrono": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "codecvt": "cpp", + "compare": "cpp", + "concepts": "cpp", + "cstddef": "cpp", + "cstdint": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cstring": "cpp", + "ctime": "cpp", + "cwchar": "cpp", + "exception": "cpp", + "filesystem": "cpp", + "format": "cpp", + "forward_list": "cpp", + "initializer_list": "cpp", + "iomanip": "cpp", + "ios": "cpp", + "iosfwd": "cpp", + "istream": "cpp", + "iterator": "cpp", + "limits": "cpp", + "list": "cpp", + "locale": "cpp", + "map": "cpp", + "memory": "cpp", + "new": "cpp", + "optional": "cpp", + "ostream": "cpp", + "ratio": "cpp", + "regex": "cpp", + "sstream": "cpp", + "stdexcept": "cpp", + "streambuf": "cpp", + "string": "cpp", + "system_error": "cpp", + "tuple": "cpp", + "type_traits": "cpp", + "typeinfo": "cpp", + "utility": "cpp", + "vector": "cpp", + "xfacet": "cpp", + "xiosbase": "cpp", + "xlocale": "cpp", + "xlocbuf": "cpp", + "xlocinfo": "cpp", + "xlocmes": "cpp", + "xlocmon": "cpp", + "xlocnum": "cpp", + "xloctime": "cpp", + "xmemory": "cpp", + "xstring": "cpp", + "xtr1common": "cpp", + "xtree": "cpp", + "xutility": "cpp" + } +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..43bf0d6 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,29 @@ +{ + "tasks": [ + { + "type": "cppbuild", + "label": "C/C++: cl.exe build active file", + "command": "cl.exe", + "args": [ + "/Zi", + "/EHsc", + "/std:c++17", + "/nologo", + "/Fe${fileDirname}\\${fileBasenameNoExtension}.exe", + "${file}" + ], + "options": { + "cwd": "${fileDirname}" + }, + "problemMatcher": [ + "$msCompile" + ], + "group": { + "kind": "build", + "isDefault": true + }, + "detail": "Task generated by Debugger." + } + ], + "version": "2.0.0" +} \ No newline at end of file diff --git a/core/discordIntegration.py b/core/discordIntegration.py index b8f6810..df1c999 100644 --- a/core/discordIntegration.py +++ b/core/discordIntegration.py @@ -38,8 +38,8 @@ def connect(self): def is_connected(self): return self.RPC is not None - - def update_presence(self, song_title, artist_name, large_image_text, small_image_key: str, small_image_text: str, youtube_id=None, image_key=None, song_duration=None): + + def update_presence(self, song_title, artist_name, large_image_text, small_image_key: str, small_image_text: str, youtube_id=None, image_key=None): # , song_duration=None - not used right now if not self.connect_to_discord: discord_logger.info("Discord integration is disabled. Skipping presence update.") return @@ -67,6 +67,19 @@ def update_presence(self, song_title, artist_name, large_image_text, small_image if youtube_id: buttons.append({"label": "Open in YouTube", "url": f"https://www.youtube.com/watch?v={youtube_id}"}) try: + self.RPC.update( + activity_type = use_playing_status, + state=f"{artist_name}", + details=f"{song_title}", + large_image=large_image_key, + large_text=large_image_text, + small_image=small_image_key, + small_text=small_image_text, + buttons=buttons + ) + discord_logger.info(f"Presence updated: {song_title} by {artist_name}; Buttons: {buttons}; Start time: 0; End time: 0") + # Commented because duration when pausing/resuming is being resetted to the song initial duration, rather than continuing from the paused moment + """ if song_duration is None: self.RPC.update( activity_type = use_playing_status, @@ -95,11 +108,13 @@ def update_presence(self, song_title, artist_name, large_image_text, small_image buttons=buttons ) discord_logger.info(f"Presence updated: {song_title} by {artist_name}; Buttons: {buttons}; Start time: {start_time}; End time: {end_time}") + """ except Exception as e: if "rate limit" in str(e).lower(): discord_logger.warning(f"Rate limit hit: {e}. Waiting before retrying...") time.sleep(15) - self.update_presence(song_title, artist_name, song_duration, youtube_id) # Retry after waiting + #self.update_presence(song_title, artist_name, song_duration, youtube_id) # Retry after waiting + self.update_presence(song_title, artist_name, large_image_text, small_image_key, small_image_text, youtube_id) else: discord_logger.error(f"Failed to update Discord presence: {e}") self.connect() diff --git a/core/musicPlayer.py b/core/musicPlayer.py index 0b4e3c5..f9ce0aa 100644 --- a/core/musicPlayer.py +++ b/core/musicPlayer.py @@ -738,12 +738,12 @@ def update_song_info(self): "Paused", # Small image text 0, # Youtube ID for button big_image, # Playlist image - None, # Duration + #None, # Duration, commented because it doesn't work as expected ) else: # Playing and not paused title = f"{self.current_song['title']}" if self.current_song else "No song playing" artist = f"{self.current_song['artist']}" if self.current_song else "No artist" - song_duration = self.get_song_length(self.current_song['path']) if self.current_song else 0 + #song_duration = self.get_song_length(self.current_song['path']) if self.current_song else 0 self.discord_integration.update_presence( title, # Title artist, # Artist @@ -752,7 +752,7 @@ def update_song_info(self): small_image_text, # Small image text self.current_song.get('youtube_id') if self.current_song else None, # Youtube ID for button big_image, # Playlist image - song_duration, # Duration + #song_duration, # Duration, commented because it doesn't work as expected ) else: # No song is playing self.discord_integration.update_presence( @@ -763,7 +763,7 @@ def update_song_info(self): "Stopped", # Small image text None, # Youtube ID for button None, # Playlist image - None # Duration + #None, # Duration, commented because it doesn't work as expected ) def update_right_frame_info(self):