winterbird-code / adbb

Object Oriented UDP Client Library for AniDB
GNU General Public License v3.0
17 stars 4 forks source link

multiple mylist entries exceptions #5

Closed Andy2244 closed 6 years ago

Andy2244 commented 7 years ago

Oki the only way i could find to check if i have watched or collected a given episode is, by creating a virtual generic file object.

ep = adbb.Episode(eid=155250)
file2 = adbb.File(anime=ep.aid, episode=ep.episode_number)
log.debug('state: %s, viewed: %s', file2.mylist_filestate, file2.mylist_viewed)

Unfortunately i get this error:

raise AniDBFileError("adbb currently does not support multiple mylist entries for a single episode")

How complex is it to support this, i mainly only care about the mylist_state/mylist_filestate and mylist_viewed. Thats because using flexget we will use generic episodes and mainly care if the user already has this episode watched or collected.

Andy2244 commented 7 years ago

This code, syntax also keeps adding the exact same entry to the db, growing it on every call, which i assume should not happen?

file2 = adbb.File(anime='Drifters', episode=3)
log.debug('*** status: %s ,file_state: %s, viewed: %s', file2.mylist_state, file2.mylist_filestate, file2.mylist_viewed)
winterbird-code commented 7 years ago

The problem is that when you ask the anidb api using aid and eid you can get response 312 MULTIPLE MYLIST ENTRIES instead of 221 MYLIST. From the information in the 312 response you can't really get any information about any of the files you have for that episode.... The only thing you can tell for certain when you receive that exception is that there is at least two files for that episode in the users mylist.

If you have one of the files present (complete with size and correct hash) you can add the file path to the constructor and you'll get around this problem; but unfortunately I don't know any other way to handle this...

As for your second comment, that shouldn't happen; I'll take a look.

winterbird-code commented 7 years ago

It was an optimization attempt gone bad; It needs the eid to be able to fetch the entry from the database, but it never fetched the episode object from anidb, so it created a new file each time instead... Now it will do two anidb requests the first time that file is created: one to fetch the eid of the episode, and one to fetch the mylist data; but after that the information will be cached.

Andy2244 commented 7 years ago

Assuming i have no local information or files, i can't get any watched state/date from mylist for the episode, if i get this exception? So all i can guess is that i have the file collected?

winterbird-code commented 7 years ago

A 312 response does contain some information about what episodes are watched and so on; I guess we could add that information to the exception object and then you could handle the exception in the calling code. However, I don't think we'll be able to save the information to the database, meaning that there will be no cache for objects throwing this exception and there's a high risk of an anidb ban if this is treated as a "normal" case...