euzu/m3u-filter

Suffix with tag matching nothing render the tag anyway

Closed this issue · 4 comments

kumy commented

Describe the bug
When the captured tag captures nothing, the static mappings.tags[0].prefix and mappings.tags[0].suffix are still rendered.

This is not what has been documented "The special text tag:tag_name is used to append the tag if not empty" https://github.com/euzu/m3u-filter#2344-prefix

To Reproduce
Excerpt from the repo mapping.yml:

mappings:
  templates:
   - name: quality
     value: '[\s_-]*(?i)(?P<quality>HD|FHD|LQ|4K|UHD)?[\s_-]*'
  tags:
    - name: quality
      captures:
        - quality
      concat: '|'
      prefix: ' ['
      suffix: ']'

  mapping:
    - id: France TNT
      match_as_ascii: true
      mapper:
        - pattern: 'Name ~ "!start!TF1!~!Series?!~!(Films?)?!end!" OR Name ~ "!start!HD1!end!"'
          attributes:
            name: 'TF1 Séries Films'
            id: 'TF1SeriesFilms.fr'
            chno: '20'
            logo: 'https://upload.wikimedia.org/wikipedia/commons/d/d4/Logo_TF1_S%C3%A9ries_Films_2018.jpg'
          suffix:
            name: '<tag:quality>'
            group: 'FR|TNT'
          assignments:
             title: name

Expected behavior
When a parsed m3u entry doesn't match the quality regex, the name should be as tvg-name="TF1 Séries Films". Actually it's tvg-name=" []TF1 Séries Films []" (including bug #12 - or tvg-name="TF1 Séries Films []" if bug #12 wasn't here)

Additional context
Link to #12

euzu commented

I cant reproduce this problem, but i have added extra check for emtpy tag content. If you pull and compile, you can test.

kumy commented

There is some changes, still not the expected behavior. The literal string <tag:quality> is displayed instead of "nothing"

#EXTINF:-1 tvg-id="TF1SeriesFilms.fr" tvg-name="TF1 Séries Films test<tag:quality>" group-title="|FR| FRANCE FHDFR|TNT" tvg-chno="20" tvg-logo="",TF1 Séries Films test<tag:quality>
#EXTINF:-1 tvg-id="TF1SeriesFilms.fr" tvg-name="TF1 Séries Films test<tag:quality>" group-title="PROV3FR|TNT" tvg-chno="20" tvg-logo="",TF1 Séries Films test<tag:quality>
#EXTINF:-1 tvg-id="TF1SeriesFilms.fr" tvg-name="TF1 Séries Films test [HD]" group-title="PROV3FR|TNT" tvg-chno="20" tvg-logo="",TF1 Séries Films test [HD]
#EXTINF:-1 tvg-id="TF1SeriesFilms.fr" tvg-name="TF1 Séries Films test<tag:quality>" group-title="PROV2FR|TNT" tvg-chno="20" tvg-logo="",TF1 Séries Films test<tag:quality>
#EXTINF:-1 tvg-id="TF1SeriesFilms.fr" tvg-name="TF1 Séries Films test [HD]" group-title="PROV2FR|TNT" tvg-chno="20" tvg-logo="",TF1 Séries Films test [HD]

euzu commented

Should be fixed with the latest commit.

kumy commented

Looks fine, thanks !!!

#EXTINF:-1 tvg-id="TF1SeriesFilms.fr" tvg-name="TF1 Séries Films" group-title="ALIFR|TNT" tvg-chno="20" tvg-logo="https://upload.wikimedia.org/wikipedia/commons/d/d4/Logo_TF1_S%C3%A9ries_Films_2018.jpg",TF1 Séries Films
#EXTINF:-1 tvg-id="TF1SeriesFilms.fr" tvg-name="TF1 Séries Films" group-title="NIRVFR|TNT" tvg-chno="20" tvg-logo="https://upload.wikimedia.org/wikipedia/commons/d/d4/Logo_TF1_S%C3%A9ries_Films_2018.jpg",TF1 Séries Films
#EXTINF:-1 tvg-id="TF1SeriesFilms.fr" tvg-name="TF1 Séries Films [HD]" group-title="NIRVFR|TNT" tvg-chno="20" tvg-logo="https://upload.wikimedia.org/wikipedia/commons/d/d4/Logo_TF1_S%C3%A9ries_Films_2018.jpg",TF1 Séries Films [HD]
#EXTINF:-1 tvg-id="TF1SeriesFilms.fr" tvg-name="TF1 Séries Films" group-title="WANIFR|TNT" tvg-chno="20" tvg-logo="https://upload.wikimedia.org/wikipedia/commons/d/d4/Logo_TF1_S%C3%A9ries_Films_2018.jpg",TF1 Séries Films
#EXTINF:-1 tvg-id="TF1SeriesFilms.fr" tvg-name="TF1 Séries Films [HD]" group-title="WANIFR|TNT" tvg-chno="20" tvg-logo="https://upload.wikimedia.org/wikipedia/commons/d/d4/Logo_TF1_S%C3%A9ries_Films_2018.jpg",TF1 Séries Films [HD]