boramalper / himawaripy

Set near-realtime picture of Earth as your desktop background
http://labs.boramalper.org/himawaripy
MIT License
1.62k stars 239 forks source link

bail out on missing "no image" tiles #99

Closed pigmonkey closed 6 years ago

pigmonkey commented 6 years ago

Using the UTC offset feature can result in "No Image" tiles. himawaripy will get the timestamp of the latest sattelite image, subtract or add the offset, and assume an image exists for the newly calculated time. This is correct most of the time, but occasionally results in a timestamp for which there is no satellite image. In this case, the service returns black tiles with the text "No Image".

These blank "No Image" tiles are always 2867 bytes (regardless of the quality level). Legitimate tiles are always a different size (smaller if they are the solid black surrounding Earth, larger if they are part of Earth). By checking the size of each tile immediately after download and bailing out if the tile is 2867 bytes, we can avoid downloading the remaining tiles and stitching them together into a large series of "No Image".

Exiting the program here must be done with os._exit() because this part is multi-threaded. I'm using exit code 3 just so to have a unique reason so that other programs can understand why himawaripy exited at this point.

I've been using this for about a week now and it works great. It is refreshing to constantly have satellite photos and not see the occasional "No Image" interruption.

The "No Image" issue was previously discussed in #82 and #68.

boramalper commented 6 years ago

Thanks!