Compare commits

..

11 Commits

Author SHA1 Message Date
Benex254
ab782acf2f chore: bump version 2024-08-18 15:47:44 +03:00
Benex254
45836d1ebc fix: handle no matches for search results 2024-08-18 15:47:29 +03:00
Benex254
dff059d8eb fix: workaround over typing issue 2024-08-18 15:32:13 +03:00
Benex254
4010cfc9c8 fix: correct update command 2024-08-18 15:29:54 +03:00
Benex254
6329730820 chore: bump version 2024-08-18 15:23:39 +03:00
Benex254
006592ae7d test: add grab command tests 2024-08-18 15:23:27 +03:00
Benex254
831dcf4e88 feat: fix python 3.10 incompatibility issue 2024-08-18 15:20:58 +03:00
Benex254
0d2cf7ed66 chore: bump version 2024-08-18 15:18:28 +03:00
Benex254
aa6dc2b98e docs: update readme 2024-08-18 15:18:12 +03:00
Benex254
2e5cde3365 feat(grab command): include more options for finer control 2024-08-18 15:09:56 +03:00
Benex254
d75a03e594 feat(animepahe): fix episode title 2024-08-18 15:09:24 +03:00
9 changed files with 98 additions and 25 deletions

View File

@@ -350,13 +350,18 @@ fastanime download -t <anime-title> -t <anime-title> -r '-5'
# Download specific episode range
# be sure to observe the range Syntax
fastanime download <anime-title> -r '<episodes-start>:<episodes-end>:<step>'
fastanime download -t <anime-title> -r '<episodes-start>:<episodes-end>:<step>'
fastanime download <anime-title> -r '<episodes-start>:<episodes-end>'
fastanime download -t <anime-title> -r '<episodes-start>:<episodes-end>'
fastanime download <anime-title> -r '<episodes-start>:'
fastanime download -t <anime-title> -r '<episodes-start>:'
fastanime download -t <anime-title> -r ':<episodes-end>'
# download specific episode
# remember python indexing starts at 0
fastanime download -t <anime-title> -r '<episode-1>:<episode>'
fastanime download <anime-title> -r ':<episodes-end>'
```
#### search subcommand
@@ -404,7 +409,8 @@ Uses a list slicing syntax similar to that of python as the value of the `-r` op
**Syntax:**
```bash
# print all available episodes
# --- print anime info + episode streams ---
# multiple titles can be specified with the -t option
fastanime grab -t <anime-title> -t <anime-title>
@@ -425,6 +431,18 @@ fastanime grab -t <anime-title> -r '<start>:<stop>:<step>'
fastanime grab -t <anime-title> -r '<start>:'
fastanime grab -t <anime-title> -r ':<end>'
# --- grab options ---
# print search results only
fastanime grab -t <anime-title> -r <range> --search-results-only
# print anime info only
fastanime grab -t <anime-title> -r <range> --anime-info-only
# print episode streams only
fastanime grab -t <anime-title> -r <range> --episode-streams-only
```
#### downloads subcommand

View File

@@ -6,7 +6,7 @@ if sys.version_info < (3, 10):
) # noqa: F541
__version__ = "v2.2.3"
__version__ = "v2.2.6"
APP_NAME = "FastAnime"
AUTHOR = "Benex254"

View File

@@ -39,11 +39,11 @@ def check_for_updates():
and remote_tag[1] == local_tag[1]
)
):
is_update = True
is_latest = False
else:
is_update = False
is_latest = True
return (is_update, release_json)
return (is_latest, release_json)
else:
print(request.text)
return (False, {})

View File

@@ -83,6 +83,9 @@ def download(
)
return
search_results = search_results["results"]
if not search_results:
print("Nothing muches your search term")
exit_app(1)
search_results_ = {
search_result["title"]: search_result for search_result in search_results
}

View File

@@ -26,11 +26,29 @@ if TYPE_CHECKING:
"-r",
help="A range of episodes to download (start-end)",
)
@click.option(
"--search-results-only",
"-s",
help="print only the search results to stdout",
is_flag=True,
)
@click.option(
"--anime-info-only", "-i", help="print only selected anime title info", is_flag=True
)
@click.option(
"--episode-streams-only",
"-e",
help="print only selected anime episodes streams of given range",
is_flag=True,
)
@click.pass_obj
def grab(
config: "Config",
anime_titles: tuple,
episode_range,
search_results_only,
anime_info_only,
episode_streams_only,
):
import json
from logging import getLogger
@@ -52,7 +70,15 @@ def grab(
)
if not search_results:
exit(1)
if search_results_only:
# grab only search results skipping all lines after this
grabbed_animes.append(search_results)
continue
search_results = search_results["results"]
if not search_results:
logger.error("no results for your search")
exit(1)
search_results_ = {
search_result["title"]: search_result for search_result in search_results
}
@@ -68,6 +94,11 @@ def grab(
episodes = sorted(
anime["availableEpisodesDetail"][config.translation_type], key=float
)
if anime_info_only:
# grab only the anime data skipping all lines after this
grabbed_animes.append(anime)
continue
# where the magic happens
if episode_range:
if ":" in episode_range:
@@ -94,10 +125,14 @@ def grab(
else:
episodes_range = sorted(episodes, key=float)
grabbed_anime = dict(anime)
grabbed_anime["requested_episodes"] = episodes_range
grabbed_anime["translation_type"] = config.translation_type
grabbed_anime["episodes_streams"] = {}
if not episode_streams_only:
grabbed_anime = dict(anime)
grabbed_anime["requested_episodes"] = episodes_range
grabbed_anime["translation_type"] = config.translation_type
grabbed_anime["episodes_streams"] = {}
else:
grabbed_anime = {}
# lets download em
for episode in episodes_range:
try:
@@ -108,14 +143,23 @@ def grab(
)
if not streams:
continue
grabbed_anime["episodes_streams"][episode] = {
server["server"]: server for server in streams
}
episode_streams = {server["server"]: server for server in streams}
if episode_streams_only:
grabbed_anime[episode] = episode_streams
else:
grabbed_anime["episodes_streams"][ # pyright:ignore
episode
] = episode_streams
except Exception as e:
logger.error(e)
# grab the full data for single title and appen to final result or episode streams
grabbed_animes.append(grabbed_anime)
if len(grabbed_animes) == 1:
print(json.dumps(grabbed_animes[0]))
else:
print(json.dumps(grabbed_animes))
# print out the final result either {} or [] depending if more than one title os requested
if len(grabbed_animes) == 1:
print(json.dumps(grabbed_animes[0]))
else:
print(json.dumps(grabbed_animes))

View File

@@ -24,8 +24,8 @@ def update(
console.print(body)
if check:
is_update, github_release_data = check_for_updates()
if is_update:
is_latest, github_release_data = check_for_updates()
if not is_latest:
print(
f"You are running an older version ({__version__}) of fastanime please update to get the latest features"
)
@@ -36,3 +36,7 @@ def update(
else:
success, github_release_data = update_app()
_print_release(github_release_data)
if success:
print("Successfully updated")
else:
print("failed to update")

View File

@@ -183,8 +183,7 @@ class AnimePaheApi(AnimeProvider):
# get the episode title
episode_title = (
episode["title"] + f"; {episode['episode']}"
or f"{anime['title']}; Episode {episode['episode']}"
f"{episode['title'] or anime['title']}; Episode {episode['episode']}"
)
# get all links
streams = {

View File

@@ -1,6 +1,6 @@
[tool.poetry]
name = "fastanime"
version = "2.2.3"
version = "2.2.6"
description = "A browser anime site experience from the terminal"
authors = ["Benextempest <benextempest@gmail.com>"]
license = "UNLICENSE"

View File

@@ -60,6 +60,11 @@ def test_update_help(runner: CliRunner):
assert result.exit_code == 0
def test_grab_help(runner: CliRunner):
result = runner.invoke(run_cli, ["grab", "--help"])
assert result.exit_code == 0
def test_anilist_help(runner: CliRunner):
result = runner.invoke(run_cli, ["anilist", "--help"])
assert result.exit_code == 0