Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

source.unsplash.com deprecation (unsplash stopped working on nwg-lock) #83

Closed
EvantheGrump opened this issue Oct 19, 2024 · 3 comments
Closed

Comments

@EvantheGrump
Copy link

The method that is used in nwg-shell-config to download images from unsplash to use as an image for the lockscreen has been deprecated by unsplash. From now on, a developer account and api key is required to download images from unsplash.

I've messed around with the API a little bit, and found that this python reliably fetches a random images according to the parameters:

CLIENT_ID (api key)
QUERY (keyword for photo)
WIDTH (image width)
HEIGHT (image height)
PATH (path for images)

random_url = f'https://api.unsplash.com/photos/random?client_id={CLIENT_ID}&query={QUERY}&orientation=landscape'
response = requests.get(random_url)

if response.status_code == 200:
    data = response.json()

    raw_url = data['urls']['raw']
    photo_id = raw_url.split('/')[-1].split('?')[0]
    image_url = f'https://images.unsplash.com/{photo_id}?w=WIDTH&h=HEIGHT'

    image_path = 'PATH'
    response_image = requests.get(image_url)

    if response_image.status_code == 200:
        with open(image_path, 'wb') as f:
            f.write(response_image.content)

        os.system(f'swaylock -i {image_path}')
    else:
        print('Error downloading image:', response_image.status_code)
else:
    print('Error fetching data:', response.status_code)

I'm not sure how I would go about implementing this in a pull request, as my knowledge of python is lacking. I would greatly appreciate it if you reimplemented unsplash or an alternative image-fetching service!

@nwg-piotr
Copy link
Owner

nwg-piotr commented Oct 20, 2024

Yep, I'm not sure whether a screen locker complies to their rules. I wrote them an email to find out.

[edit] They don't bother reading the emails they receive. I've been sent back to API guidelines.

@nwg-piotr
Copy link
Owner

Their current API rules are too strict. I decided to switch to wallhaven.cc.

@EvantheGrump
Copy link
Author

Fantastic, thanks so much for your work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants