2014-05-17, 16:05
Hello All,
I'm working on my python script to print the list of strings from my own xml file.
I'm trying to find out how to print the list of strings from the programme-channel tag to get the format in the start="" and stop="" tags. When I'm trying to get the list of format and the title, I will only get the list of channels which you can see it here:
Here is the xml:
Here is the code:
Can you please help me how i can print the list of format from the start="" and stop="" tags as well from the title tag?
I'm working on my python script to print the list of strings from my own xml file.
I'm trying to find out how to print the list of strings from the programme-channel tag to get the format in the start="" and stop="" tags. When I'm trying to get the list of format and the title, I will only get the list of channels which you can see it here:
Code:
15:00:58 T:3316 NOTICE: 101 ABC FAMILY
15:00:58 T:3316 NOTICE: 102 CBS
15:00:58 T:3316 NOTICE: 103 CNN USA
15:00:58 T:3316 NOTICE: 105 ESPN USA
15:00:58 T:3316 NOTICE: 106 Fox News
15:00:58 T:3316 NOTICE: 107 Animal Planet
15:00:58 T:3316 NOTICE: 108 USA Network
15:00:58 T:3316 NOTICE: 110 SPIKE
15:00:58 T:3316 NOTICE: 111 BRAVO USA
15:00:58 T:3316 NOTICE: 112 BRAVO1
15:00:58 T:3316 NOTICE: 113 BRAVO2
15:00:58 T:3316 NOTICE: 114 BRAVO3
15:00:58 T:3316 NOTICE: 115 BRAVO4
15:00:58 T:3316 NOTICE: 116 BRAVO5
15:00:58 T:3316 NOTICE: 117 BRAVO6
15:00:58 T:3316 NOTICE: 118 BRAVO7
Here is the xml:
Code:
<tv generator-info-name="www.mysite.com/xmltv">
<channel id="101 ABC FAMILY">
<display-name>101 ABC FAMILY</display-name>
<programme channel="101 ABC FAMILY" start="" stop="20140517070000">
<title lang="en">The Karate Kid Part III</title>
<sub-title lang="en"></sub-title>
<desc lang="en"></desc>
<category lang="en"></category>
</programme>
<programme channel="101 ABC FAMILY" start="20140517070000" stop="20140517093000">
<title lang="en">The Karate Kid</title>
<sub-title lang="en"></sub-title>
<desc lang="en"></desc>
<category lang="en"></category>
</programme>
</channel>
Here is the code:
Code:
#DOWNLOAD THE XML SOURCE HERE
url = ADDON.getSetting('allchannels.url')
req = urllib2.Request(url)
response = urllib2.urlopen(req)
data = response.read()
response.close()
profilePath = xbmc.translatePath(os.path.join('special://userdata/addon_data/script.tvguide', ''))
if os.path.exists(profilePath):
profilePath = profilePath + 'source.db'
con = database.connect(profilePath)
cur = con.cursor()
cur.execute('CREATE TABLE programs(id TEXT, channel TEXT, title TEXT, start_date TIMESTAMP, end_date TIMESTAMP, description TEXT)')
con.commit()
con.close
tv_elem = ElementTree.parse(StringIO.StringIO(data)).getroot()
profilePath = xbmc.translatePath(os.path.join('special://userdata/addon_data/script.tvguide', ''))
profilePath = profilePath + 'source.db'
con = database.connect(profilePath)
cur = con.cursor()
channels = OrderedDict()
for elem in tv_elem.getchildren():
if elem.tag == 'channel':
channels[elem.attrib['id']] = self.load_channel(elem)
elif elem.tag == 'programme':
# get channel
channel = channels[elem.attrib['programme']]
channel = channels[elem.attrib['title']]
# load program in channel
channel.get_programs().append(self.load_programme(elem))
for channel_key in channels:
channel = channels[channel_key]
display_name = channel.get_display_name()
print channel.get_display_name()
Can you please help me how i can print the list of format from the start="" and stop="" tags as well from the title tag?