Replaced os.system calls to subprocces ones
This commit is contained in:
parent
346bf9190f
commit
d449a59b08
51
adl.py
51
adl.py
@ -43,7 +43,7 @@ if args["download"]:
|
|||||||
msg = "downloading"
|
msg = "downloading"
|
||||||
|
|
||||||
if args["version"]:
|
if args["version"]:
|
||||||
print("Py-adl version 0.1")
|
print("Py-adl version 0.1.1")
|
||||||
exit_adl()
|
exit_adl()
|
||||||
|
|
||||||
# colored print
|
# colored print
|
||||||
@ -61,14 +61,14 @@ def color_prommpt(text):
|
|||||||
# retrieve new list
|
# retrieve new list
|
||||||
def retrieve_list():
|
def retrieve_list():
|
||||||
color_print ("Running trackma retrieve for account " + account + "...")
|
color_print ("Running trackma retrieve for account " + account + "...")
|
||||||
os.system("trackma -a " + account + " retrieve")
|
subprocess.call("trackma -a " + account + " retrieve")
|
||||||
os.system("cls")
|
subprocess.call("cls", shell=True)
|
||||||
|
|
||||||
# retrieve updated list
|
# retrieve updated list
|
||||||
def retrieve_list_update(account):
|
def retrieve_list_update(account):
|
||||||
color_print("Running trackma retrieve for account " + account + " to get the updated list...")
|
color_print("Running trackma retrieve for account " + account + " to get the updated list...")
|
||||||
os.system("trackma -a " + account + " retrieve")
|
subprocess.call("trackma -a " + account + " retrieve")
|
||||||
os.system("cls")
|
subprocess.call("cls", shell=True)
|
||||||
|
|
||||||
# load list
|
# load list
|
||||||
def load_list():
|
def load_list():
|
||||||
@ -87,7 +87,7 @@ def list2file(list, file):
|
|||||||
# exit prompt
|
# exit prompt
|
||||||
def exit_ask():
|
def exit_ask():
|
||||||
while True:
|
while True:
|
||||||
os.system("cls")
|
subprocess.call("cls", shell=True)
|
||||||
choice = color_prommpt("Want to watch another anime? [Y/n]: ")
|
choice = color_prommpt("Want to watch another anime? [Y/n]: ")
|
||||||
if choice == "":
|
if choice == "":
|
||||||
exit_adl()
|
exit_adl()
|
||||||
@ -132,7 +132,7 @@ def next_episode(title,episode):
|
|||||||
while watch_next:
|
while watch_next:
|
||||||
episode = episode + 1
|
episode = episode + 1
|
||||||
watch_prompt(title, str(episode))
|
watch_prompt(title, str(episode))
|
||||||
os.system('anime dl "' + title + '" --episodes ' + str(episode) + ' --play ' + player)
|
subprocess.call('anime dl "' + title + '" --episodes ' + str(episode) + ' --play ' + player)
|
||||||
while True:
|
while True:
|
||||||
color_print("Current watched episode: " + str(episode))
|
color_print("Current watched episode: " + str(episode))
|
||||||
yn = color_prommpt("Wanna watch next episode? [Y/n]: ")
|
yn = color_prommpt("Wanna watch next episode? [Y/n]: ")
|
||||||
@ -144,23 +144,23 @@ def next_episode(title,episode):
|
|||||||
else:
|
else:
|
||||||
episode = episode + 1
|
episode = episode + 1
|
||||||
watch_prompt(title, str(episode))
|
watch_prompt(title, str(episode))
|
||||||
os.system('anime dl "' + title + '" --episodes ' + str(episode))
|
subprocess.call('anime dl "' + title + '" --episodes ' + str(episode))
|
||||||
|
|
||||||
# all from last watched
|
# all from last watched
|
||||||
def all_from_last(title,episode):
|
def all_from_last(title,episode):
|
||||||
watch_prompt(title, str(episode) + " all left episodes")
|
watch_prompt(title, str(episode) + " all left episodes")
|
||||||
if not download:
|
if not download:
|
||||||
os.system('anime dl "' + title + '" --episodes ' + str(episode + 1) + ': --play' + player)
|
subprocess.call('anime dl "' + title + '" --episodes ' + str(episode + 1) + ': --play' + player)
|
||||||
else:
|
else:
|
||||||
os.system('anime dl "' + title + '" --episodes ' + str(episode + 1) + ':')
|
subprocess.call('anime dl "' + title + '" --episodes ' + str(episode + 1) + ':')
|
||||||
|
|
||||||
# all episode
|
# all episode
|
||||||
def all_episodes(title):
|
def all_episodes(title):
|
||||||
watch_prompt(title, "all")
|
watch_prompt(title, "all")
|
||||||
if not download:
|
if not download:
|
||||||
os.system('anime dl "' + title + '" --episodes 1: --play ' + player)
|
subprocess.call('anime dl "' + title + '" --episodes 1: --play ' + player)
|
||||||
else:
|
else:
|
||||||
os.system('anime dl "' + title + '" --episodes 1:')
|
subprocess.call('anime dl "' + title + '" --episodes 1:')
|
||||||
|
|
||||||
# watch from custom range
|
# watch from custom range
|
||||||
def custom_episode_range(title):
|
def custom_episode_range(title):
|
||||||
@ -168,42 +168,42 @@ def custom_episode_range(title):
|
|||||||
end = color_prommpt("End of interval?: ")
|
end = color_prommpt("End of interval?: ")
|
||||||
watch_prompt(title, begginig + " to " + end)
|
watch_prompt(title, begginig + " to " + end)
|
||||||
if not download:
|
if not download:
|
||||||
os.system('anime dl "' + title + '" --episodes ' + begginig + ':' + end +' --play ' + player)
|
subprocess.call('anime dl "' + title + '" --episodes ' + begginig + ':' + end +' --play ' + player)
|
||||||
else:
|
else:
|
||||||
os.system('anime dl "' + title + '" --episodes ' + begginig + ':' + end)
|
subprocess.call('anime dl "' + title + '" --episodes ' + begginig + ':' + end)
|
||||||
|
|
||||||
# add to last watched m
|
# add to last watched m
|
||||||
def next_plus_n(title, episode, action):
|
def next_plus_n(title, episode, action):
|
||||||
watch_prompt(title, str(episode + int(action)))
|
watch_prompt(title, str(episode + int(action)))
|
||||||
if not download:
|
if not download:
|
||||||
os.system('anime dl "' + title + '" --episodes ' + str(episode + int(action)) + ' --play ' + player)
|
subprocess.call('anime dl "' + title + '" --episodes ' + str(episode + int(action)) + ' --play ' + player)
|
||||||
else:
|
else:
|
||||||
os.system('anime dl "' + title + '" --episodes ' + str(episode + int(action)))
|
subprocess.call('anime dl "' + title + '" --episodes ' + str(episode + int(action)))
|
||||||
|
|
||||||
# rewatch current episode
|
# rewatch current episode
|
||||||
def rewatch_episode(title, episode):
|
def rewatch_episode(title, episode):
|
||||||
watch_prompt(title, str(episode))
|
watch_prompt(title, str(episode))
|
||||||
if not download:
|
if not download:
|
||||||
os.system('anime dl "' + title + '" --episodes ' + str(episode) + ' --play ' + player)
|
subprocess.call('anime dl "' + title + '" --episodes ' + str(episode) + ' --play ' + player)
|
||||||
else:
|
else:
|
||||||
os.system('anime dl "' + title + '" --episodes ' + str(episode))
|
subprocess.call('anime dl "' + title + '" --episodes ' + str(episode))
|
||||||
|
|
||||||
# watch custom episode
|
# watch custom episode
|
||||||
def custom_episode(title):
|
def custom_episode(title):
|
||||||
episode = color_prommpt("Enter custom episode: ")
|
episode = color_prommpt("Enter custom episode: ")
|
||||||
watch_prompt(title, episode)
|
watch_prompt(title, episode)
|
||||||
if not download:
|
if not download:
|
||||||
os.system('anime dl "' + title + '" --episodes ' + episode + ' --play ' + player)
|
subprocess.call('anime dl "' + title + '" --episodes ' + episode + ' --play ' + player)
|
||||||
else:
|
else:
|
||||||
os.system('anime dl "' + title + '" --episodes ' + episode)
|
subprocess.call('anime dl "' + title + '" --episodes ' + episode)
|
||||||
|
|
||||||
# update title
|
# update title
|
||||||
def update_title(title, episode):
|
def update_title(title, episode):
|
||||||
color_print("Current episode for " + title + " is " + str(episode))
|
color_print("Current episode for " + title + " is " + str(episode))
|
||||||
custom = color_prommpt("Enter updated episode number: ")
|
custom = color_prommpt("Enter updated episode number: ")
|
||||||
if custom != "":
|
if custom != "":
|
||||||
os.system('trackma -a ' + account + ' update "' + title + '" ' + custom)
|
subprocess.call('trackma -a ' + account + ' update "' + title + '" ' + custom)
|
||||||
os.system('trackma -a' + account + ' send')
|
subprocess.call('trackma -a' + account + ' send')
|
||||||
retrieve_list_update(account)
|
retrieve_list_update(account)
|
||||||
else:
|
else:
|
||||||
color_print("Skipping updating...")
|
color_print("Skipping updating...")
|
||||||
@ -213,8 +213,8 @@ def update_score(title, score):
|
|||||||
color_print("Current score for " + title + " is " + score)
|
color_print("Current score for " + title + " is " + score)
|
||||||
custom = color_prommpt("Enter updated score: ")
|
custom = color_prommpt("Enter updated score: ")
|
||||||
if custom != "":
|
if custom != "":
|
||||||
os.system('trackma -a ' + account + ' score "' + title + '" ' + custom)
|
subprocess.call('trackma -a ' + account + ' score "' + title + '" ' + custom)
|
||||||
os.system('trackma -a' + account + ' send')
|
subprocess.call('trackma -a' + account + ' send')
|
||||||
retrieve_list_update(account)
|
retrieve_list_update(account)
|
||||||
else:
|
else:
|
||||||
color_print("Skipping updating...")
|
color_print("Skipping updating...")
|
||||||
@ -259,7 +259,7 @@ def wanna_update_title_after_watch(title, episode, score):
|
|||||||
|
|
||||||
# choose what to do with episode
|
# choose what to do with episode
|
||||||
def choose_episode():
|
def choose_episode():
|
||||||
os.system("cls")
|
subprocess.call("cls", shell=True)
|
||||||
color_print("Enter lowercase or uppercase to issue command:")
|
color_print("Enter lowercase or uppercase to issue command:")
|
||||||
color_print(" N - Next episode (default, press <ENTER>)")
|
color_print(" N - Next episode (default, press <ENTER>)")
|
||||||
color_print(" L - from current to Last known:")
|
color_print(" L - from current to Last known:")
|
||||||
@ -289,6 +289,7 @@ while True:
|
|||||||
# reload file (I Guess ??)
|
# reload file (I Guess ??)
|
||||||
fzf_file.seek(0)
|
fzf_file.seek(0)
|
||||||
|
|
||||||
|
# get choice from fzf
|
||||||
choice = subprocess.getoutput(print_fzf_path + ' | fzf --ansi --reverse --prompt "Choose anime to watch: "')
|
choice = subprocess.getoutput(print_fzf_path + ' | fzf --ansi --reverse --prompt "Choose anime to watch: "')
|
||||||
|
|
||||||
if choice:
|
if choice:
|
||||||
|
Loading…
Reference in New Issue
Block a user