{"id":48242702,"url":"https://github.com/botsarefuture/blacklistfetcher","last_synced_at":"2026-04-04T20:20:15.335Z","repository":{"id":267772675,"uuid":"902307125","full_name":"botsarefuture/blacklistfetcher","owner":"botsarefuture","description":null,"archived":false,"fork":false,"pushed_at":"2025-11-30T15:52:32.000Z","size":24,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-02T22:48:06.425Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/botsarefuture.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-12-12T10:08:03.000Z","updated_at":"2025-11-30T15:52:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"c6cc22d2-4a07-4e9f-a1bb-5695b882d249","html_url":"https://github.com/botsarefuture/blacklistfetcher","commit_stats":null,"previous_names":["botsarefuture/blacklistfetcher"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/botsarefuture/blacklistfetcher","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/botsarefuture%2Fblacklistfetcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/botsarefuture%2Fblacklistfetcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/botsarefuture%2Fblacklistfetcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/botsarefuture%2Fblacklistfetcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/botsarefuture","download_url":"https://codeload.github.com/botsarefuture/blacklistfetcher/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/botsarefuture%2Fblacklistfetcher/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31412480,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-04T20:09:54.854Z","status":"ssl_error","status_checked_at":"2026-04-04T20:09:44.350Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2026-04-04T20:20:14.886Z","updated_at":"2026-04-04T20:20:15.317Z","avatar_url":"https://github.com/botsarefuture.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `BlacklistFetcher` Library Documentation\n\nThe `BlacklistFetcher` library provides a simple and efficient way to fetch and parse IP addresses from a blacklist API. It supports both synchronous and asynchronous environments, making it versatile for different applications. This library abstracts the complexity of handling asynchronous operations, allowing you to work with blacklist data in a straightforward manner.\n\n## Installation\n\nTo use the `BlacklistFetcher` library, you can install it via pip:\n\n```bash\npip install git+https://github.com/botsarefuture/blacklistfetcher.git\n```\n\n---\n\n## Class: `BlacklistFetcher`\n\nThe `BlacklistFetcher` class is designed to fetch and parse blacklist data from a specified URL. It automatically adapts to both asynchronous and synchronous contexts, allowing you to use it in different environments without additional setup.\n\n### Methods\n\n#### `__init__(self, url='https://core.security.luova.club/api/blacklist?text=1')`\nInitializes the `BlacklistFetcher` instance with a given URL for fetching the blacklist data.\n\n- **Parameters**:\n  - `url` (`str`): The URL from which the blacklist will be fetched. Defaults to `https://core.security.luova.club/api/blacklist?text=1`.\n\n#### `_fetch_blacklist(self, session)`\nAsynchronously fetches the raw blacklist data from the specified URL.\n\n- **Parameters**:\n  - `session` (`aiohttp.ClientSession`): The session used for making the HTTP request.\n  \n- **Returns**:\n  - `str`: The raw blacklist data as a string.\n\n#### `_parse_blacklist(data)`\nParses the raw blacklist data (newline-separated IP addresses) into a list of IP addresses.\n\n- **Parameters**:\n  - `data` (`str`): The raw data fetched from the blacklist API.\n  \n- **Returns**:\n  - `list`: A list of IP addresses parsed from the raw data.\n\n#### `_get_blacklist_ips_async(self)`\nAsynchronously fetches and parses the blacklist data, returning a list of IP addresses.\n\n- **Returns**:\n  - `list`: A list of IP addresses from the blacklist.\n\n#### `get_blacklist_ips(self)`\nThis method adapts to both synchronous and asynchronous contexts. If an active event loop is detected, it runs asynchronously; otherwise, it executes the asynchronous function synchronously using `asyncio.run()`.\n\n- **Returns**:\n  - `list`: A list of IP addresses from the blacklist.\n\n- **Notes**:\n  - If no event loop is detected, the method will run the asynchronous function synchronously using `asyncio.run()`.\n  - If an event loop is already running, it will use the existing loop to fetch the data asynchronously.\n\n---\n\n## Example Usage\n\n#### 1. Using the Library in a Synchronous Context\n\n```python\nfrom bl import BlacklistFetcher\n\ndef fetch_ips_sync():\n    fetcher = BlacklistFetcher()\n    ips = fetcher.get_blacklist_ips()  # This fetches synchronously\n    return ips\n\nif __name__ == \"__main__\":\n    ips = fetch_ips_sync()\n    for ip in ips:\n        print(ip)\n```\n\n#### 2. Using the Library in an Asynchronous Context\n\n```python\nimport asyncio\nfrom bl import BlacklistFetcher\n\nasync def async_example():\n    fetcher = BlacklistFetcher()\n    ips = await fetcher.get_blacklist_ips()  # This fetches asynchronously\n    for ip in ips:\n        print(ip)\n\nasyncio.run(async_example())\n```\n\n#### Notes for Synchronous Use:\n- `asyncio.run()` is used to start the event loop, making it suitable for calling asynchronous code from a synchronous function.\n- Avoid using `asyncio.run()` multiple times in the same process. It should only be called once per program to prevent creating multiple event loops.\n\n---\n\n### Additional Notes:\n\n- Ensure that `aiohttp` is installed before using the library. Install it via:\n  ```bash\n  pip install aiohttp\n  ```\n- The default URL for fetching the blacklist is `https://core.security.luova.club/api/blacklist?text=1`, but it can be customized by specifying a different URL when initializing the `BlacklistFetcher`.\n\n---\n\nThe `BlacklistFetcher` library provides a flexible and easy-to-use interface for working with blacklist data. Whether you need it in a synchronous or asynchronous context, this library abstracts the complexity, allowing you to focus on using the data instead of managing asynchronous tasks.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbotsarefuture%2Fblacklistfetcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbotsarefuture%2Fblacklistfetcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbotsarefuture%2Fblacklistfetcher/lists"}