Jump to content

Ubc Epg


phazey

Recommended Posts

Hi,

I've been frustrated over the past few months about the lack of a decent Electronic Program Guide for UBC. I don't get the program guide here, and only knowing what's showing next on the TV onscreen guide.

So i had an idea....UBC offer the months program schedule for all channels in .txt format. I've been playing with AppleScript to figure out a way to import this into iCal - ultimatly this can be exported to the standard .cal format so outlook etc users can also benefit. All i would have to do is automate it on a server, host, convert and export once a month.

Anyone think this is worth the effort. More importantly, anyone fancy collaborating on the code to get it up and running a bit quicker (coding is not my first skill)..

I've got to the stage where i can read the files, and each channel is in it's own sub-calendar. But still screwed with pst channels....so needs work..

What does everyone think ?

Edited by phazey
Link to comment
Share on other sites

Ok granted. But there are a few issues. Their reader does not work on Apple. the whole idea was to put it into a calendar so it's available all the time, even on your mobile phone should you have one that supports calendaring...i could not see if there were scheduling alarms etc. Useful for some sure, not what i am after tho.

Cheers,

Link to comment
Share on other sites

Ok granted. But there are a few issues. Their reader does not work on Apple. the whole idea was to put it into a calendar so it's available all the time, even on your mobile phone should you have one that supports calendaring...i could not see if there were scheduling alarms etc. Useful for some sure, not what i am after tho.

Cheers,

Good point, would be more universal. However don't forget the linux community who may like to use it also (spread sheet format perhaps?).

Link to comment
Share on other sites

I've got to the stage that the Applescript will show me a prompt for what channel,show,time and date is in line - just sticking it into iCal is becoming a pain..do you want my code ?

George: i *don't* think copyright is an issue here..at the end of the day i want to upload the .cal files to ubc and open whatever code we write.....

The main problem is UBC do not use the standard epg format......

Edited by phazey
Link to comment
Share on other sites

I've got to the stage that the Applescript will show me a prompt for what channel,show,time and date is in line - just sticking it into iCal is becoming a pain..do you want my code ?

Was going to do it in a VB6 exe or an ASP.net app - hadn't decided yet. If asp.net, it'd simply be two textboxes and a button - copy/paste the text file into one, click the button, then copy past the results from the second textbox into an ICS file.

Afraid I'm not familiar with AppleScript, so not sure how much use it'd be to me. The txt format looks simple enough though - only problem is you can't tell what time the last programme in the schedule finishes. Will default this to midnight.

Link to comment
Share on other sites

I got around the midnight thing by wrapping the time. Here's my code, you may get some jist of how far i got - i know a different language, but the method will be the same. You may notice i'm doing some weird time conversion, my timezone is 30 minutes behind thailand - i'll code in some localization when i get a chance.....also near the bottom is where i started to get lost and try a few different date manipulation methods.......

set txt to choose file
set theR to read txt

set {theChannel, theDate, TitlStr} to {"", "", ""}
repeat with i from 1 to number of paragraphs in theR

set r to (paragraph i of theR) as string
if r starts with "UBC Chanel :" then set theChannel to my substitute(r, "UBC Chanel : ", "")
if r starts with "Date :" then set theDate to my substitute(r, "Date : ", "")

if number of words of r > 1 and number of characters of word 1 of r = 2 and character 3 of r is ":" then
	set timeStr to (text from word 1 to word 2 of r) as string
	set TitlStr to my substitute(r, timeStr, "")
	set TitlStr to my substitute(TitlStr, "  ", "")
	set hrs to word 1 of r as number
	set mins to word 2 of r as number
	set mins to mins - 30
	if mins < 0 then
		set hrs to (hrs - 1) as string
		if number of characters of hrs < 2 then set hrs to ("0" & hrs) as string
		set mins to mins + 60
	end if

	if hrs < 0 then
		set hrs to 23
		set theDate to theDate as date

	end if

	--set MyDate to date "Monday, July 10, 2006 9:50:00 AM" as string
	set d to "7/10/2006 16:00"
	set MyDate to date d
	--set MyDate to date (d & "," & t) as string
	set timeStr to (hrs & ":" & mins) as string
	--display dialog MyDate
	display dialog (MyDate & ", " & theChannel & ", " & timeStr & ", " & TitlStr) as string
	--> insert iCal event creation here with arguments (theDate, theChannel, timeStr, TitlStr)
	set dateString to (theDate & "," & timeStr)
	--set dateString to {theDate  timeStr} as string

	--display dialog date dateString



	tell application "iCal"
		activate
		set theCal to (first calendar whose title is theChannel)
		--tell theCal
		make event in theCal with properties {summary:TitlStr, start date:MyDate}
		--end tell
	end tell


