[RELEASE] Export Watched Data - Backup your watched status
#86
thanks!

(2013-01-30, 17:42)sargorn Wrote: "Easy" is relative. Probably would've been easier if I knew python.
Anyway,

Code:
#!/usr/bin/python
import sqlite3 as mdb
import sys
import cPickle

# args [import/export] [/path/database]
MODE = sys.argv[1]
dbname = sys.argv[2]

try:

    con = mdb.connect(dbname);
    cur = con.cursor()
    
    if MODE == "export":
       cur.execute('SELECT strFileName, lastPlayed, playCount FROM main.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:
          cur.execute("UPDATE main.files SET playCount = ?, lastPlayed = ? WHERE strFileName= ?;",(row[2], row[1],row[0]))
       con.commit()
       print "Imported"
        
except mdb.Error, e:
    print "Error:" , e.args[0]
    sys.exit(1)
    
finally:    
    if con:    
        con.close()

Save it as xbmcwatched.py
chmod u+x xbmcwatched.py
./xbmcwatched.py export /home/user/.xbmc/userdata/Database/MyVideos75.db
./xbmcwatched.py import /home/user/.xbmc/userdata/Database/MyVideos75.db

Export creates watchedItems.p
Import reads from watchedItems.p
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 ezechiel1917 - 2013-03-17, 21:20


Logout Mark Read Team Forum Stats Members Help
[RELEASE] Export Watched Data - Backup your watched status1
This forum uses Lukasz Tkacz MyBB addons.