2014-12-28, 00:56
Hello !
I currently developed a Picture plugin for xbmc, it's my first one then i need a few help.
My idea is to get picture information from a mysql database.
This very simple example work properly.
But now i want to improve this by increase of one the number of access in the mysql database, for the moment i found no ways to execute a callback each time a picture is display. I try context menu, url but for the moment nothing work properly
thanks for you help !
I currently developed a Picture plugin for xbmc, it's my first one then i need a few help.
My idea is to get picture information from a mysql database.
This very simple example work properly.
But now i want to improve this by increase of one the number of access in the mysql database, for the moment i found no ways to execute a callback each time a picture is display. I try context menu, url but for the moment nothing work properly
thanks for you help !
PHP Code:
import sys
import urllib
import urlparse
import xbmcgui
import xbmcplugin
sys.path.append('C:\\Python27\\Lib\\site-packages\\')
import MySQLdb
class Example(xbmcgui.WindowDialog):
def __init__(self, url):
## self.abouttitle = xbmcgui.ControlLabel(340, 135, 300, 30, str(sys.argv))
self.addControl(xbmcgui.ControlImage(0, 0, 720, 480, url))
##self.addControl(self.abouttitle)
def onControl(self, c):
if self.h1 == c:
print "hey"
if self.something == c:
print "you press med"
if self.btn_quit == c:
self.close()
base_url = sys.argv[0]
def build_url(query):
return base_url + '?' + urllib.urlencode(query)
if sys.argv[1] == 'show':
Z=Example('empty')
Z.doModal()
del Z
else:
addon_handle = int(sys.argv[1])
args = urlparse.parse_qs(sys.argv[2][1:])
xbmcplugin.setContent(addon_handle, 'picture')
mode = args.get('mode', None)
if mode is None:
url = build_url({'mode': 'folder', 'foldername': 'Image internet'})
li = xbmcgui.ListItem('Image internet')
xbmcplugin.addDirectoryItem(handle=addon_handle, url=url,
listitem=li, isFolder=True)
url = build_url({'mode': 'folder', 'foldername': 'Image personel'})
li = xbmcgui.ListItem('Image personel',
iconImage='N:\\Image\\Nos Photos\\2013\\03-mars 2013\\02_03_2013_divers\\P1010250.JPG',
thumbnailImage='N:\\Image\\Nos Photos\\2013\\03-mars 2013\\02_03_2013_divers\\P1010250.JPG',
path='N:\\Image\\Nos Photos\\2013\\03-mars 2013\\02_03_2013_divers\\P1010250.JPG')
xbmcplugin.addDirectoryItem(handle=addon_handle, url=url,
listitem=li, isFolder=True)
xbmcplugin.endOfDirectory(addon_handle)
elif mode[0] == 'folder':
db = MySQLdb.connect(host="127.0.0.1",
user="root",
passwd="",
db="my_files")
cur = db.cursor()
cur.execute("SELECT PATH FROM `multimedia_file` WHERE type=2 LIMIT 10020,10040")
for row in cur.fetchall():
commands = []
argsToPass = 'show'
scriptToRun = "special://home/addons/plugin.image.smardtv/default.py"
runner = "XBMC.RunScript({0}, {1})".format(scriptToRun, argsToPass)
name = 'show'
commands.append((name, runner, ))
url = row[0].replace('/', '\\')
url2 = build_url({'file': url, 'mode': 'file', 'foldername': 'Image personel'})
li = xbmcgui.ListItem(row[0], iconImage=url, thumbnailImage=url, path=url)
li.addContextMenuItems(commands)
xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, isFolder=False)
xbmcplugin.endOfDirectory(addon_handle)
elif mode[0] == 'file':
url = args['file'][0]
li = xbmcgui.ListItem(url, iconImage=url)
xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li)
xbmcplugin.endOfDirectory(addon_handle)