Git Product home page Git Product logo

mal's Introduction

mal - MyAnimeList Command Line Interface

Build Status codecov PyPi version PyPi License PyPI pyversions PyPI status

Description

mal is a command-line client for MyAnimeList, via the official API.

One of the major design goals of this project is to avoid the use of web-scraping, which means it should work indefinitely. Other projects that scrape the website tend to break whenever MyAnimeList has an update, rarely ever recovering from the needed maintenance as a result.

Development is currently in alpha. New ideas are welcome! But please check CONTRIBUTING.md before you submit that pull request.

This project is an unofficial fork of pushrax/mal, which seems to have fallen out of maintenance.

Features

  • Search your anime list.
  • Fetch your anime list.
  • List animes by their status (e.g. watching).
  • Increment or decrement episode watch count.
  • Add anime to your Plan To Watch list.
  • Edit anime metadata (currently tags, status and score) using your favorite text editor.
  • Print your MAL stats! Just like you do on MyAnimeList.

More features are currently being developed!

If you have a suggestion for a new feature, a bug to report or something else, you can submit an issue.

Please note that as this project is still in alpha development, pretty much everything is subject to change.

TL;DR | Demos

Main Usage

Listing Animes By Status

Requirements

See requirements.txt for detailed version information.

Installation

Preface

Ensure that you are using Python 3 before attempting to install.

It's common for systems to have both Python 2 and 3, so if necessary, use pip3 or python3 -m pip.

If your system has both python2 and python3, replace all instances of python and pip with python3 and pip3 (or python3 -m pip).

Install via pip

From the command line, run:

$ pip install --user mal

This will install the latest stable build of mal from the PyPi repository.

Manual Installation

If you want the absolute latest, bleeding-edge version, you'll have to install manually.

Clone this project and run pip:

$ git clone https://github.com/ryukinix/mal
$ cd mal
$ sudo pip install --user .

Note: If installing in a virtualenv, the sudo is not necessary.

It's also possible to install with the makefile (sudo make install) and the setup script (sudo python3 ./setup.py install), but we strongly recommend pip, as it tracks dependencies, and can uninstall. It is a package manager, after all.

Finally, if you want to update after having already installed, you can do this:

$ git pull origin master
$ sudo pip install --user .

On Arch Linux

This project has been packaged and uploaded to the AUR as python-mal-git in case you're using Arch Linux or a similar distro (like Manjaro).

Troubleshooting

If you just can't get mal to run because it's crashing upon startup, make sure that everything is using python3

$ head -1 $(which mal)
#!/usr/bin/python
$ sudo ed $(which mal) <<< $'1s/python$/python3\nwq'
28
#!/usr/bin/python3
29
$ head -1 $(which mal)
#!/usr/bin/python3

You might have to go through a few files to get it to work, but usually, editing the launcher is enough. Failing that, delete the launcher, re-clone the repo, and try again in a virtualenv. If it works there, be careful to follow the above steps and make sure you're using python3 for everything.

Usage

Authenticating

For some reason, the MAL API requires a username and password for most actions... including searching the main database. Thus, mal needs your MAL login to be useful. To prevent this from being a headache, mal stores your credentials in your OS's default config path (e.g. ~/.config/mal/myanimelist.ini for Linux). Your username and password are stored unencrypted in plain text in that file. If you haven't already authenticated (mal login), the program will ask for your credentials when needed.

Currently, there is an open issue hoping to resolve the whole "plain text password" kerfuffle.

The format of myanimelist.ini is as follows:

[mal]
username = your_username
password = your_password

Using The Interface

When mal is executed without any arguments, a help message is displayed:

$ mal
usage: mal [-h] [-v]
           {search,filter,increase,inc,decrease,dec,login,list,config,drop,stats,add,edit}
           ...

MyAnimeList command line client.

positional arguments:
  {search,filter,increase,inc,decrease,dec,login,list,config,drop,stats,add,edit}
                        commands
    search              search an anime
    filter              find anime in users list
    increase (inc)      increase anime's watched episodes by one
    decrease (dec)      decrease anime's watched episodes by one
    login               save login credentials
    list                list animes
    config              Print current config file and its path
    drop                Put a selected anime on drop list
    stats               Show anime watch stats
    add                 add an anime to the list
    edit                edit entry

optional arguments:
  -h, --help            show this help message and exit
  -v, --version         show the version of mal

