topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Saturday July 13, 2024, 5:03 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: [Pre-Release] Reddit Image Downloader  (Read 7222 times)

KynloStephen66515

  • Animated Giffer in Chief
  • Honorary Member
  • Joined in 2010
  • **
  • Posts: 3,742
    • View Profile
    • Donate to Member
[Pre-Release] Reddit Image Downloader
« on: May 31, 2023, 08:42 PM »
NANY 2024 Entry Information

Application Name [Python] Reddit Image Downloader
Version 0.1
Short Description Download n random images from any subreddit, and save them to a folder 
Supported OSes Anything that can run python
Web Page Only available here
Download LinkDownload Here
System Requirements
  • Internet Connection: Required for downloading images from Reddit
  • Python Version: 3.7 or above
  • Additional Libraries: requests, Pillow, tqdm
Author Click my name


Description
🌟 Introducing the Reddit Image Downloader: Fun-tastic Edition! 📸🎉

Get ready to embark on a thrilling and fun-filled image expedition with the Reddit Image Downloader: Fun-tastic Edition! This extraordinary Python script is your passport to a world of excitement, laughter, and captivating visuals from Reddit's most entertaining subreddits. Brace yourself for a truly unforgettable experience!

Why choose the Reddit Image Downloader: Fun-tastic Edition? Here are some fantastic features that will make your image exploration a blast:

1️⃣ Endless Fun, Beyond Memes: The Reddit Image Downloader: Fun-tastic Edition goes beyond just memes, uncovering a wide range of fun and entertaining images from various subreddits. From adorable animals to stunning landscapes, epic artwork to mind-bending illusions, this script brings you a kaleidoscope of visual delights to brighten your day.

2️⃣ Example Usages: Let's dive into the exciting possibilities of the Reddit Image Downloader: Fun-tastic Edition! Use it to:

📸 Create a collection of cute animal pictures from r/aww for a heartwarming slideshow.
🎨 Gather inspiring artwork from r/art to fuel your creativity and brighten your workspace.
🌄 Download breathtaking landscape images from r/EarthPorn for virtual travel adventures.
🤣 Collect hilarious images from r/funny to share with friends and create your own comedy show.
🚀 Grab captivating space-themed images from r/spaceporn for a cosmic screensaver.
🎉 Save amusing reaction GIFs from r/reactiongifs to enhance your online conversations.
🌈 Collect vibrant illustrations from r/illustration for a personalized digital art gallery.
🐱 Download adorable cat pictures from r/cats to create a "Meow of Fame" montage.
🍕 Gather mouth-watering food images from r/foodporn for culinary inspiration.
🏞️ Save stunning nature photos from r/naturepics for a calming and immersive screensaver.
🐶 Create a collection of funny dog pictures from r/dogpictures to boost your mood.
🎮 Download epic gaming screenshots and fan art from r/gaming to fuel your gaming passion.
🖼️ Gather art masterpieces from r/pics for an artistic slideshow on your digital frame.
🎉 Collect party and celebration images from r/PartyParrot for festive event invitations.
🌌 Download mesmerizing night sky photos from r/space for stargazing inspiration.
🍕 Save delicious pizza images from r/Pizza to create a mouth-watering screensaver.
🌸 Gather beautiful flower images from r/flowers for a virtual bouquet to brighten your day.
🚗 Download cool car photos from r/Autos to create a dream car vision board.
🎭 Save images from cosplay subreddits like r/cosplay to appreciate incredible costumes.
🍩 Gather tempting dessert pictures from r/dessertporn for a drool-worthy dessert recipe book.
⚡️ Download images of lightning strikes from r/weather to create a captivating weather screensaver.
🐍 Collect mesmerizing snake images from r/Sneks to appreciate their beauty and diversity.
🏞️ Save serene forest landscapes from r/ForestPorn for a peaceful and immersive screensaver.
🐦 Gather stunning bird photos from r/birdpics to create a digital aviary on your desktop.
🎉 Download party meme images from r/wheredidthesodago for a hilarious virtual celebration.
🎵 Collect images related to your favorite music artists from r/Music for a personalized gallery.
🌊 Save breathtaking ocean scenes from r/OceanPorn for a tranquil and immersive screensaver.
🐟 Gather colorful fish images from r/Aquariums to create a virtual aquarium on your desktop.
🚀 Download images from NASA subreddits like r/spaceexploration to explore the wonders of space.
🎥 Collect behind-the-scenes images from your favorite movies and TV shows from r/MovieDetails.
🌺 Save images of tropical flowers from r/tropical for a virtual paradise on your desktop.
🍔 Gather mouth-watering burger images from r/Burgers for a delicious screensaver.
📚 Download book cover art images from r/bookcoverporn for a virtual library on your desktop.
🎮 Collect nostalgic video game images from r/retrogaming for a trip down memory lane.
🎨 Gather incredible street art images from r/graffiti for an urban art gallery.
🐼 Download adorable panda pictures from r/pandas for an instant mood boost.
🚁 Capture stunning aerial photography from r/aerialporn for a bird's-eye view.
🌅 Save breathtaking sunset images from r/SunsetPorn for a soothing screensaver.
🌳 Gather images of ancient trees from r/ancienttrees to appreciate their majestic beauty.
🌈 Download rainbow-themed images from r/rainboweverything for a burst of color.
🎥 Collect behind-the-scenes images from r/behindthegifs for a peek into GIF creation.
🏞️ Save images of hidden gems from r/hiking for your next outdoor adventure.
🐮 Gather cute cow pictures from r/happycowgifs for a dose of bovine joy.
🌌 Download stunning Milky Way photos from r/MilkyWayPhotography for cosmic inspiration.
🎮 Collect video game-inspired artwork from r/gamingart for a gaming art showcase.
🎵 Save images of vinyl records and turntables from r/vinyl for music enthusiasts.
🎉 Download images of celebration fireworks from r/fireworks for a festive screensaver.
🎭 Collect theatrical makeup images from r/SFX for a showcase of special effects makeup.
🌍 Save captivating images of Earth from space from r/NASA for a cosmic screensaver.
🌸 Gather images of Japanese cherry blossoms from r/Sakura for a serene screensaver.

