Skip to content

Commit

Permalink
Black formatting the repo
Browse files Browse the repository at this point in the history
Formatting all the files to black (seems it hasn't been done in a while) cuz that is how it's supposed be, apparently.
  • Loading branch information
Arima57 committed Dec 24, 2023
1 parent a9a57fa commit 9eba8bf
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 36 deletions.
6 changes: 5 additions & 1 deletion anipy_cli/cli/menus/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ def menu_options(self) -> List[MenuOption]:
def print_header(self):
cprint(
colors.GREEN,
"Playing: ", colors.BLUE, self.entry.show_name, colors.GREEN, f" | {self.entry.quality} | ",
"Playing: ",
colors.BLUE,
self.entry.show_name,
colors.GREEN,
f" | {self.entry.quality} | ",
colors.RED,
f"{self.entry.ep}/{self.entry.latest_ep}",
)
Expand Down
3 changes: 1 addition & 2 deletions anipy_cli/cli/menus/seasonal_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from anipy_cli.arg_parser import CliArgs
from anipy_cli.colors import colors, cprint, cinput
from anipy_cli.misc import Entry, print_names, error , clear_console
from anipy_cli.misc import Entry, print_names, error, clear_console
from anipy_cli.player import get_player
from anipy_cli.url_handler import videourl, epHandler
from anipy_cli.query import query
Expand Down Expand Up @@ -80,7 +80,6 @@ def add_anime(self):
else:
show_entry = query_class.pick_show()


picked_ep = epHandler(show_entry).pick_ep_seasonal().ep
self.add_show(show_entry.show_name, show_entry.category_url, picked_ep)
self.print_options()
Expand Down
5 changes: 3 additions & 2 deletions anipy_cli/cli/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ def get_season_searches(gogo=True):
else:
cprint(colors.YELLOW, "Please enter a valid season name.\n")

with yaspin(text="Fetching seasonals...", spinner=Spinners.dots, color="cyan") as spinner:
with yaspin(
text="Fetching seasonals...", spinner=Spinners.dots, color="cyan"
) as spinner:
if gogo:
anime_in_season = search_in_season_on_gogo(season_year, season_name)

Expand All @@ -86,7 +88,6 @@ def get_season_searches(gogo=True):

spinner.ok("✔")


cprint("Anime found in {} {} Season: ".format(season_year, season_name))
cprint(
colors.CYAN,
Expand Down
14 changes: 11 additions & 3 deletions anipy_cli/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ class download:
A entry with all fields is required.
"""

def __init__(self, entry, quality, ffmpeg=False, dl_path: Path = None, file_name_format="") -> None:
def __init__(
self, entry, quality, ffmpeg=False, dl_path: Path = None, file_name_format=""
) -> None:
try:
self.quality = int(quality)
except ValueError:
Expand Down Expand Up @@ -426,7 +428,11 @@ def _get_fname(self) -> str:

show_name = self._get_valid_pathname(self.entry.show_name)

file_format = self.file_name_format if self.file_name_format else Config().download_name_format
file_format = (
self.file_name_format
if self.file_name_format
else Config().download_name_format
)

return file_format.format(
show_name=show_name,
Expand All @@ -441,7 +447,9 @@ def _get_valid_pathname(name: str):
if sys.platform == "win32":
name = "".join(["" if x in WIN_INVALID_CHARS else x for x in name])

name = "".join([i for i in name if i.isascii()]) # Verify all chars are ascii (eject if not)
name = "".join(
[i for i in name if i.isascii()]
) # Verify all chars are ascii (eject if not)
name = "-".join(name.split()) # Clean all white spaces, including tabs and such

return name
Expand Down
22 changes: 14 additions & 8 deletions anipy_cli/mal.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,9 @@ def __init__(self, user=None, password=None):
def auto_map_all_without_map(self):
with Pool(processes=None) as pool:
mal_entries = self.local_mal_list_json["data"]
# apply the search function to each search value in parallel
# apply the search function to each search value in parallel
results = pool.map(self.auto_map_gogo_mal, mal_entries, True)


new_mal_entries = list()
for result in results:
if type(result) is dict:
Expand Down Expand Up @@ -562,7 +561,9 @@ def auto_map_gogo_mal(self, mal_entry, mp=False):
if "gogo_map" in mal_entry and len(mal_entry["gogo_map"]) > 0:
return {"failed_to_map": False, "mal_entry": mal_entry}
failed_to_map = True
cprint(colors.GREEN, "Auto mapping: ", colors.BLUE, mal_entry["node"]["title"])
cprint(
colors.GREEN, "Auto mapping: ", colors.BLUE, mal_entry["node"]["title"]
)

search_values = [
mal_entry["node"]["title"],
Expand All @@ -582,7 +583,10 @@ def auto_map_gogo_mal(self, mal_entry, mp=False):
mal_entry["gogo_map"] = []
for i, anime in enumerate(found["search"][1]):
if any(
anime.lower().rstrip("(dub)").rstrip("(japanese dub)").strip(" ")
anime.lower()
.rstrip("(dub)")
.rstrip("(japanese dub)")
.strip(" ")
in show.lower()
for show in [search_values[0], search_values[1]]
):
Expand All @@ -592,13 +596,15 @@ def auto_map_gogo_mal(self, mal_entry, mp=False):
self.update_gogo_map_list(gogo_map, current_map)
failed_to_map = False
if not mp:
self.shows_failed_automap.discard(mal_entry["node"]["title"])
self.shows_failed_automap.discard(
mal_entry["node"]["title"]
)
self.update_anime_list(
mal_entry["node"]["id"],
{
"num_watched_episodes": mal_entry["node"]["my_list_status"][
"num_episodes_watched"
],
"num_watched_episodes": mal_entry["node"][
"my_list_status"
]["num_episodes_watched"],
"tags": "anipy-cli",
},
)
Expand Down
14 changes: 5 additions & 9 deletions anipy_cli/player/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,18 @@ def get_player(rpc_client=None, player_override="") -> PlayerBaseType:

if not player_override:
player = cfg.player_path

player = Path(player)

if player.name == "mpv" and cfg.reuse_mpv_window:
from anipy_cli.player.players.mpv_contrl import MpvControllable

return MpvControllable(rpc_client=rpc_client)

player_dict = {
"mpv": Mpv,
"mpvnet": Mpv,
"vlc": Vlc,
"syncplay": Syncplay
}
player_dict = {"mpv": Mpv, "mpvnet": Mpv, "vlc": Vlc, "syncplay": Syncplay}

player_class = player_dict.get(player.name, None)

if player_class:
return player_class(str(player), rpc_client=rpc_client)
else:
Expand Down
6 changes: 3 additions & 3 deletions anipy_cli/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class query:

def __init__(self, search_param, entry) -> None:
with yaspin() as spinner:
spinner.text=f"Searching for {colors.BLUE}{search_param}{colors.END}"
spinner.spinner=Spinners.dots
spinner.color="cyan"
spinner.text = f"Searching for {colors.BLUE}{search_param}{colors.END}"
spinner.spinner = Spinners.dots
spinner.color = "cyan"
self.entry = entry
self.search_url = base_url + f"/search.html?keyword={search_param}"
r = requests.get(self.search_url)
Expand Down
5 changes: 2 additions & 3 deletions anipy_cli/seasonal.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,13 @@ def latest_eps(self):
for i, e, n in zip(categ_urls, user_eps, names):
self.entry.category_url = i
ep_class = epHandler(self.entry)

eps_range = ep_class._load_eps_list()
for j in eps_range:
if parsenum(j["ep"]) == e:
eps_range = eps_range[eps_range.index(j) + 1:]
eps_range = eps_range[eps_range.index(j) + 1 :]
break


ep_urls = []
for j in eps_range:
self.entry.ep = parsenum(j["ep"])
Expand Down
27 changes: 22 additions & 5 deletions anipy_cli/url_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,24 @@ def get_first(self):

def _do_prompt(self, prompt="Select Episode"):
clear_console()
cprint(colors.BLUE, colors.BOLD, colors.UNDERLINE, (self.entry.show_name), colors.END, colors.RESET)
cprint(
colors.BLUE,
colors.BOLD,
colors.UNDERLINE,
(self.entry.show_name),
colors.END,
colors.RESET,
)
ep_range = f" [{self.get_first()}-{self.get_latest()}]"

specials = self.get_special_list()
if specials:
ep_range += " Special Eps: "
ep_range += ", ".join([x["ep"] for x in specials])

return cinput(prompt, colors.GREEN, ep_range, colors.END, "\n>> ", input_color=colors.CYAN)
return cinput(
prompt, colors.GREEN, ep_range, colors.END, "\n>> ", input_color=colors.CYAN
)

def _validate_ep(self, ep: str):
"""
Expand All @@ -151,7 +160,9 @@ def pick_ep(self):
Cli function to pick an episode from 1 to
the latest available.
"""
with yaspin(text=f"Fetching episode list for {colors.BLUE}{self.entry.show_name}...") as spinner:
with yaspin(
text=f"Fetching episode list for {colors.BLUE}{self.entry.show_name}..."
) as spinner:
spinner.color = "cyan"
spinner.spinner = Spinners.dots
self.get_latest()
Expand All @@ -178,7 +189,9 @@ def pick_ep_seasonal(self):
the latest available.
"""

with yaspin(text=f"Fetching episode list for {colors.BLUE}{self.entry.show_name}...") as spinner:
with yaspin(
text=f"Fetching episode list for {colors.BLUE}{self.entry.show_name}..."
) as spinner:
spinner.color = "cyan"
spinner.spinner = Spinners.dots
self.get_latest()
Expand Down Expand Up @@ -309,7 +322,11 @@ def embed_url(self):
soup = BeautifulSoup(r.content, "html.parser")
link = soup.find("a", {"class": "active", "rel": "1"})
loc_err(link, self.entry.ep_url, "embed-url")
self.entry.embed_url = f'https:{link["data-video"]}' if not link["data-video"].startswith("https:") else link["data-video"]
self.entry.embed_url = (
f'https:{link["data-video"]}'
if not link["data-video"].startswith("https:")
else link["data-video"]
)

@functools.lru_cache()
def get_enc_keys(self):
Expand Down

0 comments on commit 9eba8bf

Please sign in to comment.