SchapplM / xbmc-addon-service-watchedlist

Addon for Kodi Media Center to organize "watched"-status of media.
http://kodi.wiki/view/Add-on:WatchedList
GNU General Public License v3.0
32 stars 13 forks source link

watchedlist.py : accept themoviedb number format #52

Closed dwardor closed 2 years ago

dwardor commented 3 years ago

Make watchedlist addon compatible with "The Movie Database Python" scrapper which does not have the "tt" in its movie number format

SchapplM commented 2 years ago

Thanks for your contribution. I am not certain however, what specific error in the code this fixes. Does the variable item not have a field ['imdbnumber'] if you use the scraper you mentioned? In that case I would prefer checking this before. I think using try-except should be only used as a last resort or if the possible errors can not be estimated beforehand.

mafredri commented 2 years ago

I can't speak for @dwardor, but for me the imdbnumber field is populated by the tmdb id. As such, there is no tt prefix and none of the movies are recognized. I've edited the code locally to just remove the prefix and that works (for now).

Btw, all my movies have both imdb and tmdb uniqueids, but tmdb is the default, which is probably why the imdbnumber field is populated by tmdb in the jsonrpc API. It's a bit strange behavior though.

dwardor commented 2 years ago

I can't speak for @dwardor, but for me the imdbnumber field is populated by the tmdb id. As such, there is no tt prefix and none of the movies are recognized. I've edited the code locally to just remove the prefix and that works (for now).

Btw, all my movies have both imdb and tmdb uniqueids, but tmdb is the default, which is probably why the imdbnumber field is populated by tmdb in the jsonrpc API. It's a bit strange behavior though.

Yes I use The Movie Database Python scrapper and my imdbnumber field is filled with tmdb id (because I chose tmdb as default rating source ??? I'm not really sure why...) that contains no tt prefix.

I pulled the "try except" from what is done for tvshow ids (see excerp below) in what seemed to me the exact same "spirit"


                        try:
                            # check if series number is in imdb-format (scraper=imdb?)
                            res = re.compile(r'tt(\d+)').findall(item['imdbnumber'])
                            if not res:
                                # number in thetvdb-format
                                tvshowId_imdb = int(item['imdbnumber'])
                            else:
                                # number in imdb-format
                                tvshowId_imdb = int(res[0])
                        except BaseException:
                             utils.log(u'get_watched_xbmc: tv show "%s" has no imdb-number in database. tvshowid=%d. Try rescraping.' % (item['title'], tvshowId_xbmc), xbmc.LOGINFO)
                             if not silent:
                                 utils.showNotification(utils.getString(32101), utils.getString(32297) % (item['title'], tvshowId_xbmc), xbmc.LOGINFO)
                             tvshowId_imdb = int(0)
SchapplM commented 2 years ago

I agree: The handling of different scrapers is not really consistent in the API. I would prefer having multiple unique ids for a movie in the watchedlist database (if this is no contradiction in itself). Before doing a major refactorisation little fixes like this have to do it. I will merge this into the official repo. As for try-except: Its hard to demand higher coding standards from others, than one is willing to provide oneself :-D