Skip to content

ncksnydr/Reddit-Background-Fetcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Reddit Background Fetcher (Alfred Workflow & Cron Script)

Alfred workflow that fetches desktop backgrounds from subreddits. I wrote this script years ago, but never thought to post it to GitHub. I may revisit this script and convert the PHP to Python at a future date.

The script uses the Reddit's JSON API (yes—it still works) to download images based on the options set by the user. To avoid downloading the same image twice, the unique file name of each image is stored in a file called cache.txt, which is checked before an image is downloaded. Each instance that the script successfully runs will also log the timestamp to the file log.txt.

For the most optimal workflow, set your Wallpaper directory to where the images download and set to randomly Auto-Rotate.

Developer note: Usually I would not commit .png images to a repository, but I am doing it here for a pleasent experience with icon.png in the Alfred prompt.

With Alfred

Installation

  • Download repository.
  • Go to Alfred preferences.
  • Click on Workflows.
  • Create a new blank workflow.
  • Right-click workflow; select Open in Finder.
  • Place files from downloaded repository into the opened directory.

Usage

  • Trigger the Alfred prompt (CMD + Space by default)
  • Type bg to reveal Fetch backgrounds and Clear cache.
    • Fetch backgrounds will run the script and download backgrounds based on your options.
    • Clear cache will, believe it or not, clear the cache of previously downloaded file names.

Configuration

  • Go to Alfred preferences.
  • Click on the Reddit Background Fetcher workflow.
  • Double-click on the Run Script node (to the right of the bg keyword).
  • Refer to the Options section below for a description of each option.

Without Alfred (Cron)

Installation

  • Download repository.
  • Place the downloaded repository folder somewhere that you can reference.
    • Example: ~/Documents/fetcher.
  • Open bg-cron.php in a text editor to change the script options; refer to the Options section below for a description of each option.
  • Open Terminal.app.
  • Type crontab -e.
  • Enter when you would like the script to run, followed by the path to the file bg-cron.php in the respository folder.
    • For crontab references, visit Crontab Guru
    • Example: 0 5 * * * ~/Documents/fetcher/bg-cron.php would run the script every day at 5AM.

Configuration

  • Go to Alfred preferences.
  • Click on the Reddit Background Fetcher workflow.
  • Double-click on the Run Script node (to the right of the bg keyword).
  • Refer to the Options section below for a description of each option.

Options

  • $subreddit - name of the subreddit you'd like to scrape. (Default: EarthPorn)
  • $type - sort option for subreddit. [hot|new|top|rising] (Default: top)
  • $range - range of time for new search results. [hour|day|week|month|year|all] (Default: day)
  • $save_path - where the images should be saved. (Default: Documents/Backgrounds/)
  • $min_bg_width - minimum width an image should have to avoid stretching. (Default: 3000)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages