A Python wrapper for the PornPics.com website.
Project description
PornPics Python Wrapper
An unofficial, developer-friendly Python wrapper for the PornPics website. It provides a clean, high-level interface for fetching galleries, categories, and search results, with both synchronous and asynchronous clients.
Features
- Simple & Clean: A straightforward and easy-to-use API.
- Sync & Async: Provides both
Client(for synchronous code) andAsyncClient(forasyncioapplications). - Type-Hinted: Fully type-hinted for a better developer experience with tools like MyPy and modern IDEs.
- Data Models: Uses Pydantic models for robust and clear data representation.
- No API Key Needed: Interacts with the website directly, so no API key is required.
Installation
Install the package from PyPI using pip:
pip install pornpics
Quick Start
Synchronous Client
Here's a simple example of how to use the synchronous Client:
from pornpics import Client
# Initialize the client
client = Client()
# 1. Get the homepage to discover categories and tags
print("--- Fetching Homepage ---")
homepage_items = client.get_home()
for item in homepage_items:
print(f"Found {item.type}: {item.name} -> {item.link}")
# 2. Search for galleries
print("\n--- Searching for 'amateur' ---")
search_results = client.search("amateur")
if search_results.galleries:
print(f"Found {search_results.total_galleries} galleries.")
for gallery in search_results.galleries:
print(f"- {gallery.title} ({len(gallery.images)} images)")
# 3. Fetch a specific gallery from the search results
first_gallery_slug = search_results.galleries[0].slug
print(f"\n--- Fetching gallery: {first_gallery_slug} ---")
gallery_details = client.get_gallery(first_gallery_slug)
print(f"Title: {gallery_details.title}")
print(f"Tags: {gallery_details.tags}")
print(f"Image URLs: {[img.url for img in gallery_details.images]}")
# 4. Fetch a category page
print("\n--- Fetching category 'teen' ---")
category_page = client.get_category("teen") # 'teen' is the slug
print(f"Category has {category_page.total_galleries} galleries.")
for gallery in category_page.galleries:
print(f"- {gallery.title}")
Asynchronous Client
The AsyncClient provides the same functionality but with async/await syntax.
import asyncio
from pornpics import AsyncClient
async def main():
# Initialize the async client
client = AsyncClient()
# Search for galleries asynchronously
print("--- Searching for 'ebony' (async) ---")
search_results = await client.search("ebony")
if search_results.galleries:
print(f"Found {search_results.total_galleries} galleries.")
# Fetch the first gallery
first_gallery_slug = search_results.galleries[0].slug
gallery_details = await client.get_gallery(first_gallery_slug)
print(f"Fetched gallery: {gallery_details.title}")
if __name__ == "__main__":
asyncio.run(main())
API Reference
Client and AsyncClient
Both clients provide the same methods. The only difference is that AsyncClient methods are coroutines and must be awaited.
get_home(): Fetches the homepage and returns a list of featuredHomeMediaobjects (tags and categories).search(query, lang="en", offset=0, limit=0): Performs a search. Returns aSearchResponseobject containing a list ofGallerypreviews.get_gallery(slug): Fetches a single, detailed gallery by its URL slug. Returns aGalleryResponseobject with full-resolution image URLs and metadata.get_category(slug, offset=0, limit=20): Fetches a category or tag page by its slug. Returns aCategoryResponseobject containing a paginated list ofGallerypreviews.
Data Models
The wrapper uses Pydantic models to structure the returned data. Key models include:
GalleryResponse: A full gallery with title, tags, and a list ofImageobjects.CategoryResponse: A category page with total gallery count and a list ofGallerypreviews.SearchResponse: Search results with total gallery count and a list ofGallerypreviews.HomeMedia: An item from the homepage, representing a tag or category.Gallery: A gallery preview, typically found in search or category listings.Image: A single image with its URL and thumbnail URL.
Future Enhancements
Support for proxies, cookies, and custom headers is planned for a future release. The architecture is designed to easily accommodate these features by extending the Client and AsyncClient constructors.
Disclaimer
This is an unofficial wrapper and is not affiliated with, endorsed, or sponsored by PornPics. Please use it responsibly.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pornpics-0.1.0.tar.gz.
File metadata
- Download URL: pornpics-0.1.0.tar.gz
- Upload date:
- Size: 11.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eba6cac9aba285373b8b4778df69737a4ae503db396eb03eb568c1e0151092e2
|
|
| MD5 |
9f7942853e59455810ac90e61b0fa1c9
|
|
| BLAKE2b-256 |
8778cc1eccd0e2e4fc9823230432a37ffb210be35813351666f0b31e6078b742
|
File details
Details for the file pornpics-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pornpics-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00eccd09ffedb9b138e8373dc18b61b36ecc3bc8b7be23bf0652ef8fdd1cf934
|
|
| MD5 |
2b2be06d090ac18f521b2331a566b493
|
|
| BLAKE2b-256 |
03547d914cde060fb6777a3f048680cfe676d1b29e6271cf559b06fc5d91f721
|