You can also use the -h or --help options with mal or any of its subcommands to see specific help messages.

$ mal list -h
usage: mal list [-h] [--extend] [--user USER] [section]

positional arguments:
  section      section to display, can be one of: [all, watching, completed,
               on hold, dropped, plan to watch, rewatching] (default: all)

optional arguments:
  -h, --help   show this help message and exit
  --extend     display extra info such as start/finish dates and tags
  --user USER  choose which users list to show

Contributing

See CONTRIBUTING.md

License

GPLv3

mal's People

Contributors

bradenbest avatar evanjs avatar luizperes avatar mparadinha avatar ryukinix avatar xxami avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

mal's Issues

[bug] recent change broke search function

Looks like the fix to #88 caused a different bug. Any time I attempt to search for something...well, this happens:

$ mal search cat\ soup
Traceback (most recent call last):
  File "/usr/local/bin/mal", line 9, in <module>
    load_entry_point('mal==0.4.0', 'console_scripts', 'mal')()
  File "/usr/local/lib/python3.5/dist-packages/mal-0.4.0-py3.5.egg/mal/cli.py", line 192, in main
    args.func(mal_api, args)
  File "/usr/local/lib/python3.5/dist-packages/mal-0.4.0-py3.5.egg/mal/commands.py", line 25, in
search
    core.search(mal, args.anime_regex.lower(), full=args.extend)
AttributeError: 'Namespace' object has no attribute 'anime_regex'

$ mal search nichijou
Traceback (most recent call last):
  File "/usr/local/bin/mal", line 9, in <module>
    load_entry_point('mal==0.4.0', 'console_scripts', 'mal')()
  File "/usr/local/lib/python3.5/dist-packages/mal-0.4.0-py3.5.egg/mal/cli.py", line 192, in main
    args.func(mal_api, args)
  File "/usr/local/lib/python3.5/dist-packages/mal-0.4.0-py3.5.egg/mal/commands.py", line 25, in
search
    core.search(mal, args.anime_regex.lower(), full=args.extend)
AttributeError: 'Namespace' object has no attribute 'anime_regex'

filter's fine, though.

$ mal filter nichijou
Matched 6 items:
1: Nichijou: Original Jikai Yokoku
   Completed at 14/25 episodes with score 6

2: Danshi Koukousei no Nichijou
   Completed at 12/12 episodes with score 10

3: Danshi Koukousei no Nichijou Specials
   Completed at 6/6 episodes with score 9

4: Nichijou: Nichijou no 0-wa
   Completed at 1/1 episodes with score 9

5: Nichijou
   Completed at 26/26 episodes with score 10

6: Monster Musume no Iru Nichijou
   Watching at 1/12 episodes with score -

It expects the token, "anime_regex", but is getting "anime_title" instead. Looks like while the documentation was updated, the code that relies upon the internal symbols was not.

Update sphinx docs at /docs before official 0.4.0 release

This should be done. Currently docs is just a straightforward translation of a OLD README.md. This is a quite bad. I should indeed update the gifs as well because the use-case for now it's a quite different between filter/search and even we take a issue report because that #88

[feature request] add 'comments' field to 'edit' function

The comments field is one I use quite extensively to remind myself of various things, like why I loved/hated a show so much, or what convinced me to add it to my on-hold queue (which I treat as a high-priority plan to watch, so explanations are necessary). It would be nice to have that here so I don't have to use the website.

I didn't see a way to tag the issue from the editor, so I put the tag in the title out of consideration.

Default file should be in .config/myanimelist

For the past few years, it's been best practice on Linux to have programs save their configuration in the .config directory. A subdirectory can be created when there are more than one file pertaining to the same program.

edit:

DEFAULT_FILE = '~/.myanimelist.init' should become DEFAULT_FILE=~/.config/myanimelist, and the readme would have to be updated.

Partial [Start/End] dates cannot be parsed and crash application

MyAnimeList allows the user to enter a partial date for start and end date.
When the python client (mal) sees this, it throws a ValueError exception.

Example date: 05/00/2011
Command: mal filter 'tex.*' --extend
ValueError: time data '2011-05-00' does not match format '%Y-%m-%d'

After changing the suspect entries to "Unknown Date" on MyAnimeList (which seems to just blank the dates out), this issue seems to be fixed.

PS C:\Users\evanjs> mal filter 'tex.*' --extend
Matched 1 items:
1: Texhnolyze
   Plan to watch at 0/22 episodes with score -
   Started: NA   Finished: NA
   Tags: None

No idea how this should be handled, but I figure anything is better than what currently happens: the error is thrown, the process does not halt, and cannot be interrupted, forcing the user to close the window/tab in which mal is running.

Add subcommand watch

Goal (example)

watch

mal lain watch next
~opening your default player~

Needs

The #2 need to be fixed before.

Specification

After calling watch command, this will fetch the actual episode of the lain, get the next, search on the default streaming server configured, open your default player and update (+1) the watching list.

Create manpage and distribute with the software

Seems we can generate manpages with the sphinx docs (which can be improved). Would be nice getting this manpage and embedding on the package to get installed via pip or another package managers (like the package hosted on AUR)

Shouldn't ask for score if score is already given when completing an anime

As you can see there, I already gave score to it, it shouldn't ask for scoring. It should be ended with "Series completed with score 8.". Also, pressing enter there without typing anything throws an error. Instead of "0 for no score", it should be "Leave it empty for no score" something. I don't know if it's intended, though.

user stats

Maybe we could create a command to show the user stats like those on the website.
mal_drassof_stats

(this isn't my MAL btw, it's of a friend of mine how has watched a lot more then me)

Something like this:

$ mal stats
Watching: 3
Completed: 32
...
Total episodes: 1500
Watch time: 24.10 days

We could even try to do that bar graph with color, but I'm not really sure how to do that.

Log in loop due to Attribute Error.

When trying to use mal on python 3.6.1, I'm unable to log in due to an attribute error. Here is the exact error I get:

 ⣾ validating login ▁Traceback (most recent call last):
  File "/usr/bin/mal", line 11, in <module>
    load_entry_point('mal==0.3.0', 'console_scripts', 'mal')()
  File "/usr/lib/python3.6/site-packages/mal/cli.py", line 128, in main
    config = login.get_credentials()
  File "/usr/lib/python3.6/site-packages/mal/login.py", line 24, in get_credentials
    config = create_credentials()
  File "/usr/lib/python3.6/site-packages/mal/login.py", line 39, in create_credentials
    if MyAnimeList.validate_login(config[setup.LOGIN_SECTION]):
  File "/usr/lib/python3.6/site-packages/mal/utils.py", line 85, in wrapper
    result = func(*args, **kwargs)
  File "/home/m3llo/.local/lib/python3.6/site-packages/decorating/decorator.py", line 127, in _wrapper
    result = function(*args, **kargs)
  File "/usr/lib/python3.6/site-packages/mal/api.py", line 52, in validate_login
    self.base_url + '/account/verify_credentials.xml',
AttributeError: 'SectionProxy' object has no attribute 'base_url'

Add torrent sub-command

Description

We should be able to get the torrent file or magnet link for the next episode passing a anime_regex exactly how other commands like search, filter, add currently does. Some users recommended to me for default get the anime torrent/magnet-links from torrents hosted into http://nyaa.si/. Maybe this can be possible through the recent PR integration of nyaa.si into torrench, a multi-platform API and CLI written in Python integrating various torrent search engines (as suggested by @datafanatic in previous discussion at #3)

Design choices

