Skip to content

Commit

Permalink
Fixed: attempt to fix time left 00:00 in RPC
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroquinc committed Jan 20, 2024
1 parent 289cd88 commit 94bbbe0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ def fetch_length(session):
# Function to set the RP with the provided info and length
def set_rp(info, length):
global previous_info, previous_speed, cache
# Initialize start_time with a default value
start_time, end_time = None, None
# Check if 'result' and 'item' keys exist in the info and 'result' and 'speed' keys exist in the length to prevent errors
if 'result' in info and 'item' in info['result']:
info = info['result']['item']
Expand Down Expand Up @@ -129,9 +131,11 @@ def set_rp(info, length):
cache[cache_key] = (media_type, urls)
logger.debug(f"Cached values for {cache_key}: media_type={media_type}, urls={urls}")

# Calculate start_time and end_time outside the cache check, as they are not being cached
start_time = calculate_start_time(length)
end_time = calculate_end_time(start_time, length)
# Calculate start_time and end_time outside the cache check, as they are not being cached, but only if the media is playing
if length['speed'] != 0:
start_time = calculate_start_time(length)
end_time = calculate_end_time(start_time, length)
logger.debug(f"Calculated start_time={start_time} and end_time={end_time}")

update_rpc_mediatype(info, length, start_time, end_time, image_url, imdb_url, tmdb_url, trakt_url, letterboxd_url)

Expand Down

0 comments on commit 94bbbe0

Please sign in to comment.