Skip to content
This repository has been archived by the owner on Feb 25, 2023. It is now read-only.

Commit

Permalink
Added search & update
Browse files Browse the repository at this point in the history
  • Loading branch information
AyushSehrawat committed Mar 4, 2022
1 parent 3478f82 commit f4843bc
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
#### Todo

- [x] Register on pypi ( python main.py -> some_command )
- [ ] Fix `--` not in cli ( due to some issue not showing )
- [ ] Add more support and commands
- [x] Fix `--` not in cli ( due to some issue not showing )
- [x] Add more support and commands
- [ ] Simply code
- [x] Fix saving of file issue

Expand Down
2 changes: 1 addition & 1 deletion anilist_man/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.4.2'
__version__ = '0.4.3'
54 changes: 52 additions & 2 deletions anilist_man/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,10 @@
sys.exit()

if folder_check == True:
# Create new folder in location if it doesn't exist
if os.path.isdir(os.path.join(location, 'anilist_man')):
dat_dir = os.path.join(location, 'anilist_man')

else:
# Make a new folder in location
dat_dir = os.path.join(location, 'anilist_man')
try:
os.mkdir(dat_dir)
Expand Down Expand Up @@ -171,5 +169,57 @@ def update():
QueryFunctions.updateMangaStats(query2, headers, listEntryId, progress)
print(f"[+] Updated {manga['media']['title']['romaji']} to {progress}")

@app.command(short_help="Get search results from given number of chapters")
def search(chapters : int, update: Optional[bool] = typer.Option(None, "--y/")):
query1 = queryMangaCollection
subFunc.mangaList(query1, headers, uid)
query = queryMangaCollection
mangalist = QueryFunctions.getMangaStats(query, headers, uid)
mangalist = mangalist["data"]["MediaListCollection"]["lists"][0]["entries"]
print("\n [+] Results are - ")
for m in mangalist:
if m["progress"] in range(chapters-5, chapters+5):
index = len(mangalist) - mangalist.index(m)
romaji = m["media"]["title"]["romaji"]
english = m["media"]["title"]["english"]
if english == None:
print(f"[{index}] {romaji} | {m['progress']}")
else:
print(f"[{index}] {english} | {m['progress']}")

if update == None:
return
else:
try:
index = int(input("\n[+] Enter index of manga: "))
except ValueError or KeyboardInterrupt:
print("[-] Error")
sys.exit()

if index not in range(len(mangalist)):
print("[-] Index out of range")
manga = mangalist[len(mangalist) - index]
english = manga["media"]["title"]["english"]
romaji = manga["media"]["title"]["romaji"]
current_progress = manga["progress"]
print(f"[+] Updating {english} | ({romaji}) | {current_progress}")
listEntryId = manga["id"]

try:
progress = int(input("[+] Enter progress: "))
except ValueError or KeyboardInterrupt:
print("[-] Error")
sys.exit()

if progress == 0 or progress < 0:
print("[-] Progress cannot be 0 or less")
else:
query2 = queryUpdateManga
QueryFunctions.updateMangaStats(query2, headers, listEntryId, progress)
print(f"[+] Updated {manga['media']['title']['romaji']} to {progress}")




if __name__ == "__main__":
app()
4 changes: 2 additions & 2 deletions anilist_man/subFunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ def mangaList(query,headers,userid):
english = m["media"]["title"]["english"]
progress = m['progress']
if english == None:
print(f"{index} {romaji} - {progress}")
print(f"[+] {index} {romaji} - {progress}")
else:
print(f"{index} {english} - {progress}")
print(f"[+] {index} {english} - {progress}")
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
[tool.poetry]
name = "anilist-man"
version = "0.4.2"
version = "0.4.3"
description = "A command-line-tool for AniList"
authors = ["Mini"]
readme = "README.md"
repository = "https://github.com/minihut/anilist-man"
license = "LICENSE"
keywords = ['anilist', 'anilist-cli', 'anilist-man', 'manga']

packages = [
{ include = "anilist_man" },
Expand Down

0 comments on commit f4843bc

Please sign in to comment.