Project

General

Profile

Feature #4715

Stripe out "HD" from channel names when mapping services

Added by Sebastian K. about 7 years ago. Updated about 7 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
General
Target version:
-
Start date:
2017-11-09
Due date:
% Done:

0%

Estimated time:

Description

My be one can implement a funtionality to stripe out HD postfixes from channel names when service are mapped.

While merging sd and hd services to one channel for me im not interestet to see hd postfix in channelname.

History

#1

Updated by Em Smith about 7 years ago

Since you mentioned in other bug (#4714) that you use fuzzy mapping, you mean "always strip HD" so "Film HD" is always just called "Film" even if you don't have another channel called "Film" (broadcasting in SD) with which you are merging.

My only worry is that here we have channels such as "5HD" (no spaces between name and HD) so we'd have no way of knowing if HD were part of an actual word. Though, I can't think of any words in my language that end "HD" so I see no real harm making it an optional tickbox on the mapping dialog to always strip "HD" from the end of the channel name.

#2

Updated by Sebastian K. about 7 years ago

Don't know if this goes to far... (if yes, just ignore it ;) )

But instead of searching for fix letters (HD) at the end of the channel name could this be some configurable Regx expression?

So for example I've got following services with names like:

  Film
  Film HD
  Film UHD

The following regex (pcre (php) lang) will return a named regex group `ChannelName` with the relevant part of the channel name `Film`.

  (?P<ChannelName>.*?)(?| HD| UHD)

So apply the regex on all service names will give the desired channel name.


Maybe an extended replacement pattern could be given (like sed command).

Here I like to have my channels in alphabetical order. But some channel start with lower chars so they are alway at the end of every list. With this replacement pattern you could do somthing like replace first char with uppercase on.

With Linux sed i would do something like:

(sed -e "s/\b\(.\)/\u\1/g")

#3

Updated by Em Smith about 7 years ago

Yes, I sort alphabetically and those stations that use lowercase are annoying.

I have similar problems and had thought of something similar since my channel names don't always match up with the ones my SD say they should have, so IWBNI I could automatically alter them.

My case is slightly more complicated by the fact some of channel name are not unique and need extra tuning parameters to fix them (so I have ten channels called "3" but they should really be called "3 North", "3 South", etc based on the tuning details).

Long term, I had thought maybe there should be some config file configuration of fixups and mappings. But then I'm worried I'd end up implementing Greenspun's Tenth Rule which basically says that every program gets to the point where they implement a bug-ridden internal programming language.

Let's delay for a few days to give more people time for ideas and see if more examples are given or a simple solution emerges since from the two examples you gave, it would suggest it couldn't be an easy-to-read UI element and would need to be a config file. Although I use pcre, I'm wary of pcre since it's not currently a compile-time requirement so it may not be fair to some user to make the core system depend on it when they run it on some odd hardware.

#4

Updated by Sebastian K. about 7 years ago

Some one already did so (implementing Greenspun's Tenth Rule ;) ).

https://github.com/tvheadend/tvheadend/blob/master/src/tvhregex.h

#5

Updated by Em Smith about 7 years ago

You're right that tvheadend does support pcre, but it's optional and falls back to the old-fashioned regex.

But what I meant is that I didn't want to start accidentally implementing some huge format which is basically a pseudo-language where we end up with tens of regex and then decide to add extra clauses to say "these regex are only for these frequencies", then more clauses to only do some regex if some other regex hadn't matched... :)

I think we need to balance what can be easy in a GUI and perhaps something where we implement a simple additional api call "rename channel" and allow a user to just write their own logic externally. Of course, you must already be able to rename channels externally (since the UI does it), but it's call may not be intuitive.

#6

Updated by Hanspeter Müller about 7 years ago

Hi,

wouldn't we need the capability to set the priority based on the quality so it actually goes UHD -> HD -> SD? Otherwise, i think the first Service (usually NETWORK/Frequency/name) in the Channel would be used first, no matter if its the worst quality?

/hp

#7

Updated by Hanspeter Müller about 7 years ago

D'oh. https://tvheadend.org/issues/3323

The streaming profile can prefer HD or SD services. There's a switch in the streaming profile configuration. I'm closing this because everything is implemented in the current development tree.

sorry for the noise; +1 for this FR :)

#8

Updated by Em Smith about 7 years ago

I've gone for a compromise approach.

There's now a tickbox so you can automatically strip the trailing HD/UHD marker.

If you want to do something more complicated then you can use a new API call that should be easy to script. Simply add a line for the few misnamed channels specifying a "from" and "to" name. This can be used to fix names that have the wrong capitalization, channels that have names that differ from the xmltv guide, etc.

curl http://localhost:9981/api/channel/rename --data-urlencode 'from=dave' --data-urlencode 'to=Dave'

If you need something even more complicated then the existing api/channel/list and api/idnode/save calls allow you to modify everything, but they should be used with care.

#9

Updated by Andreas Fornberg about 7 years ago

Would it be possible to move something from for example beginning in the channelname to the end?

One example:
SE: Fjorton to Fjorton SE

In that case match SE: and remove that and add SE in end instead.

#10

Updated by Em Smith about 7 years ago

Sure, if there are only one-or-two then you can do as in the example above.

If it's many channels that you need to alter then you need a script. Something like this untested logic:

curl http://localhost:9981/api/channel/list |
sed  -e 's/"val"/\n"val"/g' -e 's/},/\n},/g' | grep val | awk -F\" '{print $4}' | sort | uniq | while read f; do new=`echo $f | sed s'/^\(SE: \)\(.*\)/\2 SE/'`; if [ "X$new" != "X$f" ]; then echo Changing $f to $new; echo curl http://localhost:9981/api/channel/rename --data-urlencode \'from=$f\' --data--urlencode \'to=$new\'; fi;  done

This should then output lines such as:

Changing SE: Fjorton to Fjorton SE
curl http://localhost:9981/api/channel/rename --data-urlencode 'from=SE: Fjorton' --data--urlencode 'to=Fjorton SE'

So you'd either run those curl commands manually, or replace the "echo curl" with "curl" to just automatically run it.

The key thing to change for other channel names would be the 'sed' after the 'echo $f' which takes the channel name and replaces it with a new name.

#11

Updated by Andreas Fornberg about 7 years ago

Em Smith wrote:

Sure, if there are only one-or-two then you can do as in the example above.

If it's many channels that you need to alter then you need a script. Something like this untested logic:
[...]

This should then output lines such as:
[...]

So you'd either run those curl commands manually, or replace the "echo curl" with "curl" to just automatically run it.

The key thing to change for other channel names would be the 'sed' after the 'echo $f' which takes the channel name and replaces it with a new name.

I know i can do it with bash script but would be nice if that rename thing could do that easy.
But thanks for answer i will play a little with this.

Also available in: Atom PDF