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: 67
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: 11926
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: 67
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: 11926
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: 67
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: 11926
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: 387
Joined: Sun Oct 01, 2017 3:15 pm

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

by kevinjwalters on Wed May 29, 2019 6:15 pm

I've got a first stab at making YouTube urls work with these changes (#38):


Tested ok with 2019-05-20 data.

That also has a change to look for the NASA API key in secrets.py as nasa_api_key.

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

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

by htmagic on Fri May 31, 2019 8:40 pm

I'm impressed with Adafruit and this forum crew.
I like the improvements you have done for this program.

One of the challenges with the PyPortal is writing tight code to work on this microprocessor.
I just downloaded an update to the Android Red Lobster application.
75 Mb of bloatware! I could care less about fancy graphics, I'd rather have tight codes and snappy performance so it runs fast, even on a 3G tower!
But no, script kiddies could care less and want flash and bang, and snap, it crashed again! They could write tight code if their lives depended upon it!
It's sad that an app for dinner has to be 75 Mb big, hogging up my phone memory, whereas NASA used about 8K of code to get us to the moon!

May the FORCE be with you and have a magical day!

MagicBill

htmagic
 
Posts: 5
Joined: Tue Dec 03, 2013 12:18 am

Please be positive and constructive with your questions and comments.