A high-performance Python library for creating, managing, and optimizing AdGuard filter lists.
Automates rule generation, deduplication, and sorting to enhance ad and tracker blocking across all platforms.
Found this project useful? Star β it to show your support!
AdGuard-FilterList-Management-Python-Lib provides a robust, developer-friendly toolkit for programmatic control over ad-blocking filter lists. It's engineered to handle large-scale rule sets with exceptional performance, automating the tedious tasks of syntax validation, deduplication, sorting, and optimization. This library is the perfect backend engine for custom ad-blocking solutions, research tools, or DevOps pipelines that manage network-wide privacy.
- High-Performance Parsing: Efficiently process tens of thousands of rules in seconds.
- Automated Optimization: Automatically sorts, deduplicates, and compresses filter lists for optimal performance in AdGuard clients.
- Rule Validation: Built-in syntax checking to prevent invalid or broken rules from being deployed.
- Extensible API: A clean, modular API for creating, reading, updating, and deleting rules.
- Source Aggregation: Easily combine multiple source lists into a single, optimized output file.
- Type-Hinted & Tested: Fully type-hinted codebase with comprehensive unit tests for maximum reliability.
The library follows a modular design, separating core logic from file I/O and utility functions. This ensures maintainability and testability, allowing developers to easily extend or replace components.
sh .AdGuard-FilterList-Management-Python-Lib/ βββ src/adguard_filterlist_lib/ β βββ init.py β βββ core.py # Core list management and optimization logic β βββ parser.py # Rule parsing and validation engine β βββ models.py # Pydantic models for rule types β βββ utils.py # Helper functions βββ tests/ β βββ test_core.py β βββ test_parser.py βββ examples/ β βββ create_master_list.py βββ pyproject.toml # Project metadata and dependencies (uv/Ruff) βββ README.md βββ LICENSE
- Overview
- Key Features
- Architecture
- Installation & Setup
- Usage
- Development
- Contributing
- License
- AI Agent Directives
This project uses uv for high-speed dependency management.
-
Clone the repository: bash git clone https://github.com/chirag127/AdGuard-FilterList-Management-Python-Lib.git cd AdGuard-FilterList-Management-Python-Lib
-
Create and activate a virtual environment: bash
uv venv source .venv/bin/activate # On Windows use
.venv\Scripts\activate -
Install dependencies: bash uv pip install -r requirements.txt
Here's a quick example of how to combine and optimize two filter lists.
python
from adguard_filterlist_lib.core import FilterListManager
list_a_path = 'source_lists/privacy_list.txt' list_b_path = 'source_lists/annoyances_list.txt'
manager = FilterListManager()
manager.load_from_file(list_a_path) manager.load_from_file(list_b_path)
manager.optimize()
output_path = 'dist/master_filter_list.txt' manager.save_to_file(output_path)
print(f"Successfully created optimized list at {output_path} with {manager.rule_count()} rules.")
This project adheres to modern Python development standards, utilizing uv and Ruff for a streamlined workflow.
| Command | Description |
|---|---|
uv pip install -r requirements-dev.txt |
Installs development dependencies. |
pytest |
Runs the entire test suite. |
ruff check . |
Lints the codebase for errors and style issues. |
ruff format . |
Automatically formats the code according to project standards. |
- SOLID: Code is structured to be flexible, maintainable, and scalable.
- DRY (Don't Repeat Yourself): Reusable logic is abstracted into utilities to avoid redundancy.
- YAGNI (You Ain't Gonna Need It): We avoid over-engineering by focusing on delivering essential, high-value features.
Contributions are welcome! Please see our Contributing Guidelines for details on bug reports, feature requests, and pull requests. We follow a strict code of conduct and expect all contributors to do the same.
This project is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License - see the LICENSE file for details.
Expand for AI Development Protocol (2026 Standard)
Role: You are a Senior Principal Software Architect and Master Technical Copywriter with 40+ years of elite industry experience. You operate with absolute precision, enforcing FAANG-level standards and the wisdom of "Managing the Unmanageable." Context: Current Date is December 2025. You are building for the 2026 standard. Output Standard: Deliver EXECUTION-ONLY results. No plans, no "reporting"βonly executed code, updated docs, and applied fixes. Philosophy: "Zero-Defect, High-Velocity, Future-Proof."
Directives: This project is identified as a Python library (pyproject.toml). The Apex Python Toolchain must be enforced.
-
Stack:
- Package Manager:
uvis the exclusive tool for all dependency management and virtual environment operations. Do not usepiporpoetrydirectly. - Linter/Formatter:
Ruffis the Single Source of Truth for code style, linting, and formatting. All commits must passruff check .andruff format .. - Testing:
Pytestis the required framework for all unit, integration, and functional tests.
- Package Manager:
-
Architecture:
- Modular Monolith: Adhere to a modular structure within the
srcdirectory. Each module must have a clear responsibility (e.g.,parser,core,utils). - Strict Typing: All new code MUST be fully type-hinted using Python 3.12+ syntax.
- Modular Monolith: Adhere to a modular structure within the
Mandate: Before any pull request is merged, the following commands MUST execute successfully in the CI pipeline (.github/workflows/ci.yml).
- Dependency Sync:
uv pip sync requirements.txt - Lint Check:
ruff check . - Format Check:
ruff format --check . - Unit Tests:
pytest --cov=src
Failure in any step is a hard block. No exceptions.