mirror of
https://github.com/Benexl/FastAnime.git
synced 2026-07-06 04:34:11 -07:00
fix(anilist-interface): check if both total and stop time are defined
This commit is contained in:
@@ -45,11 +45,14 @@ def calculate_percentage_completion(start_time, end_time):
|
||||
[TODO:return]
|
||||
"""
|
||||
|
||||
start = start_time.split(":")
|
||||
end = end_time.split(":")
|
||||
start_secs = int(start[0]) * 3600 + int(start[1]) * 60 + int(start[2])
|
||||
end_secs = int(end[0]) * 3600 + int(end[1]) * 60 + int(end[2])
|
||||
return start_secs / end_secs * 100
|
||||
try:
|
||||
start = start_time.split(":")
|
||||
end = end_time.split(":")
|
||||
start_secs = int(start[0]) * 3600 + int(start[1]) * 60 + int(start[2])
|
||||
end_secs = int(end[0]) * 3600 + int(end[1]) * 60 + int(end[2])
|
||||
return start_secs / end_secs * 100
|
||||
except Exception:
|
||||
return 0
|
||||
|
||||
|
||||
def media_player_controls(
|
||||
@@ -701,7 +704,7 @@ def provider_anime_episodes_menu(
|
||||
total_time = user_watch_history.get(str(anime_id_anilist), {}).get(
|
||||
"episode_total_length", "0"
|
||||
)
|
||||
if stop_time != "0" or total_time != "0":
|
||||
if stop_time != "0" and total_time != "0":
|
||||
percentage_completion_of_episode = calculate_percentage_completion(
|
||||
stop_time, total_time
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user