Coder Social home page Coder Social logo

tsarjak / downloadredditimages Goto Github PK

View Code? Open in Web Editor NEW
82.0 5.0 22.0 90 KB

Easily download all the images from any subreddit (also select sort_type if you want hot/top/new/controversial, and also sort_time day/week/month/year/all). Randomly select downloaded images and set as wallpaper, updating every 30 mins (or whenever you want duh)!

License: MIT License

Python 100.00%
wallpaper-changer reddit earthporn reddit-crawler linux linux-desktop gnome linux-mint ubuntu download-photos

downloadredditimages's Introduction

Download Images/Media from your choice of Subreddit!

Using this script:

  • No Setup Needed!
  • Download any number of images from Any Subreddit! Tested by downloading 500 images.
  • Select your sort type (Top, Hot, New, Controversial)
  • Select your sort time (All, Year, Month, Week, Day)
  • Extremely Reliable Downloading. With progress bar showing ETA.
  • Download using ParallelProcessing
  • Specify your custom save location
  • Major reddit media servers supported (i.redd.it, imgur, gfycat, redgif)
  • If media server is unsupported, Download raw previews
  • (Optional) Install tqdm to see tqdm progress and time estimates. Without tqdm, native progress bar is printed to terminal output.

PS: Automatic wallpaper setting from downloaded images and support for python v2.x has been removed in latest update. Feature will be added back soon(~1 week). Please use the old version if you absolutely need that feature.

No Dependencies! Just Download and Run!

Just download the files and run the file - no need to setup anything at all!

To download via Terminal:

git clone https://github.com/tsarjak/WallpapersFromReddit.git

# Next step is Fully Optional - to use tqdm progress bar. Without this, native progress bar will show up with exact same features, just a little less pretty.
pip install tqdm

To run the code

In terminal:

# In the Home Directory or the Directory in which you cloned/downloaded the script
cd ~/DownloadRedditImages
python download.py 
  --subreddit <your choice of subreddit> 
  --sort_type <hot|new|rising|top> 
  --sort_time <all|year|month|week|day>
  --download_dir <Directory where you want to store the images. For Max/Linux, the script can identify home directory and sets a RedditMedia folder there. For Windows, a path MUST be provided>
  --max_post_downloads <Maximum number of posts media to download. Default=10>
  --max_simultaneous_downloads <Maximum number of simultaneous downloads to run using multiple CPU cores. Default=16.>
  --max_trials <Maximum number of trials to fetch subreddit data. Sometimes the response is slow and multiple attempts are needed. Default=20.>

Example:

python download.py --subreddit pics --sort_type top --sort_time all --max_post_downloads 40 --download_dir /Users/user_me/Pictures/RedditMedia/
# This will download top 50 posts of all time from earthporn subreddit to /Users/user_me/Pictures/RedditMedia folder.
  • Without tqdm installed:

Screen Shot 2022-12-11 at 2 31 50 AM

  • With tqdm installed (optional):

Screen Shot 2022-12-11 at 2 20 41 AM

Changelogs:

v2.1.1 - Dec 11, 2022:

  • Code cleanup and minor bug fixes.

v2.1.0 - Dec 10, 2022:

  • Added support for mp4 and gif downloads.
  • Added support to download directly from media servers (imgur, i.redd.it, gfycat, redgifs) instead of reddit post previews.
  • For other media servers, fallback to reddit post preview download.
  • Added native progress bar. As well as tqdm progress bar for those who already have it installed on their systems.
  • Removed support for automatic wallpaper changing for Linux and Mac. Support will be added back in v2.1.2.
  • Removed support for python v2.x. Some requests/url libraries are difficult to maintain for python v2.x now.

v2.0.0 - April 1, 2021:

  • With this release, WallpapersFromReddit is a No Setup Needed script. This release gets rid of all the requirements, essentially making this a download and run program.
  • Add support to select the sort_type for downloading images. Previously, only hot was supported, but now hot, top, new, controversial are supported.
  • Add support to select the sort_time for downloading images. Previously, only day was supported, but now day, week, month, year, all are supported.
  • A major overhaul of the entire codebase. The previous code has been refactored for clarity, optimization and to avoid some unwanted and unexpected behavior.

Grab the previous release here! For wallpaper and python v2.x support.

DownloadRedditImages v2.0.0 - https://github.com/tsarjak/WallpapersFromReddit/releases/tag/v2.0.0

downloadredditimages's People

Contributors

aachman22 avatar nix-py avatar tsarjak 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

downloadredditimages's Issues

Support feh as wallpaper manager

