Added ability to watch all remaining episode of an anime
This commit is contained in:
parent
13a331f640
commit
422a5e2de4
49
adl.py
49
adl.py
@ -1,37 +1,45 @@
|
|||||||
import os, subprocess, sys
|
import os, subprocess, sys
|
||||||
from iterfzf import iterfzf
|
from iterfzf import iterfzf
|
||||||
from time import sleep
|
from time import sleep
|
||||||
account = "0"
|
|
||||||
episode = ""
|
|
||||||
retrieve = True
|
|
||||||
player = "mpv"
|
|
||||||
|
|
||||||
|
# global variables
|
||||||
|
account = "0" # choose an account
|
||||||
|
episode = "" # specific episode
|
||||||
|
retrieve = True # retrieve new list
|
||||||
|
player = "mpv" # specific player
|
||||||
|
|
||||||
|
# colored print
|
||||||
def color_print(text):
|
def color_print(text):
|
||||||
print("\033[0;36m" + text + " \033[0m")
|
print("\033[0;36m" + text + " \033[0m")
|
||||||
|
|
||||||
|
# colored watch primpt
|
||||||
|
def watch_primpt(title, episode):
|
||||||
|
print("Now watching \033[0;34m" + title + "\033[0m, episode \033[0;34m" + str(episode) + " \033[0m")
|
||||||
|
|
||||||
|
# colored input
|
||||||
def color_prommpt(text):
|
def color_prommpt(text):
|
||||||
return input("\033[0;34m" + text + "\033[0m")
|
return input("\033[0;34m" + text + "\033[0m")
|
||||||
|
|
||||||
def print_list(alist):
|
# iter the list
|
||||||
for anime in alist:
|
|
||||||
print(alist[alist.index(anime)])
|
|
||||||
|
|
||||||
def iter_list(alist):
|
def iter_list(alist):
|
||||||
for anime in alist:
|
for anime in alist:
|
||||||
yield anime.strip()
|
yield anime.strip()
|
||||||
sleep(0.01)
|
sleep(0.01)
|
||||||
|
|
||||||
|
# retrieve new list
|
||||||
def retrieve_list(account):
|
def retrieve_list(account):
|
||||||
color_print ("Running trackma retrieve for account " + account + "...")
|
color_print ("Running trackma retrieve for account " + account + "...")
|
||||||
os.system("trackma -a " + account + " retrieve")
|
os.system("trackma -a " + account + " retrieve")
|
||||||
os.system("cls")
|
os.system("cls")
|
||||||
|
|
||||||
|
# load list
|
||||||
def load_list(account):
|
def load_list(account):
|
||||||
alist = subprocess.getoutput("trackma -a " + account + " list").splitlines()
|
alist = subprocess.getoutput("trackma -a " + account + " list").splitlines()
|
||||||
alist.pop(0)
|
alist.pop(0)
|
||||||
alist.pop()
|
alist.pop()
|
||||||
return alist
|
return alist
|
||||||
|
|
||||||
|
# exit prompt
|
||||||
def exit_ask():
|
def exit_ask():
|
||||||
while True:
|
while True:
|
||||||
os.system("cls")
|
os.system("cls")
|
||||||
@ -42,26 +50,28 @@ def exit_ask():
|
|||||||
sys.exit()
|
sys.exit()
|
||||||
elif choice == "Y" or choice == "y":
|
elif choice == "Y" or choice == "y":
|
||||||
return
|
return
|
||||||
|
|
||||||
def get_title(choice):
|
def get_title(full_choice):
|
||||||
full_choice = "".join(choice)
|
|
||||||
full_choice = full_choice[9:55]
|
full_choice = full_choice[9:55]
|
||||||
full_choice = full_choice.rstrip(".")
|
full_choice = full_choice.rstrip(".")
|
||||||
return full_choice
|
return full_choice
|
||||||
|
|
||||||
def get_episode(choice):
|
def get_episode(full_choice):
|
||||||
full_choice = "".join(choice)
|
|
||||||
full_choice = full_choice[58:60]
|
full_choice = full_choice[58:60]
|
||||||
return int(full_choice)
|
return int(full_choice)
|
||||||
|
|
||||||
def get_all_episodes(choice):
|
def get_all_episodes(full_choice):
|
||||||
full_choice = "".join(choice)
|
|
||||||
full_choice = full_choice[63:65]
|
full_choice = full_choice[63:65]
|
||||||
return full_choice
|
return full_choice
|
||||||
|
|
||||||
def next_episode(title,episode,player):
|
def next_episode(title,episode,player):
|
||||||
|
watch_primpt(title, episode)
|
||||||
os.system('anime dl "' + title + '" --episodes ' + str(episode + 1) + ' --play ' + player)
|
os.system('anime dl "' + title + '" --episodes ' + str(episode + 1) + ' --play ' + player)
|
||||||
|
|
||||||
|
def all_from_last(title,episode, last_episode, player):
|
||||||
|
watch_primpt(title, episode)
|
||||||
|
os.system('anime dl "' + title + '" --episodes ' + str(episode + 1) + ':' + last_episode + ' --play ' + player)
|
||||||
|
|
||||||
def choose_episode():
|
def choose_episode():
|
||||||
os.system("cls")
|
os.system("cls")
|
||||||
color_print("Enter lowercase or uppercase to issue command:")
|
color_print("Enter lowercase or uppercase to issue command:")
|
||||||
@ -85,17 +95,20 @@ while True:
|
|||||||
choice = iterfzf(iter_list(alist))
|
choice = iterfzf(iter_list(alist))
|
||||||
|
|
||||||
if choice:
|
if choice:
|
||||||
title = get_title(choice)
|
full_choice = "".join(choice)
|
||||||
episode = get_episode(choice)
|
title = get_title(full_choice)
|
||||||
all_episodes = get_all_episodes(choice)
|
episode = get_episode(full_choice)
|
||||||
|
all_episodes = get_all_episodes(full_choice)
|
||||||
while True:
|
while True:
|
||||||
action = choose_episode()
|
action = choose_episode()
|
||||||
if action == "":
|
if action == "":
|
||||||
next_episode(title, episode, player)
|
next_episode(title, episode, player)
|
||||||
break
|
break
|
||||||
elif action == "n" or action == "N":
|
elif action == "n" or action == "N":
|
||||||
|
next_episode(title, episode, player)
|
||||||
break
|
break
|
||||||
elif action == "l" or action == "L":
|
elif action == "l" or action == "L":
|
||||||
|
all_from_last(title, episode,all_episodes, player)
|
||||||
break
|
break
|
||||||
elif action == "a" or action == "A":
|
elif action == "a" or action == "A":
|
||||||
break
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user