I'm working on my python script for xbmc media application to send the request to url to get the response so I can store the data in a sqlite3 database.
I want to to set up the calculate progress from 0% to 100% for the label control to see how far I'm going when I send the request to url to get the response and then to store the data in a database.
Here is the control id that i want to use:
main_loading_time_left = 4202
Here is the code:
#DOWNLOAD THE XML SOURCE HERE
url = ADDON.getSetting('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(channel TEXT, title TEXT, start_date TIMESTAMP, stop_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 = sqlite3.connect(profilePath)
cur = con.cursor()
channels = OrderedDict()
# Get the loaded data
for channel in tv_elem.findall('channel'):
channel_name = channel.find('display-name').text
for program in channel.findall('programme'):
title = program.find('title').text
start_time = program.get("start")
stop_time = program.get("stop")
cur.execute("INSERT INTO programs(channel, title, start_date, stop_date)" + " VALUES(?, ?, ?, ?)", [channel_name, title, start_time, stop_time])
con.commit()
Does anyone know how I can use the control id main_loading_time_left
to set up the calculate progress that start from 0% to 100% when I send the request to the url to get the response and then store the data into the database. Does anyone know how?