Skip to content

Vaproh/wallhaven.py

Repository files navigation

WALLHAVEN.PY-logo

WALLHAVEN.PY

Your wallpaper, your way, API-powered.

license last-commit repo-top-language repo-language-count

Built with the tools and technologies:

Python


Table of Contents

Overview

Wallhaven.py is a Python library designed to simplify interactions with the Wallhaven API. It provides a user-friendly interface for searching and retrieving high-resolution wallpapers, accessing user collections, and fetching random images. The library handles API requests, error handling, and JSON parsing, allowing developers to easily integrate Wallhavens vast library of wallpapers into their applications. Whether youre building a wallpaper management tool, a desktop background changer, or a creative project that requires high-quality imagery, Wallhaven.py offers a robust and efficient solution for accessing Wallhaven's extensive collection.


Features

Feature Description
⚙️ Architecture The project utilizes a class-based architecture with a WallhavenPY class encapsulating API interactions. It leverages external libraries for HTTP requests and JSON parsing.
🔩 Code Quality The codebase demonstrates good readability and follows Python conventions. It includes clear variable names and comments, enhancing maintainability.
📄 Documentation The repository includes basic documentation within the code itself, explaining the purpose of each file and key functions. However, more comprehensive documentation would be beneficial.
🔌 Integrations The project integrates with the Wallhaven API for retrieving wallpaper data. It utilizes external libraries like requests for HTTP requests and urllib3 for secure communication.
🧩 Modularity The codebase is modular, with the WallhavenPY class encapsulating API interactions. This allows for easy reuse and extension of the functionality.
🧪 Testing The project includes a test suite (test_wallhaven.py) that utilizes mocking to validate API interactions and error handling.
⚡️ Performance The project's performance is likely dependent on the Wallhaven API's response time and network conditions. The codebase itself appears optimized for efficient API interactions.
🛡️ Security The project relies on the security measures provided by the urllib3 library for secure communication. However, it's important to note that the API key should be handled securely to prevent unauthorized access.
📦 Dependencies Key dependencies include requests, urllib3, certifi, idna, and charset-normalizer. These libraries provide essential functionalities for HTTP requests, secure communication, and character encoding.
🚀 Scalability The project's scalability depends on the Wallhaven API's rate limits and the ability to handle increased traffic. The codebase itself appears well-structured for potential future scaling.

Repository Structure

└── wallhaven.py/
    ├── errors.py
    ├── requirements.txt
    ├── test_wallhaven.py
    ├── usage.py
    └── wallhaven.py

Modules

.
File Summary
errors.py The errors.py file defines a custom exception class named WallhavenAPIError. This exception is used to handle errors that occur when interacting with the Wallhaven API, providing a clear and specific way to manage API-related issues within the repositorys architecture.
requirements.txt The requirements.txt file specifies the external Python libraries necessary for the Wallhaven API client to function correctly. These libraries provide essential functionalities like HTTP requests, URL parsing, and secure communication, enabling the client to interact with the Wallhaven API effectively.
test_wallhaven.py This test suite thoroughly validates the functionality of the WallhavenPY class, ensuring its ability to handle successful API requests, various error scenarios, and specific search operations. It leverages mocking to simulate API responses and exceptions, guaranteeing robust and reliable interactions with the Wallhaven API.
usage.py The usage.py file demonstrates the basic usage of the WallhavenPY class within the wallhaven.py repository. It showcases how to initialize the client, retrieve collections data, and perform searches with various parameters.
wallhaven.py The wallhaven.py file provides a Python client for interacting with the Wallhaven API. It offers methods for searching wallpapers, retrieving wallpaper details, accessing user collections, and fetching random wallpapers. The client handles API requests, error handling, and JSON parsing, simplifying interactions with the Wallhaven API.

Getting Started

Prerequisites

Python: version 3.12.5

Installation

Build the project from source:

  1. Clone the wallhaven.py repository:
❯ git clone https://git.vaproh.xyz/vaproh/wallhaven.py
  1. Navigate to the project directory:
cd wallhaven.py
  1. Create an virtual envirourment:
❯ python -m venv .venv 
  1. Install the required dependencies:
❯ pip install -r requirements.txt

Usage

To run the project, execute the following command:

❯ python main.py

Tests

Execute the test suite using the following command:

❯ python -m unittest discover

Project Roadmap

  • Task 1: Make it more secure?

Contributing

Contributions are welcome! Here are several ways you can contribute:

Contributing Guidelines
  1. Fork the Repository: Start by forking the project repository to your git account.
  2. Clone Locally: Clone the forked repository to your local machine using a git client.
    git clone https://git.vaproh.xyz/vaproh/wallhaven.py
  3. Create a New Branch: Always work on a new branch, giving it a descriptive name.
    git checkout -b new-feature-x
  4. Make Your Changes: Develop and test your changes locally.
  5. Commit Your Changes: Commit with a clear message describing your updates.
    git commit -m 'Implemented new feature x.'
  6. Push to git: Push the changes to your forked repository.
    git push origin new-feature-x
  7. Submit a Pull Request: Create a PR against the original project repository. Clearly describe the changes and their motivations.
  8. Review: Once your PR is reviewed and approved, it will be merged into the main branch. Congratulations on your contribution!

License

This project is protected under the GNU GPL License. For more details, refer to the LICENSE file.


Acknowledgments

  • Thanks to this Article for guiding me.