With the Reddit Image Downloader: Fun-tastic Edition, the possibilities for joy and entertainment are truly limitless. Start your image adventure today and unleash the power of visual fun from Reddit's most delightful subreddits! 🚀📸🎉

(Yes, AI wrote the description for me because my only remaining braincell wanted to type "it downloads pics from reddit" as the description)

Features
Subreddit Image Downloader
Multithread
Supports args, or user input

Planned Features
No clue, ask and I'll probably add

Screenshots
dler.png[Pre-Release] Reddit Image Downloader

Usage
Installation
It's python, just run it like:

pip install requests urllib uuid4 sys concurrent.futures PIL Image io logging tqdm argparse

python dler.py
or
python dler.py -h (for help)

Using the Application
Do the above and everything else is obvious

Uninstallation
Delete it

Tips
Try not to get obsessed and end up with 3000+ Possum Memes in a folder, like I did

Known Issues
Can take up a lot of space if you become obsessed with possum memes







RAW CODE:


Code: Python [Select]
  1. import requests
  2. import os
  3. from uuid import uuid4
  4. import urllib
  5. import sys
  6. import concurrent.futures
  7. from PIL import Image
  8. from io import BytesIO
  9. import logging
  10. from tqdm import tqdm
  11. import argparse
  12.  
  13. logging.basicConfig(level=logging.INFO)
  14. logger = logging.getLogger(__name__)
  15.  
  16. def download_image(image_link, folder_name):
  17.     try:
  18.         response = requests.get(image_link)
  19.         if response.status_code == 200:
  20.             image_data = response.content
  21.             image = Image.open(BytesIO(image_data))
  22.             if image.format.lower() in ['jpeg', 'jpg', 'png']:
  23.                 image_name = str(uuid4()) + "." + image.format.lower()
  24.                 image_path = os.path.join(folder_name, image_name)
  25.                 with open(image_path, 'wb') as file:
  26.                     file.write(image_data)
  27.                 logger.info(f"Downloaded image: {image_link}")
  28.             else:
  29.                 logger.warning(f"Skipping image with unsupported format: {image_link}")
  30.         else:
  31.             logger.warning(f"Unable to download image: {image_link}")
  32.     except Exception as e:
  33.         logger.exception(f"Error downloading {image_link}: {e}")
  34.  
  35. def download_images(search_term, folder_name, limit):
  36.     if not os.path.exists(folder_name):
  37.         os.mkdir(folder_name)
  38.  
  39.     headers = {
  40.         "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"
  41.     }
  42.  
  43.     response = requests.get(f"https://www.reddit.com/r/{search_term}/.json?limit={limit}", headers=headers)
  44.  
  45.     data = response.json()
  46.  
  47.     if "data" not in data:
  48.         logger.warning("No posts found in subreddit")
  49.         sys.exit()
  50.  
  51.     image_links = []
  52.  
  53.     for post in data["data"]["children"]:
  54.         if "post_hint" in post["data"] and post["data"]["post_hint"] == "image":
  55.             image_links.append(post["data"]["url"])
  56.  
  57.     while len(image_links) < int(limit) and data["data"]["after"]:
  58.         after = data["data"]["after"]
  59.         response = requests.get(f"https://www.reddit.com/r/{search_term}/.json?limit={limit}&after={after}", headers=headers)
  60.         data = response.json()
  61.         for post in data["data"]["children"]:
  62.             if "post_hint" in post["data"] and post["data"]["post_hint"] == "image":
  63.                 image_links.append(post["data"]["url"])
  64.  
  65.     with concurrent.futures.ThreadPoolExecutor() as executor:
  66.         futures = []
  67.         for image_link in image_links[:int(limit)]:
  68.             futures.append(executor.submit(download_image, image_link, folder_name))
  69.         for future in tqdm(concurrent.futures.as_completed(futures), total=len(futures), desc="Downloading images"):
  70.             try:
  71.                 future.result()
  72.             except Exception as e:
  73.                 logger.exception(f"Error while downloading image: {e}")
  74.  
  75.     logger.info("All images downloaded to: %s", folder_name)
  76.  
  77. def validate_folder_name(folder_name):
  78.     folder_name = &#39;&#39;.join(c for c in folder_name if c.isalnum() or c in [&#39;-&#39;, &#39;_&#39;])
  79.     return folder_name
  80.  
  81. def validate_limit(limit):
  82.     try:
  83.         limit = int(limit)
  84.         if limit <= 0:
  85.             raise ValueError()
  86.     except ValueError:
  87.         logger.warning("Invalid limit value. Using default limit of 10.")
  88.         limit = 10
  89.     return limit
  90.  
  91. def parse_arguments():
  92.     parser = argparse.ArgumentParser(description="Reddit Image Downloader")
  93.     parser.add_argument("search_term", nargs="?", type=str, help="Enter the search term")
  94.     parser.add_argument("folder_name", nargs="?", type=str, help="Enter the folder name")
  95.     parser.add_argument("--limit", type=str, help="Enter the number of images to download (default: 10)")
  96.     return parser.parse_args()
  97.  
  98. def main():
  99.     args = parse_arguments()
  100.     if not args.search_term:
  101.         search_term = input("Enter the search term: ").replace(" ", "")
  102.     else:
  103.         search_term = args.search_term.replace(" ", "")
  104.  
  105.     if not args.folder_name:
  106.         folder_name = input("Enter the folder name: ")
  107.     else:
  108.         folder_name = validate_folder_name(args.folder_name)
  109.  
  110.     if not args.limit:
  111.         limit = input("Enter the number of images to download: ")
  112.     else:
  113.         limit = validate_limit(args.limit)
  114.  
  115.     download_images(search_term, folder_name, limit)
  116.  
  117. if __name__ == "__main__":
  118.     main()


