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 = {
87 "presence_script_path":"curddiscordpresence.py" 87 "presence_script_path":"curddiscordpresence.py"
88} 88}
89 89
90def convert_seconds_to_minutes(seconds): 90def convert_seconds_to_minutes(seconds) -> str:
91 minutes = seconds // 60 91 minutes = seconds // 60
92 remaining_seconds = seconds % 60 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
95def get_userconfig_value(userconfig:dict, key:str): 97def get_userconfig_value(userconfig:dict, key:str):
96 return userconfig.get(key, default_config.get(key)) 98 return userconfig.get(key, default_config.get(key))
@@ -363,12 +365,11 @@ while True:
363 365
364 # print("mpv_status", mpv_status) 366 # print("mpv_status", mpv_status)
365 # print("is_paused", is_paused) 367 # print("is_paused", is_paused)
366 playback_time_minutes = convert_seconds_to_minutes(playback_time)
367 if is_paused: 368 if is_paused:
368 # Update presence with paused status 369 # Update presence with paused status
369 rpc.update( 370 rpc.update(
370 details=f"Watching {title}", 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 large_image=anime_image_url, 373 large_image=anime_image_url,
373 large_text=title, 374 large_text=title,
374 ) 375 )
@@ -376,7 +377,7 @@ while True:
376 # Update presence with playback time 377 # Update presence with playback time
377 rpc.update( 378 rpc.update(
378 details=f"Watching {title}", 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 large_image=anime_image_url, 381 large_image=anime_image_url,
381 large_text=title, 382 large_text=title,
382 ) 383 )
@@ -446,45 +447,47 @@ while True:
446 exit(0) 447 exit(0)
447 finally: 448 finally:
448 binge_watching=True 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") 463 else:
451 current_ep = int(read_tmp("ep_no")) 464 print(f"Starting next episode: {current_ep}")
452 465 # write_to_tmp("ep_no", str(int(current_ep)+1))
453 if current_ep == last_episode: 466
454 if binge_watching == True and not rewatching and get_userconfig_value(user_config, 'score_on_completion') == True: # Completed anime 467 if watched_percentage > mark_episode_as_completed_at: # IF BINGE WATCHING
455 anime_rating_by_user = input("Rate this anime:\n") 468 last_episode = int(read_tmp("episode_list").split()[-1])
456 update_anime_progress(access_token, int(media_id), int(watching_ep)) 469 if not rewatching:
457 rate_anime(access_token, media_id, anime_rating_by_user) 470 update_anime_progress(access_token, int(media_id), int(watching_ep))
458 print("completed anime.") 471 watching_ep = int(watching_ep)+1
459 delete_anime(get_userconfig_value(user_config, 'history_file'), media_id, get_contents_of("id")) 472 write_to_tmp("ep_no", str(watching_ep))
460 exit(0) 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))
461 474 anime_watch_history = get_all_anime(get_userconfig_value(user_config, 'history_file'))
462 else: 475 anime_history = find_anime(anime_watch_history, anilist_id=media_id, allanime_id=get_contents_of("id"))
463 print(f"Starting next episode: {current_ep}") 476 episode_completed = False
464 # write_to_tmp("ep_no", str(int(current_ep)+1)) 477 run_script("episode_url")
465 478 links = load_links(f"{current_dir}/scripts/tmp/links")
466 if watched_percentage > mark_episode_as_completed_at: # IF BINGE WATCHING 479 mpv_args = []
467 last_episode = int(read_tmp("episode_list").split()[-1]) 480 watched_percentage = 0
468 if not rewatching: 481
469 update_anime_progress(access_token, int(media_id), int(watching_ep)) 482 if get_userconfig_value(user_config, 'save_mpv_speed') ==True:
470 watching_ep = int(watching_ep)+1 483 mpv_args.append(f'--speed={mpv_playback_speed}')
471 write_to_tmp("ep_no", str(watching_ep)) 484
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)) 485 # watching_ep = current_ep+1
473 anime_watch_history = get_all_anime(get_userconfig_value(user_config, 'history_file')) 486 if get_userconfig_value(user_config, 'next_episode_prompt') == True:
474 anime_history = find_anime(anime_watch_history, anilist_id=media_id, allanime_id=get_contents_of("id")) 487 to_continue_or_not_to_continue = input("Continue? (y/n)\n")
475 episode_completed = False 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 == "":
476 run_script("episode_url") 489 binge_watching = True
477 links = load_links(f"{current_dir}/scripts/tmp/links") 490 else:
478 mpv_args = [] 491 exit(0)
479 watched_percentage = 0 492 except Exception as e:
480 493 print(f"error:{e}\nMaybe try running again!")\ No newline at end of file
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
scripts/episode_url.sh +2 −1
@@ -24,7 +24,8 @@ get_links() {
24 *) [ -n "$episode_link" ] && printf "%s\n" "$episode_link" ;; 24 *) [ -n "$episode_link" ] && printf "%s\n" "$episode_link" ;;
25 esac 25 esac
26 # echo $episode_link >> links 26 # 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
28} 29}
29 30
30# # innitialises provider_name and provider_id. First argument is the provider name, 2nd is the regex that matches that provider's link 31# # 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=[]):
9 args_str = ' '.join(args) 9 args_str = ' '.join(args)
10 10
11 # Build the complete command string 11 # 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}"
13 13
14 subprocess.Popen(command, shell=True) 14 subprocess.Popen(command, shell=True)
15 # os.system() 15 # os.system()