end if
end repeat

on substitute(theText, toReplace, newText)
set AppleScript's text item delimiters to the toReplace
set the allTheText to every text item of theText
set AppleScript's text item delimiters to the newText
set theText to the allTheText as string
set AppleScript's text item delimiters to ""
return theText
end substitute

Link to comment
Share on other sites

  • 3 weeks later...

Hi,

Well at long last (and some extended sick leave) i've finished the first release of my UBC2iCal converter. It'll take the rather awful UBC downloadable text files for the months schedule and put the programs nicely into iCal (This is Mac only until i sort other things out, alough it does import to google calendars...I'd appreciate feedback from fellow Mac users.

Here's what you need to do:

1) download and unzip the schedule to a location on your Mac. Get the schedule from here..

http://www.ubctv.com/Schedule/downloadFiles/ubcschedule.zip

2) load up iCal and create a new Calendar for each channel you wish to store - the exact names Must be used, (identical to the filenames, without the .txt extension).

3) Copy the following code and paste into "Script Editor" - save somewhere. Run the Script.

It will ask you for a channel file, make sure you've already created the relevent calendar.

set txt to choose file
set theR to read txt
set {theChannel, theDate, TitlStr} to {"", "", ""}
repeat with i from 1 to number of paragraphs in theR
set r to (paragraph i of theR) as string
if r starts with "UBC Chanel :" then set theChannel to my substitute(r, "UBC Chanel : ", "")
if r starts with "Date :" then set d to my substitute(r, "Date : ", "")

if number of words of r > 1 and number of characters of word 1 of r = 2 and character 3 of r is ":" then
	set timeStr to (text from word 1 to word 2 of r) as string
	set TitlStr to my substitute(r, timeStr, "")
	set TitlStr to my substitute(TitlStr, "  ", "")
	set hrs to word 1 of r as number
	set mins to word 2 of r as number

	if mins < 0 then
		set hrs to (hrs - 1) as string
		if number of characters of hrs < 2 then set hrs to ("0" & hrs) as string
		set mins to mins + 60
	end if

	if hrs < 0 then
		set hrs to 23
	end if
	set theDate to my changeFormat(d) as string
	set timeStr to (hrs & ":" & mins) as string
	set theDate0 to (theDate & " " & timeStr) as string
	set theDate1 to date theDate0

	tell application "iCal"
		activate
		set theCal to (first calendar whose title is theChannel)
		make new event at end of events of theCal with properties {summary:TitlStr, start date:theDate1}
	end tell

end if
end repeat

on substitute(theText, toReplace, newText)
set AppleScript's text item delimiters to the toReplace
set the allTheText to every text item of theText
set AppleScript's text item delimiters to the newText
set theText to the allTheText as string
set AppleScript's text item delimiters to ""
return theText
end substitute

on changeFormat(theDate)
set {olddelims, text item delimiters} to {text item delimiters, "/"}
set {d, m, y} to (text items of theDate)
set retVal to {m, d, y} as string
set text item delimiters to olddelims
return retVal
end changeFormat

I'm thinking of a few other features, but as we have it now, it works (with a heap load of manual labour)....

Automatic schedule download

Import of chosen channels only - lessen user intervention

Option to grab program discriptions

Multiple format support.

Automatic upload to a wen location (google calendar for example)

Sync with mobile device for those "special not to miss programs" (BSG S3!)

As i said, i'd appreciate feedback :o

Cheers,

./P

Link to comment
Share on other sites

Hi,

Well at long last (and some extended sick leave) i've finished the first release of my UBC2iCal converter. It'll take the rather awful UBC downloadable text files for the months schedule and put the programs nicely into iCal (This is Mac only until i sort other things out, alough it does import to google calendars...I'd appreciate feedback from fellow Mac users.

Here's what you need to do:

1) download and unzip the schedule to a location on your Mac. Get the schedule from here..

http://www.ubctv.com/Schedule/downloadFiles/ubcschedule.zip

2) load up iCal and create a new Calendar for each channel you wish to store - the exact names Must be used, (identical to the filenames, without the .txt extension).

3) Copy the following code and paste into "Script Editor" - save somewhere. Run the Script.

It will ask you for a channel file, make sure you've already created the relevent calendar.

set txt to choose file
set theR to read txt
set {theChannel, theDate, TitlStr} to {"", "", ""}
repeat with i from 1 to number of paragraphs in theR
set r to (paragraph i of theR) as string
if r starts with "UBC Chanel :" then set theChannel to my substitute(r, "UBC Chanel : ", "")
if r starts with "Date :" then set d to my substitute(r, "Date : ", "")