Mint Green Pink Entertainment Pixel Art Discord Profile Banner.gif
« Last Edit: June 02, 2023, 01:14 PM by KynloStephen66515 »

KynloStephen66515

  • Animated Giffer in Chief
  • Honorary Member
  • Joined in 2010
  • **
  • Posts: 3,742
    • View Profile
    • Donate to Member
Re: [Pre-Release] Reddit Image Downloader
« Reply #1 on: June 21, 2023, 08:41 AM »
This probably won't work with the new API changes that Reddit are forcing down people's throats. So, if it doesn't work, blame them, not me  >:( ;D

rgdot

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 2,193
    • View Profile
    • Donate to Member
Re: [Pre-Release] Reddit Image Downloader
« Reply #2 on: June 24, 2023, 02:27 PM »
This probably won't work with the new API changes that Reddit are forcing down people's throats. So, if it doesn't work, blame them, not me  >:( ;D
-KynloStephen66515 (June 21, 2023, 08:41 AM)

When will you process my refund?

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,643
    • View Profile
    • Donate to Member
Re: [Pre-Release] Reddit Image Downloader
« Reply #3 on: June 25, 2023, 07:52 AM »
This probably won't work with the new API changes that Reddit are forcing down people's throats. So, if it doesn't work, blame them, not me  >:( ;D
-KynloStephen66515 (June 21, 2023, 08:41 AM)

Thanks for reminding me to bulk download the three sub-reddits I'm interested in for images :up:

kunkel321

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 597
    • View Profile
    • Donate to Member
Re: [Pre-Release] Reddit Image Downloader
« Reply #4 on: August 26, 2023, 08:53 AM »
Does anyone know if this still works with the Reddit changes?

Tuxman

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 2,481
    • View Profile
    • Donate to Member
Re: [Pre-Release] Reddit Image Downloader
« Reply #5 on: August 26, 2023, 06:59 PM »
What can this tool do that Hydrus Network can't?

KynloStephen66515

  • Animated Giffer in Chief
  • Honorary Member
  • Joined in 2010
  • **
  • Posts: 3,742
    • View Profile
    • Donate to Member
Re: [Pre-Release] Reddit Image Downloader
« Reply #6 on: August 31, 2023, 05:16 PM »
What can this tool do that Hydrus Network can't?

Literally no idea because I have no idea what that is.  I made this out of sheer boredom, used it like 5 times, uploaded it here then Reddit did stuff and I gave up caring about it  8)

Tuxman

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 2,481
    • View Profile
    • Donate to Member
Re: [Pre-Release] Reddit Image Downloader
« Reply #7 on: August 31, 2023, 05:34 PM »