0

Not getting actual images from NASA Image Viewer (pyportal)
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Not getting actual images from NASA Image Viewer (pyportal)

by devinganger on Mon May 06, 2019 9:42 pm

Greetings,

I'm not getting the actual downloaded images from the PyPortal NASA Image Viewer project. I get the metadata pulled down, but the only image is the default nasa_background.bmp that came with the project.

Basically, it's the same symptoms as discussed in viewtopic.php?f=56&t=151046 but unlike that poster, I am simply trying to make the project work as-is, not bootstrap into my own project.

Any ideas?

devinganger
 
Posts: 66
Joined: Tue Aug 09, 2016 1:09 am

Re: Not getting actual images from NASA Image Viewer (pyport

by adafruit_support_carter on Wed May 15, 2019 10:53 am

Can you try again. I just ran through the guide and tested it out and it seemed to work.

If it is still not working, try connecting to the serial output so you can check for any error messages. I think one subtle tripping point is the need to make the filesystem writeable via boot.py. The error messages would normally be printed to the PyPortal display also. But since you've gotten as far as seeing the background image, the program has taken over that output.

adafruit_support_carter
 
Posts: 11091
Joined: Tue Nov 29, 2016 2:45 pm

Re: Not getting actual images from NASA Image Viewer (pyport

by devinganger on Thu May 16, 2019 4:38 pm

It seems to only not work if the URL that NASA's API returns points to Youtube.

I would think that a simple modification of the sample program so that it checks for the string "youtube" in the returned URL would cause the program to skip that update.

devinganger
 
Posts: 66
Joined: Tue Aug 09, 2016 1:09 am

Re: Not getting actual images from NASA Image Viewer (pyport

by adafruit_support_carter on Thu May 16, 2019 5:15 pm

Ah, interesting. So every now and then it's a video and not an image. Did it not raise an exception that got caught here?
https://github.com/adafruit/Adafruit_Le ... asa.py#L28

adafruit_support_carter
 
Posts: 11091
Joined: Tue Nov 29, 2016 2:45 pm

Re: Not getting actual images from NASA Image Viewer (pyport

by devinganger on Thu May 16, 2019 7:43 pm

Yes, but the problem is that it still updates the metadata and prints that, then spills out the error.

If this is the first URL your PyPortal attempts to load, you'll be left with the default NASA background, an ugly error, and the metadata for the image you were SUPPOSED to have downloaded (but was a link to YouTube). I imagine that if it is later in the cycle, you'll see the same thing, only the previous picture instead of the NASA background.

If the URL is pointing to a resource that Adafruit.io isn't capable of handling, then it should be quietly discarded, not stripped for metadata and passed to Adafruit.io.

devinganger
 
Posts: 66
Joined: Tue Aug 09, 2016 1:09 am

Re: Not getting actual images from NASA Image Viewer (pyport

by adafruit_support_carter on Fri May 17, 2019 1:06 pm

Yah, it doesn't try to do any kind of clean up. It just leaves the display in whatever state and prints a message:
https://github.com/adafruit/Adafruit_Le ... asa.py#L32
and then waits 30 minutes to try again.

So I think a good fix would be to add more logic to the except clause so things are more obvious on the display. One idea would be to set the show() group to None so that the display reverts back to showing the CircuitPython terminal:
https://circuitpython.readthedocs.io/en ... splay.show
So, something like:
Code: Select all | TOGGLE FULL SIZE
    try:
        response = pyportal.fetch()
        print("Response is", response)
    except RuntimeError as e:
        board.DISPLAY.show(None)
        print("Some error occured, retrying! -", e)


Or get fancy and create a text label and add it to the display group.

adafruit_support_carter
 
Posts: 11091
Joined: Tue Nov 29, 2016 2:45 pm

Re: Not getting actual images from NASA Image Viewer (pyport

by kevinjwalters on Mon May 20, 2019 6:46 am

I've just come across same issue, today's "image" is https://www.youtube.com/embed/my1euFQHH-o (Pluto, never forget).

I'm not sure of the optimal place to put this from an architecture point of view and that may have to take into account the low CPU/storage on the end devices but it looks easy to retrieve the title image for YouTube videos based on Stack Overflow: How do I get a YouTube video thumbnail from the YouTube API?

For today's image, either of these would be suitable, latter would give slightly better rescaling result down to the required 320x240 for PyPortal:


Note ratio differences, first image is letter-boxed.

If /api/v2/USER/integrations/image-formatter is modified to return an image I think it needs to have some thought about the API specification, i.e. is it defined to give one image (which one?) for a video or will the same API be used one day to convert to a suitable video format. It would be good to not disrupt existing application code which expects a single image if it's enhanced at a later date to convert video.

kevinjwalters
 
Posts: 325
Joined: Sun Oct 01, 2017 3:15 pm

Please be positive and constructive with your questions and comments.