Skip to content

Commit

Permalink
Comment out broken code parts.
Browse files Browse the repository at this point in the history
  • Loading branch information
vorlie committed Sep 2, 2024
1 parent 03d9242 commit 0e35d89
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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/
21 changes: 21 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -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
}
67 changes: 67 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
29 changes: 29 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -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"
}
21 changes: 18 additions & 3 deletions core/discordIntegration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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()
Expand Down
8 changes: 4 additions & 4 deletions core/musicPlayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand All @@ -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):
Expand Down

0 comments on commit 0e35d89

Please sign in to comment.