Last active
January 30, 2018 12:15
-
-
Save TRSGuy/3615540273eb131f9205ca30078514bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import glob, praw, requests, subprocess | |
from pathlib import Path | |
SUBREDDIT = "wallpapers" | |
wallpaperPath = "{}/Wallpapers/".format(str(Path.home())) | |
files = [i.split("/")[-1] for i in glob.glob(wallpaperPath+"*")] | |
r = praw.Reddit(client_id="", | |
client_secret="", | |
user_agent="WallpaperGrabber by /u/ParanoidBox") | |
allowedFormats = ['jpg', 'png'] | |
urls = [post.url for post in r.subreddit(SUBREDDIT).hot() if post.url.split(".")[-1] in allowedFormats and not post.url.split("/")[-1] in files] | |
req = requests.get(urls[0]) | |
with open(wallpaperPath + urls[0].split("/")[-1], 'wb') as file: | |
file.write(req.content) | |
subprocess.call(['feh', "--bg-fill", wallpaperPath + urls[0].split("/")[-1]]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment