Skip to content

OMEE-Y/wallhavencli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Wallhaven Cli

Wallhaven CLI is a high-performance wallpaper downloader CLI tool built with Java 21 and Project Loom Virtual Threads. It searches wallhaven.cc using user-provided keywords, collects wallpaper pages through native HTML parsing, extracts original image URLs, and downloads wallpapers concurrently with real-time terminal progress tracking.

SnapVid.Net_2MuemyPVhFDazbvN_360p.mp4

Features

  • Keyword Search: Scrape and fetch images using any search term or tag directly from Wallhaven.
  • Project Loom Integration: Leverages lightweight virtual threads via Executors.newVirtualThreadPerTaskExecutor() for high-scalability, non-blocking I/O.
  • Terminal UI: Built with custom ANSI color states, a text-based layout, and real-time terminal progress tracking.
  • No External Dependencies: Pure Java implementation utilizing native Regex-based HTML parsing and standard library network clients (HttpURLConnection).
  • Zero-Crash Flow: Failures, missing images, or timed-out connections on a single wallpaper link won't halt the rest of your download queue.

Tech Stack

  • Language: Java 21+
  • Concurrency: Virtual Threads, ExecutorService, AtomicInteger, CopyOnWriteArrayList
  • Networking: HttpURLConnection, URI
  • Parsing Engine: Native Java Pattern and Matcher (Regex-based)

Usage

• Configure Output Directory

Before compilation, open WallhavenDownloader.java and modify your destination path where you needed the wallpapers :

Path downloadDir = Paths.get("C:\\Users\\konda\\OneDrive\\Desktop\\wallpaper");

• Run the Program

Compile and execute the program directly using your terminal:

# Compile the application
javac WallhavenDownloader.java

# Run the utility
java WallhavenDownloader

• Interactive Walkthrough

Once loaded, follow the interactive interface prompts:

  ❯ Search term  →  anime landscape
  ❯ How many     →  50
  ❯ Threads      →  (default 8, press enter to skip)

Why Virtual Threads?

Traditional multi-threaded applications require allocating heavy operating system (OS) platform threads. When downloading files, those threads spend most of their lifespans sitting idle, waiting for network packets to arrive.

This utility assigns each individual download to a Java Virtual Thread. Virtual threads are context-switched automatically by the JVM onto carrier platform threads during network blockages. This lets you spin up dozens or hundreds of parallel tasks safely and efficiently without excessive memory usage or crashing your OS task manager.

About

Wallhaven CLI is a lightweight, concurrent Java 21 command-line tool designed to scrape and download high-resolution wallpapers from Wallhaven.cc. By leveraging Virtual Threads, it executes non-blocking HTTP requests to fetch pages and images simultaneously. It features a sleek, text-based ANSI user interface with live progress bars.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages