ryukinix / mal

MAL: A MyAnimeList Command Line Interface [BROKEN: BLAME MyAnimeList]
https://mal.readthedocs.io
Other
109 stars 9 forks source link

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

Closed evanjs closed 6 years ago

evanjs commented 6 years ago

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.

ryukinix commented 6 years ago

Thanks for catch that.

Well... this is indeed not a valid date and need to be to parse correctly here: api.py. There a couple of ways to fix that. As this is about how MAL works, I think we should not close the whole application because of that or give any error about it. Because is not a error of MyAnimeList, is a feature (how the PHP developers say, they say). The design is wrong, but that is other history.

A simple strategy to implement one fix for that is keep the raw date untouched, as 2011-05-00 in your case, if a exception is signalized. Or to avoid try/exception blocks, just split by - and check if some of the tokens are a 0 filled string.

As you see, methods with decorator @checked_regex and @checked_connection on api.py did handle exceptions very well, but I did not write a special case for date format on _fdate because I didn't even know that MyAnimeList would be send even MORE TYPES of invalid date here.

Anyway, the MAL API... what are they thinking to put a invalid date to store a information of a PARTIAL-DATE?. :/ well, as the MAL API is so wrong in so many levels, this is not even a surprise...

ryukinix commented 6 years ago

Just one thing, I know are you using the PS prompt of Windows, but Ctrl-C doesn't send a SIGINT signal and close the application when the application throw a exception? Are you tested that?

I don't have sure if Windows implement the POSIX signals, although Windows is not a POSIX system at all.

ryukinix commented 6 years ago

I implemented a simple fix just for you on date-fix feature branch.

Please, reinstall your mal application with that command:

pip install git+https://www.github.com/ryukinix/mal.git@date-fix

Give me a feedback if this works for you.

evanjs commented 6 years ago

Yeah, scratch the interrupt statement. Ctrl+C works fine on Gentoo (4.13.4). Fix seems to work:

PS C:\Users\evanjs> mal filter 'Naruto.*' --extend
Matched 3 items:
1: Naruto
   Completed at 220/220 episodes with score 10
   Started: 03-04-2011   Finished: NA
   Tags: ナルト

2: Naruto x UT
   Completed at 1/1 episodes with score 10
   Started: NA   Finished: NA
   Tags: None

3: Naruto: Shippuuden
   Watching at 387/500 episodes with score 9
   Started: 2011-05-00   Finished: NA
   Tags: ナルト疾
ryukinix commented 6 years ago

Nice to hear about it.