Skip to main content

libgentools

A Python library for downloading content from Library Genesis.

The library serves as a backend for libgenx, a GUI/CLI application for using LibGen, but it is available for implementation in any other Python project as well.

Developers are welcome to fork this repository.

Contents:

Installation

It is always recommended to use a Python environment manager, like pipenv: pipenv install libgentools

But it is also possible to install the package system-wide: pip install libgentools

Requirements

Usage

After installing from pip, import the library to your Python script:

import libgentools

or

from libgentools import SearchRequest, Results # ...

Classes

SearchRequest

The class handles search requests and generates a list of results.

A new instance can be created with the query parameter. The query should be an author, title (or both) or an ISBN number:

request = SearchRequest('principles of geology')

The request.results variable now holds the search results as a list of Standard Entry Dictionaries (SEDs).

Standard Entry Dictionary:

entries = [{'id': 1234,
            'isbn': ["ISBN", "ISBN"],
            'auth': "Author",
            'title': "Title",
            'pub': "Publisher",
            'year': 1999,
            'pp': "Pages",
            'lang': "Language",
            'size': "Size",
            'ext': "Extension",
            'mirrors': ["url", "url"]}]

A new Results instance can be constructed from the request.results variable:

results = Results(request.results)

Results

The class stores and manages search results.

A new instance can be created from the results variable of a SearchRequest instance:

results = Results(request.results)

The results are now stored in the results.entries variable of the new instance as a list of SEDs.

Filtering

The filter_entries method filters the results using a Standard Filter Dictionary and the filtering mode as parameters.

Standard Filter Dictionary:

filters = {'auth': "Author", 'ext': "Extension", 'year': "1999-2010"}

Every value must be a string! The following fields can be used in the filter:

  • auth: author
  • title: title
  • year: as an interval (e.g. "1999-2010") or exact year (e.g. "2000")
  • lang: use standard language codes
  • ext: use any of the popular formats (e.g. "pdf", "epub", "mobi", etc.)

The FILTERS dictionary can be used to interpret command line arguments in applications.

The second parameter is the filtering mode: "exact" or "partial" (the default is "partial"). The method returns exact or partial matches based on this parameter.

The filtered results are returned by the method as a new Results instance:

filtered_results = results.filter_entries(filters, "exact")
Downloading

Any entry from a list of results (SEDs) can be downloaded using the download method:

downloaded = results.download(entry, dirname(abspath(sys.argv[0])))

The first parameter is the entry (an SED), the second is the path where the file should be downloaded (in this case the location of the script - dirname() and abspath() can be imported from os.path). The name of the downloaded file will be the LibGen ID of the entry. The value of the downloaded variable will be true if the download was successful or false otherwise.

Exceptions

QueryError

The constructor of the SearchRequest class raises this error if the query is empty or its length is less than three characters.

FilterError

The filter_entries method of the Results class raises this error if there is an invalid key in the filtering dictionary (validated by FILTERS) or the year filter has a wrong format.

Reporting errors

Any error can be reported through e-mail with the exact error message and/or console screenshot. Alternatively, an issue can be opened.

Metadata

Release files for libgentools 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for libgentools 0.0.1
File Size Uploaded Provenance
libgentools-0.0.1.tar.gz 18.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for libgentools 0.0.1
File Interpreter ABI Platform
libgentools-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 37.4 kB

Release files / libgentools-0.0.1.tar.gz

Download URL libgentools-0.0.1.tar.gz
Size 18.0 kB
Tags Source
SHA-256 checksum
How to use checksums
3a2cfdcac5b48b8092096270d75b36b7d73be881cc06a9e7099b948f6601c08c
BLAKE2b-256 checksum
How to use checksums
ee9a58bc69127441e420a34d143ad064654f4d2c6b0da7dd928504e442679f30
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.7

Release files / libgentools-0.0.1-py3-none-any.whl

Download URL libgentools-0.0.1-py3-none-any.whl
Size 19.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9373b51cfdd6348ec6c086b3bc0e73ea6285b05add314a1dd99a4415ba816ab3
BLAKE2b-256 checksum
How to use checksums
f5e0876727b535b8c4cdc52c1cdcb152bfe54f4db39ba71f1a0befa9d4710b04
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.7

Security for libgentools 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page