SageTV Community  

Go Back   SageTV Community > SageTV Products > SageTV EPG Service
Forum Rules FAQs Community Downloads Today's Posts Search

Notices

SageTV EPG Service Discussion related to the SageTV EPG Service used within SageTV. Questions about service area coverage, channel lineups, EPG listings, XMLTV, or anything else related to the service or programming guide data for SageTV should be posted here.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-26-2015, 12:31 PM
matrixebiz matrixebiz is offline
New Member
 
Join Date: Aug 2015
Location: Canada
Posts: 3
need guidance on XML parsing

Hello, looking for some help to modify this code/script;

Code:
1 import datetime 
2 
 
3 CHANNELS = {} 
4 
 
5 #################################################################################################### 
6 def initchannels(xmlguide): 
7 	channels = {} 
8 	for key in xmlguide: 
9 		channel = {} 
10 		channels[0] = channel 
11 
 
12 	CHANNELS = channels 
13 
 
14 
 
15 def format_time(timestamp): 
16 	return datetime.datetime.strptime(timestamp[:12], "%Y%m%d%H%M%S") 
17 
 
18 
 
19 #################################################################################################### 
20 def epgguide(channelID, currentTime): 
21 	epgInfo = 'No EPG Info Available' 
22 	#Log("currenttime ---------------- " + str(currentTime)) 
23 	try: 
24 		for channel in CHANNELS: 
25 			if channel.id in channelID: 
26 				for prog in channel: 
27 					if int(currentTime) > int(format_time(prog.key['start'])) and int(currentTime)+120 < int(format_time(prog.key['stop'])): 
28 						epgInfo = epgInfo + ' | ' + prog + '[ ' + format_time(key['start']) + ' - ' + format_time(key['stop']) + ' ]' 
29 	except: 
30 		pass 
31 	return epgInfo
I just need it to be able to read the attached guide.xml to parse the info.
Thank you
Attached Files
File Type: txt guide.xml.txt (601.5 KB, 301 views)
Reply With Quote
  #2  
Old 08-26-2015, 12:54 PM
matrixebiz matrixebiz is offline
New Member
 
Join Date: Aug 2015
Location: Canada
Posts: 3
I would like it to;

a) Init function [def initchannels(xmlguide)] that parses the 'guide.xml' at the start when Refreshing Channel Listing is called
b) Get Channel content based on current time [def epgguide(channelID, currentTime)]

Thank you
Reply With Quote
  #3  
Old 08-27-2015, 11:39 AM
stanger89's Avatar
stanger89 stanger89 is offline
SageTVaholic
 
Join Date: May 2003
Location: Marion, IA
Posts: 15,188
That looks like python, I'd take a look at some of the python xml parsers. sax is probably a good start since you want to parse the whole XML on init.
https://docs.python.org/2/library/xml.html
Reply With Quote
  #4  
Old 08-27-2015, 01:10 PM
matrixebiz matrixebiz is offline
New Member
 
Join Date: Aug 2015
Location: Canada
Posts: 3
Ok, I'll check with some Python programmers. Thx
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with Parsing error PLUCKYHD SageTV Studio 2 05-06-2009 08:08 AM
6.1.4 Metadata Properties Parsing JREkiwi SageTV Beta Test Software 35 03-10-2007 08:39 PM
Two Questions. H.264 and Tag Parsing kranzel SageTV Software 0 01-16-2007 04:20 AM
XML Parsing Library (Exist?) Necro SageTV Studio 3 10-18-2006 03:50 PM
XMLTV Parsing Software... pawn SageTV EPG Service 0 01-13-2004 03:00 PM


All times are GMT -6. The time now is 12:07 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.