Commit 7d92b0529c

7d92b0529c9e369e5f98749a0f15da152f6c3151

parent: 1036c544ee

Unsigned

Wraient <wraient.911@gmail.com> · 2024-09-24 20:31 UTC

Not verbose at all

Layout: unified · split

curd.py +49 −46
@@ -87,10 +87,12 @@ default_config = {
8787 "presence_script_path":"curddiscordpresence.py"
8888}
8989
90def convert_seconds_to_minutes(seconds):
90def convert_seconds_to_minutes(seconds) -> str:
9191 minutes = seconds // 60
9292 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}"
9496
9597def get_userconfig_value(userconfig:dict, key:str):
9698 return userconfig.get(key, default_config.get(key))
@@ -363,12 +365,11 @@ while True:
363365
364366 # print("mpv_status", mpv_status)
365367 # print("is_paused", is_paused)
366 playback_time_minutes = convert_seconds_to_minutes(playback_time)
367368 if is_paused:
368369 # Update presence with paused status
369370 rpc.update(
370371 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)",
372373 large_image=anime_image_url,
373374 large_text=title,
374375 )
@@ -376,7 +377,7 @@ while True:
376377 # Update presence with playback time
377378 rpc.update(
378379 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",
380381 large_image=anime_image_url,
381382 large_text=title,
382383 )
@@ -446,45 +447,47 @@ while True:
446447 exit(0)
447448 finally:
448449 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)
449462
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
scripts/episode_url.sh +2 −1
@@ -24,7 +24,8 @@ get_links() {
2424 *) [ -n "$episode_link" ] && printf "%s\n" "$episode_link" ;;
2525 esac
2626 # echo $episode_link >> links
27 [ -z "$ANI_CLI_NON_INTERACTIVE" ] && printf "\033[1;32m%s\033[0m Links Fetched\n" "$provider_name" 1>&2
27 # [ -z "$ANI_CLI_NON_INTERACTIVE" ] && printf "\033[1;32m%s\033[0m Links Fetched\n" "$provider_name" 1>&2
28 [ -z "$ANI_CLI_NON_INTERACTIVE" ] 1>&2
2829}
2930
3031# # innitialises provider_name and provider_id. First argument is the provider name, 2nd is the regex that matches that provider's link
start_video.py +1 −1
@@ -9,7 +9,7 @@ def start_video(link, salt:str, args:list=[]):
99 args_str = ' '.join(args)
1010
1111 # Build the complete command string
12 command = f"mpv {args_str} --input-ipc-server=/tmp/mpvsocket{salt} {link}"
12 command = f"mpv {args_str} --no-terminal --really-quiet --input-ipc-server=/tmp/mpvsocket{salt} {link}"
1313
1414 subprocess.Popen(command, shell=True)
1515 # os.system()