brandan-schmitz / plexbot

Plexbot - A discord bot for automating movie libraries.
0 stars 0 forks source link

TVDB response with null image causing import errors #85

Closed brandan-schmitz closed 3 years ago

brandan-schmitz commented 3 years ago

If a request to TVDB API returns a result without an image, a null pointer exception is thrown when importing media. This should be fixed similar to how the OMDb API handles images that are null by providing a method to get the image URL which will either return the URL or if that URL is null, then it will provide the configured no-poster URL as configured in the bot settings.

An example episode that causes this error is https://api4.thetvdb.com/v4/episodes/8124722

brandan-schmitz commented 3 years ago

The method already exists in both the episode and extended episode data models.

https://github.com/brandan-schmitz/plexbot/blob/f7f5d5b687faefc415a7ba67e257ee12220a923c/src/main/java/net/celestialdata/plexbot/clients/models/tvdb/objects/TvdbEpisode.java#L25-L30

https://github.com/brandan-schmitz/plexbot/blob/f7f5d5b687faefc415a7ba67e257ee12220a923c/src/main/java/net/celestialdata/plexbot/clients/models/tvdb/objects/TvdbExtendedEpisode.java#L36-L41

These methods should be verified against the incoming data to ensure that they are properly working. They do not seem to be detecting null values correctly. The methods in the rest of the TVDB data models for seasons, shows, movies and other items of the type that contain a image field should also be verified. It should also be verified that all usages of these classes use the getImage() method versus directly accessing the image field.

brandan-schmitz commented 3 years ago

This issue is still present. Using the java.lang.string isBlank() does not properly handle nulls. This needs to be switched to use StringUtils.isBlank().