If you want to support more desktops than Gnome (I'm using awesome and didn't work), I recommend you that, if feh is detected, use feh to set the wallpaper with a command like this:

os.system('feh --bg-fill "%s"' % listwallpaper[count])

Option -hq should not delete images from Wallpapers folder

Problem

It looks like this option will delete any low-res images from the Wallpapers folder, including any images which were already there, not downloaded by the script!

This may be an unexpected and unwanted surprise for someone who already had some small images in that folder.

Solutions

The script could get the listwallpaper from the list of files that was downloaded, rather than polling the destination folder for all the files inside it.

Alternatively, the default folder could have a unique name, e.g. $HOME/Wallpapers/WallpapersFromReddit and the script could create the folder if it doesn't already exist.

AttributeError: type object 'MediaDownloader' has no attribute 'global_counter'

Hello, getting the following error when trying to run the example from the readme

$ python3.9 download.py --subreddit pics --sort_by top --sort_time all --max_post_downloads 40 --download_dir ./images

Downloading 40 posts from /r/pics sorted by top|all to ./images/pics/

pics|top|all|n=40:   0%|                                                                                                                                                       | 0/40 [00:00<?, ?it/s]multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/usr/local/Cellar/[email protected]/3.9.15/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/usr/local/Cellar/[email protected]/3.9.15/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/pool.py", line 48, in mapstar
    return list(map(*args))
  File "/Users/alemelis/WallpapersFromReddit/downloaders.py", line 41, in download_post
    if MediaDownloader.global_counter.get_counter_value() >= MediaDownloader.max_posts_download:
AttributeError: type object 'MediaDownloader' has no attribute 'global_counter'
"""

I'm on macOS 12.5.1, running python3.9 (same error with 3.8 and 3.10)

Unsupported photos

A few photos are not not getting downloaded properly, they just show an error message while opening.

System.Net.Http.HttpRequestException: Response status code does not indicate success: 403 (Forbidden).

Hello,

got following error. Downloader used work for me fine in past. My laic guess this is due to some changes Reddit made recently.

[ERROR]: An error occurred while downloading images for user "someusername". Please try again later. If this error occurs repeatedly, file a bug.
System.Net.Http.HttpRequestException: Response status code does not indicate success: 403 (Forbidden).
   at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
   at System.Net.Http.HttpClient.GetStringAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken)
   at DownloadRedditImages.Program.Get(String author, Int32 createdAfter) in E:\Software\My Software\DownloadRedditImages\DownloadRedditImages\Program.cs:line 207
   at DownloadRedditImages.Program.Download(String author) in E:\Software\My Software\DownloadRedditImages\DownloadRedditImages\Program.cs:line 70
   at DownloadRedditImages.Program.Main(String[] args) in E:\Software\My Software\DownloadRedditImages\DownloadRedditImages\Program.cs:line 49

ps. this is my first post on github, so I hope it belongs here. If not, then sorry.

Error while downloading wallpaper

dCount = download()
TypeError: download() takes exactly 1 argument (0 given)

You probably missed an argument! Let me try to fix it! :)

Error while installing requirements on Ubuntu.

Could not find a version that satisfies the requirement pillow=='5.1.0' (from -r requirements.txt (line 1)) (from versions: 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7.0, 1.7.1, 1.7.2, 1.7.3, 1.7.4, 1.7.5, 1.7.6, 1.7.7, 1.7.8, 2.0.0, 2.1.0, 2.2.0, 2.2.1, 2.2.2, 2.3.0, 2.3.1, 2.3.2, 2.4.0, 2.5.0, 2.5.1, 2.5.2, 2.5.3, 2.6.0, 2.6.1, 2.6.2, 2.7.0, 2.8.0, 2.8.1, 2.8.2, 2.9.0, 3.0.0, 3.1.0rc1, 3.1.0, 3.1.1, 3.1.2, 3.2.0, 3.3.0, 3.3.1, 3.3.2, 3.3.3, 3.4.0, 3.4.1, 3.4.2, 4.0.0, 4.1.0, 4.1.1, 4.2.0, 4.2.1, 4.3.0, 5.0.0, 5.1.0, 5.2.0, 5.3.0, 5.4.0, 5.4.1, 6.0.0, 6.1.0, 6.2.0, 6.2.1, 6.2.2)
No matching distribution found for pillow=='5.1.0' (from -r requirements.txt (line 1))

Does not work on macOS Sierra

The code does not work on macOS Sierra. It terminates with error -
SError: [Errno 45] Operation not supported: '/home/myusername'

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.