Skip to content

Conversation

@Coffelius
Copy link
Collaborator

Allow navigation between different sections, each representing a filter or sorting mechanism, using the left and right arrow keys.

@Coffelius Coffelius marked this pull request as draft January 30, 2025 22:57
@Coffelius Coffelius requested a review from Sam-Max January 30, 2025 22:57
@Coffelius
Copy link
Collaborator Author

Some components have been added:

1. Enrichers (Metadata Enhancers)

Enrichers add or modify metadata in items (dictionaries) based on specific patterns in their data.

  • Base Class: Enricher
    • Abstract class requiring implementation of enrich(item: Dict).
    • Subclasses:
      • LanguageEnricher: Detects languages from emoji flags/keywords in descriptions.
      • StatsEnricher: Extracts size, seeders, and provider info from descriptions.
      • QualityEnricher: Determines video quality (4K, 1080p, etc.) from titles.
      • IsPackEnricher: Identifies multi-episode/seasons packs using regex patterns.

2. EnricherBuilder

Orchestrates the sequential application of enrichers to a list of items.

  • Workflow:
    1. Initialize with a list of items.
    2. Chain enrichers using add().
    3. build() processes items through all enrichers.

3. FilterBuilder

Applies filters, sorting, and limits to refine processed items.

  • Capabilities:
    • Filtering: By language, episode/season, duplicates, and data sources.
    • Sorting: By multiple fields (numeric/string, ascending/descending).
    • Limiting: Return top N results.

How It Works: Example Scenario

Goal: Process torrent items to:

  1. Enrich with languages, quality, and pack detection.
  2. Filter English episodes of S02E05, sort by seeders, limit to 10.
# Sample Items
items = [
    {"title": "Show.Name.S02E05.1080p", "description": "👤 150 🌐 ProviderA 🇺🇸"},
    {"title": "Show.Name.Complete.S02", "description": "👤 80 🇬🇧"}
]

# 1. Enrichment Pipeline
enriched = (
    EnricherBuilder(items)
    .add(LanguageEnricher(language_map={"🇺🇸": "en"}, keywords={"english"}))
    .add(QualityEnricher())
    .add(IsPackEnricher(season_number=2))
    .add(StatsEnricher(size_converter=some_size_function))
    .build()
)

# 2. Filtering/Sorting
filtered = (
    FilterBuilder(enriched)
    .filter_by_language("en")
    .filter_by_episode(episode_name="", episode_num=5, season_num=2)
    .filter_by_source()  # Ensure items have infoHash/guid
    .sort_by("seeders", ascending=False)
    .sort_by("quality_sort")  # Secondary sort
    .limit(10)
    .build()
)

Output:

[
    {
        "title": "Show.Name.S02E05.1080p",
        "languages": ["en"],
        "quality": "[B][COLOR blue]1080p[/COLOR][/B]",
        "isPack": False,
        "seeders": 150,
        "size": "5.2 GB",
        "provider": "ProviderA"
    }
]

@Coffelius Coffelius changed the title Experimenting with sections in source select window Select source screen: quick filter switching, compact skin with collapsable sidebar Feb 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants