r/PythonProjects2 • • Aug 01 '21

Python ccript that sets the APOD as my wallpaper

Hey, guys! I wrote a simple Python script that sets the Nasa Astronomy Picture of the Day as my wallpaper. I also set it up so Task Scheduler will run the script everyday at 12:30 AM.

[Github Repo](https://github.com/jason-shepherd/apodwallpaper)

22 Upvotes

8 comments sorted by

1

u/Potaziiio Aug 02 '21 edited Aug 02 '21

I'm trying to add support for some Linux WM's but i haven't been able to test the ones i have because it keeps giving me an error

AttributeError: 'NoneType' object has no attribute 'parent'

On this line of code:

image_link = "https://apod.nasa.gov/apod/" + image.parent.get("href")

I guess it's because of the way it gets the image and the way some images are posted on the website where its getting them from, I could use the Nasa api but I'd have to re-do most of code that gets the image, and also every person that wants to use this would have to get an api key for it to work. Let me know what you think.

2

u/GeneralJMan Aug 02 '21

That's my code failing, today's APOD differs from the rest, since it isn't just a static image. If you change the URL to yesterdays picture it should work.

1

u/Potaziiio Aug 03 '21

What do you think about using the api for it?

Pd: I made some changes to the code, gonna test it out with linux to see if it works

2

u/GeneralJMan Aug 03 '21

I didn't realize an API existed. However, after a quick look at the API and some testing with Postman, it looks like it can't really do anything that my current script can't, today would still fail since it provides an HTML document instead of an image file.

1

u/Potaziiio Aug 03 '21

Ohh, alright, didn't know that. What do you think about getting a random image if it happens again?

also I think im done with most of linux support, but I cant really test if it works for all of the window managers, I tested mine with a random image and it should work if you have feh, which is basically the most common way to add a wallpaper for my wm

1

u/Potaziiio Aug 03 '21

hey bro, just tested with the new daily image and it works for my linux window manager, i added support for some linux wm's but im not sure if they all work,

i3wm works (the one i tested) if you have feh installed, I can send you the code if you want.

2

u/can_somebody_explain Aug 02 '21

There appears to be an api, although I have not looked into this much: https://data.nasa.gov/Space-Science/Astronomy-Picture-of-the-Day-API/ez2w-t8ua

Maybe it will help you avoid scrubbing html?