Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

list shows in json format #662

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

list shows in json format #662

wants to merge 10 commits into from

Conversation

RaitaroH
Copy link

@RaitaroH RaitaroH commented Jan 4, 2023

For issue #660
If you merge this PR, please squash and merge.

$ trackma help
...
     list|ls <>            Lists all shows available in the local list.
   list_json <>            Print list of shows in json format.
...

Example of trackma list_json (it defaults to watching list)

{"title": "Ars no Kyojuu", "current_episode": "2", "total_episodes": "12", "score": "0", "status": "Ongoing", "estimated_aired_episode": "2", "image": "https://s4.anilist.co/file/anilistcdn/media/anime/cover/medium/bx155089-I5zYFNvWua57.png"}
{"title": "Blue Lock", "current_episode": "14", "total_episodes": "24", "score": "5.5", "status": "Ongoing", "estimated_aired_episode": "14", "image": "https://s4.anilist.co/file/anilistcdn/media/anime/cover/medium/bx137822-4dVWMSHLpGf8.png"}
{"title": "Buddy Daddies", "current_episode": "2", "total_episodes": "13", "score": "0", "status": "Ongoing", "estimated_aired_episode": "2", "image": "https://s4.anilist.co/file/anilistcdn/media/anime/cover/medium/bx155907-gR7aRwVHwrjc.jpg"}
{"title": "Bungou Stray Dogs 4th Season", "current_episode": "2", "total_episodes": "13", "score": "0", "status": "Ongoing", "estimated_aired_episode": "2", "image": "https://s4.anilist.co/file/anilistcdn/media/anime/cover/medium/bx141249-8tjavEDHmLoT.jpg"}
{"title": "Flying Witch", "current_episode": "12", "total_episodes": "12", "score": "0", "status": "Finished", "image": "https://s4.anilist.co/file/anilistcdn/media/anime/cover/medium/bx21284-vQcCLIWt1o5O.png"}

Then it also can accept list status, trackma list_json paused:

{"title": "Casshern Sins", "current_episode": "15", "total_episodes": "24", "score": "6", "status": "Finished", "image": "https://s4.anilist.co/file/anilistcdn/media/anime/cover/medium/bx4981-V6MbMiJUqdvP.jpg"}
{"title": "Chi's Sweet Home: Atarashii Ouchi", "current_episode": "63", "total_episodes": "104", "score": "0", "status": "Finished", "image": "https://s4.anilist.co/file/anilistcdn/media/anime/cover/medium/bx6024-eYiQMRfPfWiF.jpg"}
{"title": "Joshiraku", "current_episode": "1", "total_episodes": "13", "score": "0", "status": "Finished", "image": "https://s4.anilist.co/file/anilistcdn/media/anime/cover/medium/bx12679-0zlvLP7KyxjH.png"}
{"title": "Karakai Jouzu no Takagi-san 2", "current_episode": "7", "total_episodes": "12", "score": "5", "status": "Finished", "image": "https://s4.anilist.co/file/anilistcdn/media/anime/cover/medium/bx107068-KJq0eFP0GTjL.jpg"}

I believe trackma -a should work. I tested with trackma -a 2 list_json and it asks me to select account first, before listing anything.

In bash scripts, jq works as expected. Here is a more complicated command:

trackma list_json | jq -jr '.title, "|", .current_episode, "|", .total_episodes, "|", .score, "|", .status, "|",.estimated_aired_episode, "\n"'
Ars no Kyojuu|2|12|0|Ongoing|2
Blue Lock|13|24|5.5|Ongoing|14
Buddy Daddies|2|13|0|Ongoing|2
Bungou Stray Dogs 4th Season|2|13|0|Ongoing|2
Flying Witch|9|12|0|Finished|null

@RaitaroH
Copy link
Author

RaitaroH commented Jan 4, 2023

Apologies if this isn't quite correct / good. I don't know python that much.

faster than info
trackma/ui/cli.py Outdated Show resolved Hide resolved
trackma/ui/cli.py Outdated Show resolved Hide resolved
trackma/ui/cli.py Outdated Show resolved Hide resolved
@RaitaroH RaitaroH requested a review from FichteFoll January 13, 2023 16:45
trackma/ui/cli.py Outdated Show resolved Hide resolved
@@ -362,6 +365,39 @@ def do_list(self, args):
# Show the list in memory
self._make_list(self.sortedlist)

def do_list_json(self, args):
"""
Print list of shows in json format.
Copy link
Collaborator

@FichteFoll FichteFoll Jan 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should mention that each entry is printed as a JSON line on its own (instead of an array). At least right now.

If we were to consider things like the scoring format, it may be useful to also report that in a meta object on its own, in which case the question follows whether the entries should instead be wrapped in an array to build an object as follows:

{ "account": "string", "api": "string", "has_progress": false, "scoring_format": "enum", "entries": [{}] }

I don't now how the scoring format options in anilist are implemented currently in various parts of the code or whether it makes more sense to instead specify a max_score to be of either 3, 5, or 10 (and use the latter for 10, 20, and 100-point schemas).

And that it is intended to be used by third-party tools.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my particular usage, each entry being on its own line is better. In case another shell program wants to use this, I think it might be better to leave it like this.

The scoring format is something I was simply wondering about, but I think is a good idea to investigate.

Copy link
Collaborator

@FichteFoll FichteFoll Jan 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll leave this unresolved for @z411 to read (also the description hasn't been updated).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kind reminder.
@z411

trackma/ui/cli.py Outdated Show resolved Hide resolved
trackma/ui/cli.py Outdated Show resolved Hide resolved
RaitaroH and others added 2 commits January 14, 2023 11:38
@RaitaroH RaitaroH changed the title list shows without formatting list shows in json format Jan 14, 2023
trackma/ui/cli.py Outdated Show resolved Hide resolved
trackma/ui/cli.py Outdated Show resolved Hide resolved
this should be useful in my adl script
@FichteFoll FichteFoll self-assigned this Feb 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants