Coder Social home page Coder Social logo

destaq / reddit-wallpapers Goto Github PK

View Code? Open in Web Editor NEW
66.0 5.0 6.0 355 KB

Download the hottest 100 images from r/wallpaper and set them as your cycling Desktop background

License: MIT License

Python 100.00%
wallpaper wallpaper-changer subreddit desktop theme personalization wallpapers

reddit-wallpapers's Introduction

reddit-wallpapers

This program will fetch, download, and save the 100 (changeable number) hottest wallpapers from the r/wallpaper subreddit to a folder in your computer. It can also optionally remove low-quality images, and then cycle through the dozens of images and set them as your desktop background.

Requirements

  • beautifulsoup4 (for BeautifulSoup) (pip3 install beautifulsoup4)
  • praw (pip3 install praw)
  • lxml (pip3 install lxml)

All the above modules are available on PyPI. You can download them each individually or simply run pip3 install -r requirements.txt in the folder that houses requirements.txt.

Reddit Bot Setup

In order for reddit-wallpapers to work, you must create your own Reddit bot. Reddit itself does not provide access to the links and content on its pages, so creating a bot that is given permission to go through its database is required. This takes about 5 mins, and the steps are outlind below.

  1. Go to https://reddit.com/prefs/apps and login if you are asked to do so. This is where you will create the bot.
  2. Scroll to the bottom and click 'create another application'. Fill out the details as follows:

Setup Image

  1. Once you have done the above, click create app. You should now see a bot named ImageBot on your page.
  2. Go to the bottom left of the ImageBot square and click edit. You will now see some information about the bot - most importantly, your personal use script and secret.
  3. Go to wherever you have saved the add_images.py program and start replacing. Replace client_id with your personal use script (seen at the top of the bot square). Replace your client_secret with your 27-character secret key (also seen in the bot square). Replace HIDDEN with your username, and HIDDEN_PASSWORD with your password. Secrets Image You are now all set up with your very own Reddit bot that can read data from Reddit! There's only a few more things to do before you too can get that beautiful changing background!

Usage

First, you need to make sure that you have all the required modules intalled. These are all outlined in requirements.txt and they can be downloaded using pip. Without them downloaded, the program will not run.

Once you have done so, all you need to do is change the os.chdir() line. Currently, it is pointing to a folder on my Desktop, but you will need to change that so it matches an absolute path on your computer (i.e. change Users/Destaq to Users/ and either create a directory in the Desktop or make it point to another blank directory.

The only thing left to do at this point is run the program, with python3 add_images.py. Keep in mind that it may take a few minutes to download all the images due to hardware or Internet limitations. However, you can rest assured as there is a progress bar showing which image is currently being downloaded/processed. You may also notice at the bottom of the code that there are a few lines which check and delete small images. Not all images posted on r/wallpaper are clear, and so the program deletes ones which are smaller than 200 kB. You can change this size, or remove the deletion entirely (but fuzzy images may show up on Desktop).

Last note: Once you have all of your images downloaded to your folder, all you have to do is navigate to your System Preferences/Settings and change the directory where your computer gets its images from. Below is an image showing how to do so on Mac. I recommend setting random order to true to be excited each time you see a new picture!

PS: I've made another cycling wallpaper program, but this one is even better! It teaches you languages, countries, and more straight from your wallpaper, with contributions welcome to help expand the number of topics! Check it out here.

System Preferences Image

reddit-wallpapers's People

Contributors

dependabot[bot] avatar destaq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

reddit-wallpapers's Issues

No such file or directory

After processing all the images I do get this one error:

Writing image 1 of 90.Traceback (most recent call last):
  File "add_images.py", line 66, in <module>
    os.stat(f"image_{i+1}.{images[i][-3]}").st_size < 200000
FileNotFoundError: [Errno 2] No such file or directory: 'image_1.p'

and the scripts stops with only one image in the directory.

BeautifulSoup Parser

I followed the readme and got this error:

Navigated to directory...
Removed previous files...

Processing image 1 of 100.Traceback (most recent call last):
  File "add_images.py", line 48, in <module>
    soup = BeautifulSoup(html_page, "lxml")
  File "/usr/local/lib/python3.7/site-packages/bs4/__init__.py", line 245, in __init__
    % ",".join(features))bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?

Followed the instructions here and did a quick pip3 install lxml / pip3 install html5lib and it started processing images just fine
Screenshot 2020-06-24 at 14 41 49

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.