| @@ -87,10 +87,12 @@ default_config = { |
| 87 | 87 | "presence_script_path":"curddiscordpresence.py" |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | | def convert_seconds_to_minutes(seconds): |
| 90 | def convert_seconds_to_minutes(seconds) -> str: |
| 91 | 91 | minutes = seconds // 60 |
| 92 | 92 | remaining_seconds = seconds % 60 |
| 93 | | return minutes, remaining_seconds |
| 93 | if remaining_seconds < 10: |
| 94 | return f"{minutes}:0{remaining_seconds}" |
| 95 | return f"{minutes}:{remaining_seconds}" |
| 94 | 96 | |
| 95 | 97 | def get_userconfig_value(userconfig:dict, key:str): |
| 96 | 98 | return userconfig.get(key, default_config.get(key)) |
| @@ -363,12 +365,11 @@ while True: |
| 363 | 365 | |
| 364 | 366 | # print("mpv_status", mpv_status) |
| 365 | 367 | # print("is_paused", is_paused) |
| 366 | | playback_time_minutes = convert_seconds_to_minutes(playback_time) |
| 367 | 368 | if is_paused: |
| 368 | 369 | # Update presence with paused status |
| 369 | 370 | rpc.update( |
| 370 | 371 | details=f"Watching {title}", |
| 371 | | state=f"Episode {watching_ep} - {"{}:{}".format(playback_time_minutes[0], playback_time_minutes[1])} (Paused)", |
| 372 | state=f"Episode {watching_ep} - {convert_seconds_to_minutes(playback_time)} (Paused)", |
| 372 | 373 | large_image=anime_image_url, |
| 373 | 374 | large_text=title, |
| 374 | 375 | ) |
| @@ -376,7 +377,7 @@ while True: |
| 376 | 377 | # Update presence with playback time |
| 377 | 378 | rpc.update( |
| 378 | 379 | details=f"Watching {title}", |
| 379 | | state=f"Episode {watching_ep} - {playback_time_minutes[0]}:{playback_time_minutes[1]}/{duration}:00", |
| 380 | state=f"Episode {watching_ep} - {convert_seconds_to_minutes(playback_time)}/{duration}:00", |
| 380 | 381 | large_image=anime_image_url, |
| 381 | 382 | large_text=title, |
| 382 | 383 | ) |
| @@ -446,45 +447,47 @@ while True: |
| 446 | 447 | exit(0) |
| 447 | 448 | finally: |
| 448 | 449 | binge_watching=True |
| 450 | try: |
| 451 | print("binge watching") |
| 452 | current_ep = int(read_tmp("ep_no")) |
| 453 | |
| 454 | if current_ep == last_episode: |
| 455 | if binge_watching == True and not rewatching and get_userconfig_value(user_config, 'score_on_completion') == True: # Completed anime |
| 456 | anime_rating_by_user = input("Rate this anime:\n") |
| 457 | update_anime_progress(access_token, int(media_id), int(watching_ep)) |
| 458 | rate_anime(access_token, media_id, anime_rating_by_user) |
| 459 | print("completed anime.") |
| 460 | delete_anime(get_userconfig_value(user_config, 'history_file'), media_id, get_contents_of("id")) |
| 461 | exit(0) |
| 449 | 462 | |
| 450 | | print("binge watching") |
| 451 | | current_ep = int(read_tmp("ep_no")) |
| 452 | | |
| 453 | | if current_ep == last_episode: |
| 454 | | if binge_watching == True and not rewatching and get_userconfig_value(user_config, 'score_on_completion') == True: # Completed anime |
| 455 | | anime_rating_by_user = input("Rate this anime:\n") |
| 456 | | update_anime_progress(access_token, int(media_id), int(watching_ep)) |
| 457 | | rate_anime(access_token, media_id, anime_rating_by_user) |
| 458 | | print("completed anime.") |
| 459 | | delete_anime(get_userconfig_value(user_config, 'history_file'), media_id, get_contents_of("id")) |
| 460 | | exit(0) |
| 461 | | |
| 462 | | else: |
| 463 | | print(f"Starting next episode: {current_ep}") |
| 464 | | # write_to_tmp("ep_no", str(int(current_ep)+1)) |
| 465 | | |
| 466 | | if watched_percentage > mark_episode_as_completed_at: # IF BINGE WATCHING |
| 467 | | last_episode = int(read_tmp("episode_list").split()[-1]) |
| 468 | | if not rewatching: |
| 469 | | update_anime_progress(access_token, int(media_id), int(watching_ep)) |
| 470 | | watching_ep = int(watching_ep)+1 |
| 471 | | write_to_tmp("ep_no", str(watching_ep)) |
| 472 | | update_anime(get_userconfig_value(user_config, 'history_file'), str(media_id), str(get_contents_of("id")), str(watching_ep), "0", str(duration), str(title)) |
| 473 | | anime_watch_history = get_all_anime(get_userconfig_value(user_config, 'history_file')) |
| 474 | | anime_history = find_anime(anime_watch_history, anilist_id=media_id, allanime_id=get_contents_of("id")) |
| 475 | | episode_completed = False |
| 476 | | run_script("episode_url") |
| 477 | | links = load_links(f"{current_dir}/scripts/tmp/links") |
| 478 | | mpv_args = [] |
| 479 | | watched_percentage = 0 |
| 480 | | |
| 481 | | if get_userconfig_value(user_config, 'save_mpv_speed') ==True: |
| 482 | | mpv_args.append(f'--speed={mpv_playback_speed}') |
| 483 | | |
| 484 | | # watching_ep = current_ep+1 |
| 485 | | if get_userconfig_value(user_config, 'next_episode_prompt') == True: |
| 486 | | to_continue_or_not_to_continue = input("Continue? (y/n)\n") |
| 487 | | if to_continue_or_not_to_continue.lower() == "yes" or to_continue_or_not_to_continue.lower() == "y" or to_continue_or_not_to_continue == "": |
| 488 | | binge_watching = True |
| 489 | | else: |
| 490 | | exit(0) |
| \ No newline at end of file |
| 463 | else: |
| 464 | print(f"Starting next episode: {current_ep}") |
| 465 | # write_to_tmp("ep_no", str(int(current_ep)+1)) |
| 466 | |
| 467 | if watched_percentage > mark_episode_as_completed_at: # IF BINGE WATCHING |
| 468 | last_episode = int(read_tmp("episode_list").split()[-1]) |
| 469 | if not rewatching: |
| 470 | update_anime_progress(access_token, int(media_id), int(watching_ep)) |
| 471 | watching_ep = int(watching_ep)+1 |
| 472 | write_to_tmp("ep_no", str(watching_ep)) |
| 473 | update_anime(get_userconfig_value(user_config, 'history_file'), str(media_id), str(get_contents_of("id")), str(watching_ep), "0", str(duration), str(title)) |
| 474 | anime_watch_history = get_all_anime(get_userconfig_value(user_config, 'history_file')) |
| 475 | anime_history = find_anime(anime_watch_history, anilist_id=media_id, allanime_id=get_contents_of("id")) |
| 476 | episode_completed = False |
| 477 | run_script("episode_url") |
| 478 | links = load_links(f"{current_dir}/scripts/tmp/links") |
| 479 | mpv_args = [] |
| 480 | watched_percentage = 0 |
| 481 | |
| 482 | if get_userconfig_value(user_config, 'save_mpv_speed') ==True: |
| 483 | mpv_args.append(f'--speed={mpv_playback_speed}') |
| 484 | |
| 485 | # watching_ep = current_ep+1 |
| 486 | if get_userconfig_value(user_config, 'next_episode_prompt') == True: |
| 487 | to_continue_or_not_to_continue = input("Continue? (y/n)\n") |
| 488 | if to_continue_or_not_to_continue.lower() == "yes" or to_continue_or_not_to_continue.lower() == "y" or to_continue_or_not_to_continue == "": |
| 489 | binge_watching = True |
| 490 | else: |
| 491 | exit(0) |
| 492 | except Exception as e: |
| 493 | print(f"error:{e}\nMaybe try running again!") |
| \ No newline at end of file |