Package: rwpp
Reddit Wallpaper Puller (rwpp)This project is a simple python command line application to download images from Reddit built usingTyperandRedditwarp.SetupFor general usage as a user you can simply install the program usingpip install rwpp.Development EnvironmentFor development you can simply create avirtualenvand install the required dependencies.python3-mvenv.venvsource.venv/bin/activate
pipinstall-rrequirements.txtThe project now usesPoetryto build and upload the project toPyPi.
You can setup and manage your virtual environments withPoetry.cdrwpp
poetryshell
poetryinstallUsageAfter installing the program usingpipyou can call it from the command line usingrwpp.
The CLI will prompt you for a limit and a download path, press enter to use the defaults.rwppearthporn# OutputHowmanyimageswouldyouliketodownload?[10]:
Wherewouldyouliketosavetheimages?[./downloads]:DevelopmentAfter setting uprwppfor development, you can call therwpp/main.pyfile with the name of asubreddit.
The CLI will prompt you for a limit and a download path, press enter to use the defaults.pythonrwpp/main.pyearthporn# OutputHowmanyimageswouldyouliketodownload?[10]:
Wherewouldyouliketosavetheimages?[./downloads]:To run the program withPoetrysimply usepoetry run.poetryrunrwppearthpornPublishingPublishing the project to Pypi or Test Pypi is now done using Poetry. After you have made all the necessary commits, tested everything to ensure it runs as expected and setup your Pypi tokens in Poetry (read more here), the process is as follows below.First add your pypi API token usingpoetry config.poetryconfigpypi-token.pypi<token>For uploading to Test Pypi first add the repository to your config and then your token.poetryconfigrepositories.test-pypihttps://test.pypi.org/legacy/
poetryconfigpypi-token.test-pypi<token>Each time you need to publish the project you can usepoetry publish.# Bump versionpoetryversionpatch# Publishpoetrypublish# poetry publish -r test-pypiNotesThis project is currently in beta and dev mode, no code is assumed to be safe.
Run at your own risk, there is currently no check to make sure the url pulled from top posts contains an image, just a valid extensionThe script will check the given download paths for images that 'have already been downloaded'. This is a simple check against the names of the files (titles of their respective posts) to see what's been downloaded. This can become an issue when a user wants to download to multiple paths.
A sqlite db/csv file could be implemented to save details about downloads so that when checking a given path for already downloaded images, the image in question does not have to be inside of the given directory.Had to save the images using the unique post.id rather then the post.title as sometimes it will throw an error if the title is too long.
We can get the unique url which contains part of the title for a more detailed file name.TodoCheck to see if the subreddit exists before pulling images/Handle errors for invalid subredditAdd time filters, so rather then top:all we can do top:day,week,month etc.After adding extra time filters, add the option to pull 'hot' posts with the same filtersAdd time filter of new postsOnly top and controversial posts supports choosing a time range for the download.The goal is to get this script up to the state where it can be a simple command line utility you can run usingrwppand then pass in args such as subreddit(s), how many posts, whether to be top or hot posts, the downloads path to use if not the default oneCurrently doing a simple check against the list of the names ofs the images which have already been downloaded should be suffice, though I don't see it being an issue immediately, I do wonder how well it would scale and at what point does it really start to hinder performance. Maybe look at ways to do a more performant check.