Added provider and to watch a certain show options

This commit is contained in:
CronyAkatsuki 2021-07-30 20:15:24 +02:00
parent d65f9184c9
commit a37e438210

241
adl.py
View File

@ -6,6 +6,10 @@ ap = argparse.ArgumentParser()
ap.add_argument("-p", "--player", required=False, ap.add_argument("-p", "--player", required=False,
help="Define player used for streaming. Ex: \033[0;36mpyadl -p mpv\033[0m") help="Define player used for streaming. Ex: \033[0;36mpyadl -p mpv\033[0m")
ap.add_argument("-i", "--provider", required=False,
help="Define provider used for streaming (check \033[0;36m$anime dl --help\033[0m for providers list)")
ap.add_argument("-s", "--show", required=False,
help='Watch custom show. Ep nr optional, careful with the quotes. Ex: \033[0;36m$adl -s "gegege 2018"\033[0m')
ap.add_argument("-a", "--account", required=False, ap.add_argument("-a", "--account", required=False,
help="By default trackma will use account 1. Use '-a 2' for example to change trackma account") help="By default trackma will use account 1. Use '-a 2' for example to change trackma account")
ap.add_argument("-d", "--download", required=False, type=bool, nargs='?', const=True, default=False, ap.add_argument("-d", "--download", required=False, type=bool, nargs='?', const=True, default=False,
@ -17,17 +21,31 @@ ap.add_argument("-r", "--retrieve", required=False, nargs='?', const=True,
args = vars(ap.parse_args()) args = vars(ap.parse_args())
# get account print(args)
if args['account']:
account = str(int(args["account"]) - 1) # take the account from input
else:
account = "0" # default account
# get player # get player
if args["player"]: if args["player"]:
player = str(args["player"]) # get player from user player = str(args["player"]) # get player from user
else: else:
player = "mpv" # default player player = "mpv" # default player
# get provider
if args['provider']:
provider = str(args["provider"])
else:
provider = ""
# get show
if args['show']:
show = str(args["show"])
else:
show = ""
# get account
if args['account']:
account = str(int(args["account"]) - 1) # take the account from input
else:
account = "0" # default account
# enable downloading # enable downloading
if args["download"]: if args["download"]:
@ -146,10 +164,15 @@ def get_score(choice):
# watch animes # watch animes
def watch(title, episode): def watch(title, episode):
cmd = 'anime dl "' + title + '" --episodes ' + episode
if not download: if not download:
subprocess.run('anime dl "' + title + '" --episodes ' + episode + ' --play ' + player) cmd += ' --play ' + player
else:
subprocess.run('anime dl "' + title + '" --episodes ' + episode) if not provider == "":
cmd += ' --provider ' + provider
subprocess.run(cmd)
# next episode # next episode
def next_episode(title,episode): def next_episode(title,episode):
@ -281,100 +304,134 @@ def choose_episode():
color_print(" S - Skip. Choose another show.") color_print(" S - Skip. Choose another show.")
return color_prommpt("Your choice? [N/l/a/i/0-9/r/c/u/s]: ") return color_prommpt("Your choice? [N/l/a/i/0-9/r/c/u/s]: ")
# main loop def choose_episode_specific_show():
while True: subprocess.call("cls", shell=True)
# retrieving the list on start color_print("Enter lowercase or uppercase to issue command:")
if retrieve: color_print(" A - All available, from episode 1")
retrieve_list() color_print(" I - custom Interval (range) of episodes")
retrieve = False color_print(" C - Custom episode")
color_print(" S - Skip. Exit adl.")
return color_prommpt("Your choice? [A/i/c/s]: ")
# get the list of anime if not show == "":
alist = load_list() while True:
# choose what to do with the choosen anime
# write list to file action = choose_episode_specific_show()
list2file(alist, fzf_file) if action == "a" or action == "A" or action == "":
all_episodes(show)
# reload file (I Guess ??) exit_adl()
fzf_file.seek(0) # custom range of episodes
elif action == "i" or action == "I":
# get choice from fzf custom_episode_range(show)
choice = subprocess.getoutput(print_fzf_path + ' | fzf --ansi --reverse --prompt "Choose anime to watch: "') if wanna_continu_watch():
continue
if choice: else:
# get the title exit_adl()
title = get_title(choice) # watch custom episode
# get current episode elif action == "c" or action == "C":
episode = get_episode(choice) custom_episode(show)
# get latest episode if wanna_continu_watch():
last_episode = get_all_episodes(choice) continue
# get current score else:
score = get_score(choice) exit_adl()
# skip the anime
elif action == "s" or action == "S":
exit_adl()
else:
# main loop
while True:
# retrieving the list on start
if retrieve:
retrieve_list()
retrieve = False
# the watch loop # get the list of anime
while True: alist = load_list()
# choose what to do with the choosen anime
action = choose_episode() # write list to file
# watch next episode list2file(alist, fzf_file)
if action == "n" or action == "N" or action == "":
next_episode(title, episode) # reload file (I Guess ??)
wanna_update_title_after_watch(title, episode, score) fzf_file.seek(0)
exit_ask()
break # get choice from fzf
# watch all left episodes choice = subprocess.getoutput(print_fzf_path + ' | fzf --ansi --reverse --prompt "Choose anime to watch: "')
elif action == "l" or action == "L":
all_from_last(title, episode) if choice:
wanna_update_title_after_watch(title, episode, score) # get the title
exit_ask() title = get_title(choice)
break # get current episode
# watch every episode available episode = get_episode(choice)
elif action == "a" or action == "A": # get latest episode
all_episodes(title) last_episode = get_all_episodes(choice)
wanna_update_title_after_watch(title, episode, score) # get current score
exit_ask() score = get_score(choice)
break
# custom range of episodes # the watch loop
elif action == "i" or action == "I": while True:
custom_episode_range(title) # choose what to do with the choosen anime
if wanna_continu_watch(): action = choose_episode()
continue # watch next episode
else: if action == "n" or action == "N" or action == "":
next_episode(title, episode)
wanna_update_title_after_watch(title, episode, score) wanna_update_title_after_watch(title, episode, score)
exit_ask() exit_ask()
break break
# something? # watch all left episodes
elif action == "1" or action == "2" or action == "3" or action == "4" or action == "5" or action == "6" or action == "7" or action == "8" or action == "9": elif action == "l" or action == "L":
next_plus_n(title, episode, action) all_from_last(title, episode)
if wanna_continu_watch():
continue
else:
wanna_update_title_after_watch(title, episode, score) wanna_update_title_after_watch(title, episode, score)
exit_ask() exit_ask()
break break
# rewatch current episode # watch every episode available
elif action == "r" or action == "R": elif action == "a" or action == "A":
rewatch_episode(title, episode) all_episodes(title)
if wanna_continu_watch():
continue
else:
wanna_update_title_after_watch(title, episode, score) wanna_update_title_after_watch(title, episode, score)
exit_ask() exit_ask()
break break
# watch custom episode # custom range of episodes
elif action == "c" or action == "C": elif action == "i" or action == "I":
custom_episode(title) custom_episode_range(title)
if wanna_continu_watch(): if wanna_continu_watch():
continue continue
else: else:
wanna_update_title_after_watch(title, episode, score) wanna_update_title_after_watch(title, episode, score)
exit_ask()
break
# something?
elif action == "1" or action == "2" or action == "3" or action == "4" or action == "5" or action == "6" or action == "7" or action == "8" or action == "9":
next_plus_n(title, episode, action)
if wanna_continu_watch():
continue
else:
wanna_update_title_after_watch(title, episode, score)
exit_ask()
break
# rewatch current episode
elif action == "r" or action == "R":
rewatch_episode(title, episode)
if wanna_continu_watch():
continue
else:
wanna_update_title_after_watch(title, episode, score)
exit_ask()
break
# watch custom episode
elif action == "c" or action == "C":
custom_episode(title)
if wanna_continu_watch():
continue
else:
wanna_update_title_after_watch(title, episode, score)
exit_ask()
break
# update anime meta
elif action == "u" or action == "U":
update_question(title, episode, score)
exit_ask() exit_ask()
break break
# update anime meta # skip the anime
elif action == "u" or action == "U": elif action == "s" or action == "S":
update_question(title, episode, score) break
exit_ask() else:
break exit_ask()
# skip the anime
elif action == "s" or action == "S":
break
else:
exit_ask()