{"id":17477702,"url":"https://github.com/samfun75/libgenesis","last_synced_at":"2025-04-22T10:43:15.875Z","repository":{"id":42064125,"uuid":"334930211","full_name":"Samfun75/libgenesis","owner":"Samfun75","description":"Asynchronous python library for Libgen.rs to search and download books.","archived":false,"fork":false,"pushed_at":"2022-04-14T13:30:39.000Z","size":69,"stargazers_count":10,"open_issues_count":1,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-22T10:43:14.284Z","etag":null,"topics":["async","asynchronous-python-library","book","download","libgen","python","search"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Samfun75.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-01T11:39:31.000Z","updated_at":"2024-03-04T20:23:04.000Z","dependencies_parsed_at":"2022-08-12T03:50:36.451Z","dependency_job_id":null,"html_url":"https://github.com/Samfun75/libgenesis","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Samfun75%2Flibgenesis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Samfun75%2Flibgenesis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Samfun75%2Flibgenesis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Samfun75%2Flibgenesis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Samfun75","download_url":"https://codeload.github.com/Samfun75/libgenesis/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250222342,"owners_count":21394854,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["async","asynchronous-python-library","book","download","libgen","python","search"],"created_at":"2024-10-18T20:09:03.225Z","updated_at":"2025-04-22T10:43:15.839Z","avatar_url":"https://github.com/Samfun75.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# libgenesis\n\nAsynchronous python library for Libgen.rs to search and download books.\n\n[![PyPI version](https://badge.fury.io/py/libgenesis.svg)](https://pypi.org/project/libgenesis)\n[![Build Python Package](https://github.com/Samfun75/libgenesis/actions/workflows/python-publish.yml/badge.svg)](https://github.com/Samfun75/libgenesis/actions/workflows/python-publish.yml)\n\n### [Bookdlbot](https://github.com/Samfun75/BookdlBot) Async telegram bot utilizing this library\n\n## Installing libgenesis\n\nusing the command line\n\n```python\npip install libgenesis\n```\n\n## Importing libgenesis\n\n```python\nfrom libgenesis import Libgen\n```\n\n## Creating libgenesis object\n\n```python\nlg = Libgen()\n```\n\nor\n\n```python\nlg = Libgen(sort= 'year', sort_mode= 'ASC', result_limit= '50')\n```\n\nWhen creating an instance of LibGen, you can set 3 option.\n\n- **sort**: You can use this to choose a sorting method from allowed fields ( 'id', 'author', 'title', 'publisher', 'year', 'pages', 'language', 'size', 'extension'). Defaults to 'def'.\n- **sort_mode**: Pick the order of the sort ascending or decending ('ASC', 'DESC'). Defaults to 'DESC'.\n- **result_limit**: Limit the number of results based on the allowed limit (25, 50, 100). Defaults to 25.\n\n## Searching for a book\n\n```python\nasync def search():\n    q = 'japan history'\n    result = await lg.search(q)\n    for item in result:\n        print('id = ' + item)\n        print('title = ' + result[item]['title'])\n        print('md5 = ' + result[item]['md5'])\n```\n\nThe returned data looks like this: (The dict key is the Libgen id of the book)\n\n```python\n{\n    '881061':{\n        'title': 'The Japanese Experience: A Short History of Japan (History of Civilisation)',\n        'volumeinfo': '',\n        'series': '',\n        'periodical': '',\n        'author': 'W. G. Beasley',\n        'year': '1999',\n        'edition': '',\n        'publisher': 'University of California Press',\n        'city': '',\n        'pages': '331',\n        'language': 'English',\n        'topic': '',\n        'library': '',\n        'issue': '0',\n        'identifier': '0520220501, 9780520220508',\n        'issn': '',\n        'asin': '',\n        'udc': '',\n        'lbc': '',\n        'ddc': '',\n        'lcc': '',\n        'doi': '',\n        'googlebookid': '',\n        'openlibraryid': '',\n        'commentary': '',\n        'dpi': '0',\n        'color': '',\n        'cleaned': '',\n        'orientation': '',\n        'paginated': '',\n        'scanned': '',\n        'bookmarked': '',\n        'searchable': '1',\n        'filesize': '29750320',\n        'extension': 'pdf',\n        'md5': 'a382109f7fdde3be5b2cb4f82d97443b',\n        'generic': '',\n        'visible': '',\n        'local': '0',\n        'timeadded': '2013-02-15 18:40:21',\n        'timelastmodified': '2019-12-21 21:23:21',\n        'coverurl': 'http://libgen.rs/covers/881000/a382109f7fdde3be5b2cb4f82d97443b-g.jpg',\n        'identifierwodash': '0520220501,9780520220508',\n        'tags': '',\n        'pagesinfile': '331',\n        'descr': '',\n        'toc': '',\n        'sha1': 'ZZYRRG56BOX3XAQ5D2IWAV2FUUC35ELG',\n        'sha256': '3B40D6524409A18573900B729AB1BFB872E26CF111A4845F375A84BD0CB12460',\n        'crc32': '3DB84D01',\n        'edonkey': 'A63EEBB71C46DAE130725C07F2CDC67C',\n        'aich': '733CLKTMCYOGD4W5PIG2GMA7CMLAFN2V',\n        'tth': 'O4O5Z7UL2YAOUG57PINCLOAN63HVZPCSDYACT6Q',\n        'btih': '84195af51fa738cb232297dd1376df6d8b8313be',\n        'mirrors':\n            {\n                'main': 'http://library.lol/main/a382109f7fdde3be5b2cb4f82d97443b',\n                'libgen.lc': 'http://libgen.lc/ads.php?md5=a382109f7fdde3be5b2cb4f82d97443b',\n                'z-library': 'http://b-ok.cc/md5/a382109f7fdde3be5b2cb4f82d97443b',\n                'libgen.pw': 'https://libgen.pw/item?id=881061',\n                'bookfi': 'http://bookfi.net/md5/a382109f7fdde3be5b2cb4f82d97443b',\n                'torrent': 'http://libgen.rs/book/index.php?md5=a382109f7fdde3be5b2cb4f82d97443b\u0026oftorrent=',\n                'torrent_1k': 'http://libgen.rs/repository_torrent/r_881000.torrent',\n                'gnutella': 'magnet:?xt=urn:sha1:ZZYRRG56BOX3XAQ5D2IWAV2FUUC35ELG\u0026xl=29750320\u0026dn=a382109f7fdde3be5b2cb4f82d97443b.pdf',\n                'ed2k': 'ed2k://|file|A382109F7FDDE3BE5B2CB4F82D97443B.pdf|29750320|A63EEBB71C46DAE130725C07F2CDC67C|h=733CLKTMCYOGD4W5PIG2GMA7CMLAFN2V|/',\n                'dc++': 'magnet:?xt=urn:tree:tiger:O4O5Z7UL2YAOUG57PINCLOAN63HVZPCSDYACT6Q\u0026xl=29750320\u0026dn=a382109f7fdde3be5b2cb4f82d97443b.pdf'\n            }\n    },\n    'id_of_book':{\n        ...\n        ...\n        ...\n    },\n    'id_of_book':{\n        ...\n        ...\n        ...\n    },\n}\n```\n\nNote that the above information except for mirrors is fecthed as is from Libgen and it is up to the uploader of the books to include the metadata of the books.\n\n## Downloading a book\n\nDownloading is only supported for the top **3** mirrors in the returned result ('main', 'libgen.lc', 'z-library'). Pass one of the 3 links to the download method of the Libgen object. Optionaly a destination Path can be passed with the url using **dest_folder** argument. The output of the download method is a Path to the downloaded file.\n\n```python\nasync def download():\n    q = 'japan history'\n    result = await lg.search(q)\n    download_location = []\n    path = Path('Downloads')\n    for item in result:\n        file_path = await lg.download(result[item]['mirrors']['main'],\n                                      dest_folder=path,\n                                      progress=progress,\n                                      progress_args=[\n                                          result[item]['title']\n                                      ])\n        download_location.append(file_path)\n\nasync def progress(current, total, title):\n    print('Downloading ', current, ' of ', total, ' ', title)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamfun75%2Flibgenesis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamfun75%2Flibgenesis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamfun75%2Flibgenesis/lists"}