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

233
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,11 +21,7 @@ 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"]:
@ -29,6 +29,24 @@ if args["player"]:
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"]:
download = True # enable downloading download = True # enable downloading
@ -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
action = choose_episode_specific_show()
if action == "a" or action == "A" or action == "":
all_episodes(show)
exit_adl()
# custom range of episodes
elif action == "i" or action == "I":
custom_episode_range(show)
if wanna_continu_watch():
continue
else:
exit_adl()
# watch custom episode
elif action == "c" or action == "C":
custom_episode(show)
if wanna_continu_watch():
continue
else:
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
# write list to file # get the list of anime
list2file(alist, fzf_file) alist = load_list()
# reload file (I Guess ??) # write list to file
fzf_file.seek(0) list2file(alist, fzf_file)
# get choice from fzf # reload file (I Guess ??)
choice = subprocess.getoutput(print_fzf_path + ' | fzf --ansi --reverse --prompt "Choose anime to watch: "') fzf_file.seek(0)
if choice: # get choice from fzf
# get the title choice = subprocess.getoutput(print_fzf_path + ' | fzf --ansi --reverse --prompt "Choose anime to watch: "')
title = get_title(choice)
# get current episode
episode = get_episode(choice)
# get latest episode
last_episode = get_all_episodes(choice)
# get current score
score = get_score(choice)
# the watch loop if choice:
while True: # get the title
# choose what to do with the choosen anime title = get_title(choice)
action = choose_episode() # get current episode
# watch next episode episode = get_episode(choice)
if action == "n" or action == "N" or action == "": # get latest episode
next_episode(title, episode) last_episode = get_all_episodes(choice)
wanna_update_title_after_watch(title, episode, score) # get current score
exit_ask() score = get_score(choice)
break
# watch all left episodes # the watch loop
elif action == "l" or action == "L": while True:
all_from_last(title, episode) # choose what to do with the choosen anime
wanna_update_title_after_watch(title, episode, score) action = choose_episode()
exit_ask() # watch next episode
break if action == "n" or action == "N" or action == "":
# watch every episode available next_episode(title, episode)
elif action == "a" or action == "A":
all_episodes(title)
wanna_update_title_after_watch(title, episode, score)
exit_ask()
break
# custom range of episodes
elif action == "i" or action == "I":
custom_episode_range(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
# 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()