[RELEASE] Export Watched Data - Backup your watched status
#74
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

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
Reply


Messages In This Thread
[No subject] - by iDude - 2009-12-04, 15:17
[No subject] - by tikkiew - 2009-12-05, 20:58
[No subject] - by JustinAiken - 2010-05-29, 16:19
[No subject] - by Fox - 2010-09-17, 22:43
[No subject] - by asr82 - 2010-11-05, 16:49
[No subject] - by ubuntuf4n - 2010-11-12, 04:17
[No subject] - by olympia - 2010-11-12, 08:44
[No subject] - by ubuntuf4n - 2010-11-12, 18:00
[No subject] - by Fox - 2010-11-17, 09:31
[No subject] - by thica - 2011-01-18, 09:29
[No subject] - by castortray - 2011-01-22, 23:41
[No subject] - by Fox - 2011-01-24, 21:37
[No subject] - by bigbear77 - 2011-07-22, 17:47
[No subject] - by Fox - 2011-07-22, 18:52
[No subject] - by bigbear77 - 2011-07-23, 12:56
[No subject] - by Fox - 2011-07-23, 13:57
[No subject] - by Shinu - 2011-08-02, 02:41
[No subject] - by Fox - 2011-08-02, 11:25
[No subject] - by Shinu - 2011-08-02, 21:51
[No subject] - by Fox - 2011-08-02, 21:56
[No subject] - by Shinu - 2011-08-02, 22:04
[No subject] - by Fox - 2011-08-02, 22:07
[No subject] - by Fox - 2011-08-04, 14:02
[No subject] - by Shinu - 2011-08-04, 21:25
[No subject] - by castortray - 2011-08-05, 00:00
[No subject] - by Fox - 2011-09-07, 14:28
[No subject] - by flobbes - 2011-09-16, 22:15
[No subject] - by Fox - 2011-09-26, 08:22
[No subject] - by XmemphistoX - 2011-09-28, 08:59
[No subject] - by Fox - 2011-09-28, 09:02
[No subject] - by XmemphistoX - 2011-09-28, 09:04
[No subject] - by azgul - 2011-10-09, 23:46
[No subject] - by Fox - 2011-10-10, 08:20
Updates. - by Weatherman - 2011-11-20, 23:30
[No subject] - by Fox - 2011-11-21, 10:14
Exporting - by Weatherman - 2011-11-21, 17:03
[No subject] - by olympia - 2011-11-21, 17:20
[No subject] - by Fox - 2011-11-21, 17:43
[No subject] - by JustinAiken - 2011-11-21, 18:47
[No subject] - by olympia - 2011-11-21, 21:01
[No subject] - by Weatherman - 2011-11-22, 02:09
[No subject] - by pko66 - 2011-11-24, 15:22
[No subject] - by Fox - 2012-01-10, 15:33
[No subject] - by Ecwfrk - 2012-01-15, 18:30
[No subject] - by Fox - 2012-01-15, 21:46
[No subject] - by Fox - 2012-01-17, 15:37
nice one - by jeanbraye - 2012-01-25, 21:59
[No subject] - by JustinAiken - 2012-02-15, 01:36
[No subject] - by Fox - 2012-02-15, 09:11
[No subject] - by Fox - 2012-02-15, 10:07
[No subject] - by JustinAiken - 2012-02-15, 16:33
[No subject] - by Fox - 2012-02-15, 16:52
[No subject] - by JustinAiken - 2012-02-17, 02:57
[No subject] - by Fox - 2012-02-17, 10:11
[No subject] - by JustinAiken - 2012-02-17, 19:47
[No subject] - by Fox - 2012-02-17, 20:43
RE: [RELEASE] Export Watched Data - Backup your watched status - by BlackSack - 2012-12-30, 20:27
Logout Mark Read Team Forum Stats Members Help
[RELEASE] Export Watched Data - Backup your watched status1