The default behaviour for search is to fetch the desired anime based on your MyAnimeList data, so then get the torrent or magnet link of the next episode on your list. That way we can pass short names and not worry about multiple matches (like just typing steins and return Steins;Gate because is that all you have in your watching list (supposition). Remember that all the search process happens through simple regex through your MyAnimeList profile content.

When we found multiple results, as another commands which make a action based a provided anime_regex, we should print the multiple results and ask for the user (via stdin) which anime he meant by a index (likely how torrench does too, but without using tabulate).

Usage

Download the torrent file

Download the torrent file of the next episode of lain which is translated to Serial Experiments Lain based through the mal data so then.

$ mal torrent lain

Get magnet link

Similiar to above, but print to stdout the magnet link for the next episode

$ mal torrent --magnet lain 

Can be implemented a -m flag as alias

Extra

  • Implement a --all flag to select a torrent from the provided anime with all the episodes (full-pack)
  • We should pass as optional parameter the search engine if the user want change, but again, for default the https://nyaa.si, can be either --engine SEARCH_ENGINE or ==search SEARCH_ENGINE, we should choose the better.

Roadmap for torrent command

  • integrate torrench with nyaa.si as default
  • get torrent file
  • get magnet link
    • -m alias
  • --all flag to get torrent/magnet-link with all episodes
  • --engine or --search argument to select the search engine to use with torrench

Add edit sub-command

Old idea

  • usage anime score regex

The current possibility to put score on anime is only when the watching process is completed using mal inc regex command, so the CLI will ask for the user about the score of that anime.

Would be better if we can score any anime of the user list.

Edited

This thread now is about creating the command edit with the following features: edit
the fields of a specific anime: status, score and tags. Maybe we can add more of them later.

Status of implementation:

  • edit with an editor like vim or emacs through the env variable EDITOR
  • flag --status set the list status of anime
  • flag --score set the score of anime
  • flag --tags set N tags on anime
  • additional short alias for all flags

Abandon appdirs and use ~/.config/mal

I understand your trouble to use appdirs' user_config_dir function to get proper config directory but in mac side for a command-line application putting configuration files under~/Library/Application Support/mal does not make sense at all. It's there mostly for GUI apps. mal should use ~/.config/mal/ as default nomatter what.

Can't say anything about Windows though but AFAIK it should be C:\Users\<username>\mal\myanimelist.ini.

Apart from that, I have set $XDG_CONFIG_HOME, why don't you use that? (Although, it's a Linux standard, it's still acceptable under Unix as far as I see.) I think you should drop support for appdirs and use common config paths or $XDG_CONFIG_HOME if they are set.

Search other users anime lists

How about a new option like --user=USERNAME to search some other users anime list instead of our own when using the program? This would only work on the list command of course.
It seems easy to implement

[need-update] `anime_regex` is a wrong arg name for search command

When you exec mal search without an argument, it gives this:

$ mal search
usage: mal search [-h] [--extend] anime_regex
mal search: error: the following arguments are required: anime_regex

This tells me that it accepts regex. However, the actual behavior differs from the expected behavior, and acts more like a raw string search, rather than a regex search.

$ mal search boku
<long list of anime>
$ mal search b.ku # expect: baku, bbku, bcku, ...
No matches in MAL database ᕙ(⇀‸↼‶)ᕗ
$ mal search b[oua]ku # expect: boku, buku or baku
No matches in MAL database ᕙ(⇀‸↼‶)ᕗ

If it supported regex, it should at least be displaying the 50-or-so anime that the first call did. I know that there's two major standards of regex that are slightly different, so I pulled up an online python regex tester, and all of my tests worked on there.

Document api.py

mal.api don't have docstrings of its methods. We need it.

  • validate_login
  • login
  • search
  • list
  • find
  • update

Refactor command line interface using a symmetric and better abstraction

For now I don't use any lib for parsing command line arguments and without abstraction in the major cases we don't have power.

We need a good way and easy to use and develop more arguments for mal.

config
------
$ mal config
:: streaming:
1. superanimes (free server) (no credentials need) (pt-br)
2. crunchbag (paid server) (need credentials) (multilanguage)
select streaming source: 1
:: player
1. vlc
2. mplayer
select your player: 1
:: download:
1. anbient (pt-br)
2. another (?)
select download source: 1

download
--------
$ mal lain download next
==> downloading the epi ~x~

watch
--------
$ mal lain watch next
~opening your default player

This need work well as the default features for now.

[Feature Request] List related anime in extended info

One of the main reasons I have to keep coming back to the website after starting/finishing a single entry, is to check the related anime to see if there's an OVA, movie, or sequel to be seen. It would be nice to have this information available when I search, list or filter an anime with --extend.

Do you think a feature like this would be possible given MAL's API?

Store login credentials in encrypted form

I noticed that after running mal login, ~/.config/mal/myanimelist.ini contains my MyAnimeList login credentials in plaintext. I think there should at least be an option to store it as a GPG encrypted blob (so whenever I run mal it will ask the GPG agent to decrypt the blob, prompting me for a password to my GPG private key every so often). I may take a look at implementing this myself.

MAL API it's broken: HTTP 404

Description

It's eternally dead? Will be shutdown forever?

We need research for info. I didn't find nothing yet.

Reading info in the subreddit of MyAnimeList seems that all 3rd apps are now broken due to the aggressive move of myanimelist shutdown it's own API. We need look for more info.

References

Find and add new animes to list

When I do mal search it only shows results that are already on my animelist. Don't know if this was intended, but it would be nice to have that feature as well as being able to add an anime to the list (maybe a add command).
I noticed that the MyAnimeList.search is not used anywhere in the codebase and it seems to be there for this exact purpose.

  • implement new search command
  • implement add command

Option to disable "back and forth" animation on Windows

In a default Windows command prompt, the fancy loading animation causes some nasty output due to the lack of proper support for symbols/colors in cmd. Powershell does the same thing. Here is an example of how it looks:
????????? ? matching animes - preparing animes ▄←[G←[K←[G←[KMatched 17 items:

Would it be possible to have a config option that would disable that animation?

Edit: It's obviously low-priority (as it is aesthetics) but I would be more than happy to write it myself and submit a pull request, if you wanted.

Curses interface for mal

I've been wanting to make a curses interface for mal for a while now, I don't have much time free but someday maybe I'll get to it.
It could be an extension for this project or it can be on a separate project. What do you think?

Update dependencies

Hello I have version 2.11.1 of requests installed and mal complains when running, it gives this output:

Traceback (most recent call last):
  File "/usr/lib/python3.5/site-packages/pkg_resources/__init__.py", line 662, in _build_master
    ws.require(__requires__)
  File "/usr/lib/python3.5/site-packages/pkg_resources/__init__.py", line 970, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python3.5/site-packages/pkg_resources/__init__.py", line 861, in resolve
    raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.ContextualVersionConflict: (requests 2.11.1 (/usr/lib/python3.5/site-packages), Requirement.parse('requests==2.10.0'), {'mal'})

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/mal", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2991, in <module>
    @_call_aside
  File "/usr/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2977, in _call_aside
    f(*args, **kwargs)
  File "/usr/lib/python3.5/site-packages/pkg_resources/__init__.py", line 3004, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/lib/python3.5/site-packages/pkg_resources/__init__.py", line 664, in _build_master
    return cls._build_from_requirements(__requires__)
  File "/usr/lib/python3.5/site-packages/pkg_resources/__init__.py", line 677, in _build_from_requirements
    dists = ws.resolve(reqs, Environment())
  File "/usr/lib/python3.5/site-packages/pkg_resources/__init__.py", line 856, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'requests==2.10.0' distribution was not found and is required by mal

Could you update the dependencies please? Thank you.

Adding support to manga list

I think it's time to add a upport to do actions on the manga list (inc/dec/search, etc.).
It might be as easier as replacing API urls' anime word to manga, be we need to check if the XML results match in format.
We could add an argument --mode which could either get anime or manga, when the default is anime.

Add subcommand download

Goal (example)

download

mal lain download next
==> downloading the epi ~x~

Needs

The #2 need to be fixed before.

Specification

After calling download command, this will fetch the actual episode of the lain, get the next, search on the default download server configured and save him in the actual directory.

  • use urlretrieve and tqdm for download
  • allow pass a custom directory for saving
  • allow all alias (download all episodes)
  • all download a specific episode with the number

Improve inc and dec commands

I think that inc or dec commands should get the number of episodes to change as an argument, for exmaple:

mal inc Naruto 5

Instead of increasing/decreasing one episode at a time.

Write unit tests for all project

We need a basic set of tests to use continues integration to validate all functionalities. After that I'll setup the https://codecov.io/.

We can create test sets by file on /test folder, like this:

> tree
. tests/
    test_cli.py
    test_api.py
    ...

Roadmap

  • basic tests
  • codecov
  • full tests
    • api
      • validate_login
      • login
      • search
      • list
      • find
      • update
    • cli
    • core
    • commands
    • login
    • setup
    • utils

Add subcommand config

Goal

config

> mal config
:: streaming:
1. superanimes (free server) (no credentials need) (pt-br)
2. crunchbag (paid server) (need credentials) (multilanguage)
select streaming source: 1
:: player
1. vlc
2. mplayer
select your player: 1
:: download:
1. anbient (pt-br)
2. another (?)
select download source: 1

Specification

  • create the list of supported streaming & download sources
  • persists the configuration for:
    • streaming source
    • download source
    • default player

mal is broken

I have pulled from dev branch and now mal seems to be broken, the output:

[alex@archlinux mal]$ python mal/cli.py 
Traceback (most recent call last):
  File "mal/cli.py", line 20, in <module>
    from mal import commands
ImportError: cannot import name 'commands'
[alex@archlinux mal]$ 

Some answers for related issues on stackoverflow suggest it happens because of circular dependencies but it doesn't look like the case here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.