euzu / m3u-filter

m3u-filter (iptv filter) is an application which can filter/rename/map entries out of a playlist in M3U / XTREAM format and can save/serve it as m3u, xtream or kodi format. It can be used as reverse or redirect proxy for xtream.
MIT License
72 stars 8 forks source link

Add custom tag to Names and/or Titles #9

Closed kumy closed 1 year ago

kumy commented 1 year ago

Is your feature request related to a problem? Please describe. As I'm using multiple providers, I like to know which one I'm currently using. So I used to tag my channels as: (mind the - PROVx in Name and Title)

#EXTINF:-1 tvg-id="TF1.fr" tvg-name="TF1 [HD] - PROV1" group-title="PROV1|FR|TNT" tvg-chno="1" tvg-logo="https://upload.wikimedia.org/wikipedia/commons/thumb/3/3c/TF1_logo_2013.svg/320px-TF1_logo_2013.svg.png", TF1 HD - PROV1
#EXTINF:-1 tvg-id="TF1.fr" tvg-name="TF1 [HD] - PROV2" group-title="PROV2|FR|TNT" tvg-chno="1" tvg-logo="https://upload.wikimedia.org/wikipedia/commons/thumb/3/3c/TF1_logo_2013.svg/320px-TF1_logo_2013.svg.png", TF1 HD - PROV2

Describe the solution you'd like Be able per config.yml source, to add a specific suffix

  - input:
      url: 'prov1.m3u'
      persist: 'prov1.m3u.bak'
    targets:
      - filename: iptv-PROV1-FR_raw.m3u
        type: M3u
        processing_order: FRM
        filter: 'Name ~ "^FR\d+:"'
        options: { ignore_logo: false }
        rename:
          - { field: Name, new_name: "$1", pattern: "FR[0-9]+:(.*)" }
          - { field: Group, new_name: "$1", pattern: "(.*)" }
          - { field: Title, new_name: "$1", pattern: "FR[0-9]+:(.*)" }
        sort: { order: Asc }
        # HERE -->>
        tag:
            prefix: ''
            suffix: ' - PROV1'
        # <<-- HERE
        mapping:
          - France TNT
          - France Premium
          - Belgique
          - Suisse
          - Canada
          - RakutenTv

Describe alternatives you've considered

  1. Without the mapping feature, I used to hack the rename to achieve that:
    - input:
      url: 'prov1.m3u'
      persist: 'prov1.m3u.bak'
    targets:
      - filename: iptv-PROV1-FR_raw.m3u
        type: M3u
        filter: 'Name ~ "^FR\d+:"'
        options: { ignore_logo: false }
        rename:
          - { field: Name, new_name: "$1 - PROV1", pattern: "FR[0-9]+:(.*)" }
          - { field: Group, new_name: "PROV1", pattern: "(.*)" }
          - { field: Title, new_name: "$1 - PROV1", pattern: "FR[0-9]+:(.*)" }
        sort: { order: Asc }

2.1 With the rename feature: when using default FRM, the Rename hack still works, but the mapping doesn't (The regex filters can be changed to permit matching

2.2 With the rename feature: when using FMR, the Rename hack works only on Title (Name only contains the mapped name - as expected), the mapping works, as I have the Chno and Logo

Both 2.1 an 2.2 are easily explainable, and are the expected result for the current implementation

Additional context Add any other context or screenshots about the feature request here.

euzu commented 1 year ago

Is this done with the current mapping refactoring ?

kumy commented 1 year ago

Sorry for late testing I had a new stay at the hospital... :(

Is this done with the current mapping refactoring ?

Hum, if you are referring to prefix in mapping.yml https://github.com/euzu/m3u-filter#2344-prefix, then unfortunately no.

I wish with the same mapping file to be able to add distinct tags per config input. So I better see the tag definition at the config level not the mapping level (don't remove the tags in mapping level they have use case too). With the prefix in mapping to achieve what I want I would need to duplicate mapping to set a static prefix tag :(

I'm not sure how I can better explain than it the initial issue comment.

kumy commented 1 year ago

(Could you please reopen, I miss the privileges for that, thanks)

euzu commented 1 year ago

I dont understand the use-case. The tags are only used during thge mapping phase. You define them on the top level. You want to define a tag with the same name for different inputs (sources)?

kumy commented 1 year ago

Maybe we call tag for 2 distinct things, so it may be confusing.

My use case is: I have multiple providers giving me the same channels (sometime there are outage so I switch on another one). I'm using Kodi, so I would love to see the provider name along with the channel name

such as image

I can achieve that today by renaming the Title (only the Title, I prefer to leave the Name with only the channel Name so tvheadend can also do it's XMLTV mapping itself - just a personal choice) at the input level:

rename:
  - { field: name, new_name: "$1", pattern: "FR: (.*) FHD" }
  - { field: group, new_name: "ALI", pattern: ".*" }
  - { field: title, new_name: "$1 - ALI", pattern: "FR: (.*) FHD" }

That worked fine until I requested #10, where I overwrite the Title by the Name. I use processing_order: frm as I clean the channel Title before mapping (else the regexp will be too much complicated on mapping side).

So my idea was to have a new setting at the input level which would allow me to add static suffixes per input. All channels from provider 1 will be configured to add ALI to the Title, the second provider WANI, the third NIRV.

Sorry again for the confusion around that.

euzu commented 1 year ago

Each input presents a m3u file. You want to Prefix/Suffix each entry for one specific input-file with a static text?

    input: 
          persist: 'playlist_1_{}.m3u'
          url: 'http://myserver.net/playlist.m3u' 
          suffix: {field: title, value: "Prov.1" }
          prefix: <like suffix>

Something like this ?

kumy commented 1 year ago

Looks great, and the syntax is neat and open. Not sure I was clear, but it would be nice to have that after the FRM, or maybe a 4 letters combination, FRMT 🤷 Thanks

euzu commented 1 year ago

Please look at the latest commit or release

kumy commented 1 year ago

That works only if the assignments is not enabled in mapping.yml

assignments:
   title: name

With assignments only assigned to Tf1 series film entry. It's not working, the lines 2 and 3 should have ended by -ALI or - NIRV

iptv-ALI-FHD_raw.m3u:#EXTINF:-1 tvg-id="TF1.fr" tvg-name="TF1" group-title="ALIFR|TNT" tvg-chno="1" tvg-logo="https://upload.wikimedia.org/wikipedia/commons/thumb/3/3c/TF1_logo_2013.svg/320px-TF1_logo_2013.svg.png",TF1 - ALI
iptv-ALI-FHD_raw.m3u:#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
iptv-NIRV-FR_raw.m3u:#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
iptv-NIRV-FR_raw.m3u:#EXTINF:-1 tvg-id="TF1.fr" tvg-name="TF1" group-title="NIRVFR|TNT" tvg-chno="1" tvg-logo="https://upload.wikimedia.org/wikipedia/commons/thumb/3/3c/TF1_logo_2013.svg/320px-TF1_logo_2013.svg.png",TF1 HD - NIRV
iptv-NIRV-FR_raw.m3u:#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]
iptv-WANI-FR_raw.m3u:#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
iptv-WANI-FR_raw.m3u:#EXTINF:-1 tvg-id="TF1.fr" tvg-name="TF1" group-title="WANIFR|TNT" tvg-chno="1" tvg-logo="https://upload.wikimedia.org/wikipedia/commons/thumb/3/3c/TF1_logo_2013.svg/320px-TF1_logo_2013.svg.png",TF1 HD - WANI
iptv-WANI-FR_raw.m3u:#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]

Without the assignment at all, this feature is working well for all lines:

iptv-ALI-FHD_raw.m3u:#EXTINF:-1 tvg-id="TF1.fr" tvg-name="TF1" group-title="ALIFR|TNT" tvg-chno="1" tvg-logo="https://upload.wikimedia.org/wikipedia/commons/thumb/3/3c/TF1_logo_2013.svg/320px-TF1_logo_2013.svg.png",TF1 - ALI
iptv-ALI-FHD_raw.m3u:#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 Series Films - ALI
iptv-NIRV-FR_raw.m3u:#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",HD1 - NIRV
iptv-NIRV-FR_raw.m3u:#EXTINF:-1 tvg-id="TF1.fr" tvg-name="TF1" group-title="NIRVFR|TNT" tvg-chno="1" tvg-logo="https://upload.wikimedia.org/wikipedia/commons/thumb/3/3c/TF1_logo_2013.svg/320px-TF1_logo_2013.svg.png",TF1 HD - NIRV
iptv-NIRV-FR_raw.m3u:#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 Series Films HD - NIRV
iptv-WANI-FR_raw.m3u:#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",HD1 - WANI
iptv-WANI-FR_raw.m3u:#EXTINF:-1 tvg-id="TF1.fr" tvg-name="TF1" group-title="WANIFR|TNT" tvg-chno="1" tvg-logo="https://upload.wikimedia.org/wikipedia/commons/thumb/3/3c/TF1_logo_2013.svg/320px-TF1_logo_2013.svg.png",TF1 HD - WANI
iptv-WANI-FR_raw.m3u:#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 Series Films HD - WANI
euzu commented 1 year ago

I did not understand the issue, what works and what not? The input affixes are applied after frm processing, so the assignment happens before.

kumy commented 1 year ago

That works as long as the mappings doesn't use the assignmentsfeature.

euzu commented 1 year ago

ok i will check when i am back at home

euzu commented 1 year ago

I cant reproduce this, and i cant see it in the code, because the input affixes are appended after everything is done. Please can you provide me a little set of anonymized config, mapping, input file zip to reproduce this.

kumy commented 1 year ago

Sure I'll try to provide that during the day. Thanks for digging into the issue :+1:

kumy commented 1 year ago

I did the exercise and stripped my conf to the bare minimum, and finally found the issue :innocent: :bow:

I was defining the suffixin config.yml at .sources[].targets[].suffix instead of .sources[].input.suffix.

I'm really sorry to make you loose your time, issue was on my side. I thought I had it working fine the first time I tested the feature because my rename rules were applied and the expected result was the same.

Closing. And thanks again!

euzu commented 1 year ago

you are welcome.