Skip to content

fix: read a country before a left quarter block separator - #69

Merged
PiratesIRC merged 1 commit into
PiratesIRC:mainfrom
dillardblom:fix/country-prefix-left-block-delimiter
Oct 29, 2026
Merged

PiratesIRC merged 1 commit into
PiratesIRC:mainfrom
dillardblom:fix/country-prefix-left-block-delimiter

Conversation

@dillardblom

Copy link
Copy Markdown
Contributor

What this changes

A country written before U+258E LEFT ONE QUARTER BLOCK (NL ▎NEDERLAND HD, BE ▎DISCOVERY CHANNEL HD) is now recognised by the country filter, the same way NL | and ┃NL┃ already are.

Why

One of my providers separates the country from the rest of every group and stream name with ▎ instead of a pipe or a box bar. The character was not in _DELIM, so none of those names produced a country. With Restrict Matching To Same Country on, every such stream came out unknown and was kept, so Belgian and German feeds still landed on Dutch channels.

How it was verified

  • python -m pytest -q passes (1786 passed, 1 skipped: the plugin-stats sibling checkout)
  • A new test was written first and watched to fail before the code was written
  • The new test was confirmed to fail when the code it covers is deliberately broken

The new tests in tests/test_country_detection.py cover NL ▎, BE ▎, DE▎ (no space) and UK ▎, through both country_from_name and country_from_group, plus PPV ▎, UEFA ▎ and MULTI ▎, which must stay unknown. Three of them fail without the change; UK ▎ already passed through the bare-code rule.

On my own group names (343 groups across three providers), the provider that uses ▎ went from 0 groups with a country to 933 streams detected as NL and 153 as BE. What is left unknown there is genuinely country-less (PPV, UEFA, MULTI, FORMULA 1). The other two providers are unchanged.

Anything a reviewer should know

  • ▎ only goes into _DELIM, not into the wrapped form, because it is never used as a pair.
  • Name matching already strips the spaced form: NL ▎RTL 4 HD normalises to RTL 4. The unspaced form DE▎ZDF HD keeps its country token there (DE ZDF), because PROVIDER_PREFIX_PATTERNS in matching_core.py does not list ▎ either. That file is vendored and hash-pinned, so I left it alone. If you want both sides to agree, it would need ▎ in that pattern in _shared/. All the names I have put a space before the character, so I could not test the unspaced case against real data.

  • No provider credentials, stream URLs, M3U account names or server
    addresses appear in the diff, the description, or any attached output.
  • The version was bumped with python scripts/bump_version.py, or
    this change does not need a version bump. (Not bumped; I left that to the release.)

Some providers separate the country from the rest of a group or stream
name with U+258E LEFT ONE QUARTER BLOCK ("NL ▎NEDERLAND HD") instead of
a pipe or a box bar. The character was not in the delimiter set, so
none of those names produced a country. Restrict Matching To Same
Country then treated every such stream as unknown and kept it, which
put Belgian and German feeds on Dutch channels.

Add the character to the token delimiter. It is never used as a pair,
so the wrapped form is unchanged.

Name matching already strips the spaced form ("NL ▎RTL 4" matches as
"RTL 4"). The unspaced form ("DE▎ZDF") keeps its country token there,
but that pattern lives in the vendored matching core, so it is not
changed here.
@PiratesIRC

Copy link
Copy Markdown
Owner

Thanks, this is a clean fix. I ran the full suite locally (1786 passed) and confirmed the three new cases fail without the change. Merging now; it will go out in the next release.

You are right about PROVIDER_PREFIX_PATTERNS in matching_core.py. That file is shared with three other plugins, so I will look at adding the character there separately.

@PiratesIRC
PiratesIRC merged commit 676c626 into PiratesIRC:main Oct 29, 2026
PiratesIRC added a commit that referenced this pull request Oct 29, 2026
pytest 9.2.0 undoes monkeypatch.setattr(<MagicMock>, "objects", ...) by
deleting the attribute, so every later test that read
ChannelProfileMembership.objects on the shared stub failed (9 tests, CI on
main since the PR #69 merge). Patch the module attribute with a fresh
MagicMock instead; undoing that restores the shared stub untouched.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Q5fkaJ73nXCNUcFxJTvQm
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