Changing Channel display-name attribute

Discussion of Version 3 and developing lua grabbers
Post Reply
black sky
Posts: 4
Joined: Mon Apr 03, 2006 3:13 pm

Changing Channel display-name attribute

Post by black sky »

Hi Alan,
Great tool that makes XMLTV a breeze to use.
just having a browse around to see how possible it is to change the display-name attribute in the XML file, e.g. shorten National Geographic to Nat Geo but haven't found anything on the web about this.
Was thinking that maybe a variation on altchids.txt (called say altchnms.txt) with old and new name might do the trick, but at first glance I'll have to study up on Lua a bit to do teh processing.
Would this be a reasonable strategy?

Regards.
alanbirtles
Site Admin
Posts: 495
Joined: Mon Sep 06, 2004 4:44 pm

Post by alanbirtles »

yep, the ukrt_altchids_xmltv.lua script is probably a good place to start from see http://www.birtles.org.uk/xmltv/wiki/in ... ng_Scripts for some documentation. If there is anything missing that you need let me know
black sky
Posts: 4
Joined: Mon Apr 03, 2006 3:13 pm

Post by black sky »

Thx Alan.
Found a quick and easy way (for me anyway)... in using my SageTV xmltv plugin to achieve this.
melearp
Posts: 12
Joined: Wed Dec 20, 2006 6:28 pm

Post by melearp »

I am a very satisifed user of XMLTVGUI. Thanks for all the effort.

I would like to write the script to transform names but I can't get to the wiki to see the documentation. Is there something wrong or is the link no longer valid.

Thanks for your help.
alanbirtles
Site Admin
Posts: 495
Joined: Mon Sep 06, 2004 4:44 pm

Post by alanbirtles »

try again i have been having some problems with my php install recently
melearp
Posts: 12
Joined: Wed Dec 20, 2006 6:28 pm

Post by melearp »

Yep, that's fine now.
Cheers.
melearp
Posts: 12
Joined: Wed Dec 20, 2006 6:28 pm

Post by melearp »

Well, here's a first attempt. It did the job for me but I know it has shortcomings. I had to learn LUA along the way!

Here's the lua script and the configuration file that I use to transform the Radio Times names into those that appear on the Freeview transmissions. Now, when I scan with GBPVR they are linked immediately rather than having to do it by hand. Put both files in the UK_RT folder under scripts. and configure the postprocessor to read the text file (using the XMLTVGUI configuration settings).

The deficiency in the script (if it is a deficiency) is that it doesn't cope with the full generality of the spec and just assumes that "Name" contains a "Value". This seems to be always the case for the RT scanner.

Script

Code: Select all

local channels

local function Pass1Func(grabber,channel)
	local oldname,newname,str
	XGUI.SetStatus(2,"Processing "..channel.Name.Value)
	oldname=channel.Name.Value
	newname=channels[oldname]
	if newname~=nil then 
		print(string.format("Changing '%s' --> '%s'",oldname,newname))
		channel.Name.Value=newname
		end
	return channel
	end

local function Start(grabber)
	local fn=XGUI.GetSetting(grabber,"FileName","altchnames.txt")
	local line
	local first=true
	channels={}
	for line in io.lines(fn) do
		local name,alt
		for name,alt in string.gfind(line,"(.-),(.+)") do
--			note that this requires comma separated strings since names can contain spaces but hopefully not commas
			if not first then
				print(string.format("config '%s' --- '%s'",name,alt))
				channels[name]=alt
				else first=false
				end
			end
		end
	return XGUI.OK
	end

local function Init(grabber)
	XGUI.AddSetting(grabber,"FileName",XGUI.SettingType.Directory,"altchnames.txt","Channel names file")
	return XGUI.OK
	end
	
PostProcs.UK_RT_ALTNAMES_Text={
	Name = "UK - Radio Times - Text Altnames reader",
	Version = "1.00.00",
	Author = "Mel Earp modified from Alan Birtles",
--	InfoURL = "http://www.birtles.org.uk/xmltv/wiki/index.php?title=UK_RT_Alt_Text",
--	There is no separate InfoURL
	Grabber = "UK_RT",
	Init=Init,
	Passes={
		Pass1={
			Start=Start,
			Type=XGUI.PassTypes.Channel,
			Func=Pass1Func,
			},
		},
	}
Here's my configuration file (it does do null transformations for those that are not different, so that it's easier to change). You will have to change the "North West" names to ones that suit you.

Code: Select all

RT Guide Name,TV Name
BBC1 North West,BBC ONE
BBC2 North West,BBC TWO
ITV1 Granada,ITV1
Channel 4,Channel 4
Five,Five
ITV2,ITV2
BBC3,BBC THREE
BBC4,BBC FOUR
ITV3,ITV3
Sky Three,SKY THREE
UKTV History,UKTV History
More4,More 4
E4,E4
ABC1,abc1
QVC,QVC
The Hits,The Hits
UKTV Bright Ideas,UKTV Br'tIdeas
Ftn,f tn
TMF: The Music Factory,TMF
Ideal World,Ideal World
Price-drop tv,price-drop tv
ITV4,ITV4
Film4,Film4
E4 +1,E4+1
ITV Play,ITV Play
FilmFour +1,Film4+1
Five US,Five US
Five Life,Five Life
CBBC,CBBC Channel
CBeebies,CBeebies
CITV,CITV
BBC News 24,BBC NEWS 24
BBC Parliament,BBC Parliament
Sky News,Sky News
Sky Sports News,Sky Spts News
alanbirtles
Site Admin
Posts: 495
Joined: Mon Sep 06, 2004 4:44 pm

Post by alanbirtles »

feel free to add this script to the wiki
melearp
Posts: 12
Joined: Wed Dec 20, 2006 6:28 pm

Post by melearp »

Done.
bgowland
Posts: 7
Joined: Sun Jun 25, 2006 4:33 pm

Post by bgowland »

melearp - thanks for this. I came here today to see if something like this existed. Having names which don't match those detected in the Freeview brodcast is annoying sometimes. I'll give this a go.

Cheers,
Brian
Post Reply