2012-12-30, 20:27
Here is a Python script that I quickly whipped up when I saw the current script is not compatible with FRODO.
This script is for interacting with a MySQL implementation ONLY however you can easily change it to talk to the local SQlite database instead, SQL queries will be the same.
This will basically do the same thing, query all files that are "watched", save the play count, date watched and name to a file then when you import lookup each file by name and mark it as watched - simple!
You will need MySQL connector for python.
http://pastebin.com/gNvK2LNg
Enjoy!
Tom
This script is for interacting with a MySQL implementation ONLY however you can easily change it to talk to the local SQlite database instead, SQL queries will be the same.
This will basically do the same thing, query all files that are "watched", save the play count, date watched and name to a file then when you import lookup each file by name and mark it as watched - simple!
You will need MySQL connector for python.
http://pastebin.com/gNvK2LNg
Code:
import MySQLdb as mdb
import sys
import cPickle
# change to import for import and export for export
MODE = "import"
try:
#enter your MySQL server ip address here and your username/password will be xbmc/xbmc if you used guide on the wiki
con = mdb.connect('192.168.1.10', 'xbmc', 'xbmc');
cur = con.cursor()
if MODE == "export":
cur.execute('SELECT strFileName, lastPlayed, playCount FROM mainvideo75.files WHERE playCount >= 1 and strFileName != "";')
rows = cur.fetchall()
for row in rows:
print row
cPickle.dump(rows, open('watchedItems.p', 'wb'))
print "Exported"
else:
rows = cPickle.load(open('watchedItems.p', 'rb'))
for row in rows:
qu = "UPDATE `mainvideo75`.`files` SET playCount = {}, lastPlayed = '{}' WHERE strFileName= '{}';".format(row[2],con.escape_string(row[1]),con.escape_string(row[0]))
cur.execute(qu)
print con.info() ,", Command ::> ", qu
con.commit()
print "Imported"
print con.info()
except mdb.Error, e:
print "Error %d: %s" % (e.args[0],e.args[1])
sys.exit(1)
finally:
if con:
con.close()
Enjoy!
Tom