youdroid / home-assistant-sickchill

🎥 SickChill component to feed Upcoming Media Card.
3 stars 3 forks source link

Corrrupt cache: Images are downloaded even on 404 errors #12

Closed ghost closed 4 years ago

ghost commented 4 years ago

Seems like if not img_data.status_code.__eq__("200"): does not work as intended for me. I see that also images that results in a 404 error are still cached as broken images. My server respons like this for some reason:

Traceback (most recent call last):
tornado.web.HTTPError: HTTP 404: Not Found

image

img_data.status_code.__eq__("200") returns true even though img_data.status_code is 404. Changing to int and not string seems to fix it:

not img_data.status_code.__eq__(200):

youdroid commented 4 years ago

Hi!

Sure I handled the case or the image does not exist in sickchill. But I haven't found any TV shows to test it. Thank you for giving me a feedback on this point.

I will fix this in the next version ! :smiley:

ghost commented 4 years ago

This might be a medusa/tornado related issue. I've looked a bit into it and it seems to only affect images that are pulled from "anidb". I'm not sure how this works internally or if this affects sickchill too..

In order to fix this I changed from string to int as I mentioned above. I've also rewritten the query to use this instead as it seems more robust: {0}://{1}:{2}/api/v1/{3}/?cmd=show.getposter&indexerid={4}

Here's a screenshot of my /cache/image directory from medusa: image

youdroid commented 4 years ago

You're right, I'm going to modify image fetching to use sixkchill's dedicated poster and fanart API. It will be cleaner and more robust as you say.

In addition I will reinforce the 404 return of the API to correct the error you had at home.

I'll take care of it for the weekend.

Thanks for your feedback