if number of words of r > 1 and number of characters of word 1 of r = 2 and character 3 of r is ":" then
	set timeStr to (text from word 1 to word 2 of r) as string
	set TitlStr to my substitute(r, timeStr, "")
	set TitlStr to my substitute(TitlStr, "  ", "")
	set hrs to word 1 of r as number
	set mins to word 2 of r as number

	if mins < 0 then
		set hrs to (hrs - 1) as string
		if number of characters of hrs < 2 then set hrs to ("0" & hrs) as string
		set mins to mins + 60
	end if

	if hrs < 0 then
		set hrs to 23
	end if
	set theDate to my changeFormat(d) as string
	set timeStr to (hrs & ":" & mins) as string
	set theDate0 to (theDate & " " & timeStr) as string
	set theDate1 to date theDate0

	tell application "iCal"
		activate
		set theCal to (first calendar whose title is theChannel)
		make new event at end of events of theCal with properties {summary:TitlStr, start date:theDate1}
	end tell

end if
end repeat

on substitute(theText, toReplace, newText)
set AppleScript's text item delimiters to the toReplace
set the allTheText to every text item of theText
set AppleScript's text item delimiters to the newText
set theText to the allTheText as string
set AppleScript's text item delimiters to ""
return theText
end substitute

on changeFormat(theDate)
set {olddelims, text item delimiters} to {text item delimiters, "/"}
set {d, m, y} to (text items of theDate)
set retVal to {m, d, y} as string
set text item delimiters to olddelims
return retVal
end changeFormat

I'm thinking of a few other features, but as we have it now, it works (with a heap load of manual labour)....

Automatic schedule download

Import of chosen channels only - lessen user intervention

Option to grab program discriptions

Multiple format support.

Automatic upload to a wen location (google calendar for example)

Sync with mobile device for those "special not to miss programs" (BSG S3!)

As i said, i'd appreciate feedback :o

Cheers,

./P

Link to comment
Share on other sites

I'm looking forward to trying the iCal solution. Here's what I've been using to keep track of the movie channels on UBC (HBO, CineMax, Star Movies, Hallmark and Movie Hits).

It's a collection of two html pages (moviepages calls ubc53, which uses JavaScript to call the correct day for channel 53).

Now and then HBO or the channel 53 page fails to load - in fact after two weeks I finally yelled at UBC to fix their scripting today - but most of the time it gives me a view of whats coming up.

I use a DVR to program recordings at night, etc., and this has helped a lot. Star Movies is damaged compared to HBO and what they used to offer, but by moving forward day by day, I've copied the movie times and titles to a spread sheet that I also use to keep track of scheduled and movies to schedule in the future. It was a bit tedious, but not too difficult and didn't take too long.

What I do like about it is that when I spot a movie I want, I can quickly find the best time to record it. Cheers if it helps anyone.

Link to comment
Share on other sites

  • 9 months later...

Couldn't you just publish a Google calendar with the data? I know there's tons of different Google calendars out there, has to be easy to publish one. And iCal I think is compatible, it's some sort of calendaring standard - don't remember the deets...

ps: A very worthwhile project! Exellent :o

Edited by nikster
Link to comment
Share on other sites

Could anyone come up with a way to extract the data from the UBC txt files into an XML TV file or similar that could be used by Windows Media Centre as an EPG.

It can be done with Perl (http://www.perl.com/).

I've been planning to write something to make searching the text files easy (to get all the show times for a particular event, for example), but until the zip file provided by True is dependable (i.e., always available by at least the first of the month, and preferably a month in advance - all of Oct. available on Sept. 1), it'd be a waste of time.

I've had to bug them almost every month about it, or their other ways of making schedules available. This month it took until just a few days ago to get the September schedule available.

I wish I could load an XML file into my unit to enable automatic programming! Would be cool. :o

UC

Link to comment
Share on other sites

There is a program that does that, it actually queries the UBC schedules online, Its called TVxB - However the Thailand file is around a year out of date, so some of the channels are wrong/old. It could be edited, I'd be happy to do it if someone else had some more in-depth knowledge of XML (TV?) than myself.

Link to comment
Share on other sites

There is a program that does that, it actually queries the UBC schedules online, Its called TVxB - However the Thailand file is around a year out of date, so some of the channels are wrong/old. It could be edited, I'd be happy to do it if someone else had some more in-depth knowledge of XML (TV?) than myself.

Do you mean "ubcschedule.zip"?

The one that is old, is - I think - the one left over when UBC got "taken over by" or "merged with" True. It is the schedule for April 2006.

But I can't find that one any more - it was there up to about a week ago, but the UBC web site has been cleaned up a lot recently and I can't find the link to the old schedule, just the new one at TrueVisions: http://www.truevisionstv.com/schedule/down...ubcschedule.zip

Edited by JetsetBkk
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.







×
×
  • Create New...