• 1
  • 3
  • 4
  • 5
  • 6(current)
  • 7
[RELEASE] Export Watched Data - Backup your watched status
#76
"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
#77
Sargorn,
This looks like it is EXACTLY what I am looking for!
Unfortunatly I dont know how to do anything with scripts beyond installing an add-on from zip and running through programs.
Any chance of compling your code to an easy to use zip or pointing me in a direction to learn how to execute the code you have provided in XBMC?

Sorry if this is a pain in the ass newbie question, but i'd really love to export my watched list, update to frodo and restore my watched list and i'm not sure how to do it. Your solution seems like the answer but I dont know how to run it.

Thank you for all your help!
Reply
#78
(2013-02-01, 17:56)lancewindew Wrote: Sargorn,
This looks like it is EXACTLY what I am looking for!
Unfortunatly I dont know how to do anything with scripts beyond installing an add-on from zip and running through programs.
Any chance of compling your code to an easy to use zip or pointing me in a direction to learn how to execute the code you have provided in XBMC?

Sorry if this is a pain in the ass newbie question, but i'd really love to export my watched list, update to frodo and restore my watched list and i'm not sure how to do it. Your solution seems like the answer but I dont know how to run it.

Thank you for all your help!

I don't really have the time to figure out how to run it directly from xbmc.

If you let us know what you're running xbmc on top of I'm sure someone could step by step it.

Basically though,
* Open a terminal window (command prompt).
* type: nano xbmcwatched.py
* paste in everything under "code:" above.
* hit Ctrl+O and then Enter to save.
* hit Ctrl+X to exit.
* type: chmod u+x xbmcwatched.py
* type: ./xbmcwatched.py export ~/.xbmc/userdata/Database/MyVideos60.db
(pretty sure EDEN was MyVideos60.db)
* This will create a new file in your current directory - watchedItems.p.
* If you're doing a fresh install, back up watchedItems.p.

Once you've installed Frodo:
Copy watchedItems.p back to your current directory and open up the terminal again.
type: ./xbmcwatched.py import /home/user/.xbmc/userdata/Database/MyVideos75.db
(MyVideos75.db is the new database file for frodo).


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

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

Looks like you figured it out even so Tongue
Reply
#80
(2013-02-11, 18:52)BlackSack Wrote:
(2013-01-30, 17:42)sargorn Wrote: "Easy" is relative. Probably would've been easier if I knew python.

Looks like you figured it out even so Tongue

Odd tuple errors and python's sqlite not having similar methods as mysql (no .info() ) made things take longer than they should have.

Almost gave up and re-wrote in perl. Wink
Reply
#81
Sargorn, I'm running XBMC over windows 7 64bit, I assume all those fancy terminal commands to activate the python are for use in a linux environment and so this wont work for me.

*EDIT: Ha ha, I just read my post - "activate the python"
Reply
#82
For those Windows users like me who prematurely upgraded to Frodo before checking if they could take this fantastic little add-on with them, I have created this small .net application.

It can import the old watched.xml file created by the ExportWatchedData add-on into Frodo, and can also export back out to a similar xml file. The only limitations being that it is only for those that have a MySQL back-end for XBMC, and it isn’t an XMBC add-on.
You may need to install the MySQL connector for .net:

http://dev.mysql.com/downloads/connector/net/

Please feel free to use it and comment. I’ve packed it all up into a zip file, including the source code for anyone interested. Thanks to BlackSack for the SQL statements that I shamelessly stole.

As for the settings – I think they’re pretty straight forward. The Username and Password are normally both ‘xbmc’.

Here is the download:

http://www.2shared.com/file/4ZzeCWIg/XBM...er_10.html

Hope this helps!

edit: see my later post for an updated version
Reply
#83
(2013-02-12, 15:49)sargorn Wrote:
(2013-02-11, 18:52)BlackSack Wrote:
(2013-01-30, 17:42)sargorn Wrote: "Easy" is relative. Probably would've been easier if I knew python.

Looks like you figured it out even so Tongue

Odd tuple errors and python's sqlite not having similar methods as mysql (no .info() ) made things take longer than they should have.

Almost gave up and re-wrote in perl. Wink

I ran your export script in Frodo (MyVideos75.db), deleted, relocated, re-scraped. I then ran the import function of your script ./xbmcwatched.py import /home/useromitted/.xbmc/userdata/Database/MyVideos75.db
Error: no such table: main.files

I checked the file watchedItems.p and it has all the shows and movies I have watched, it just seems it's not importing them properly. I am using the MySQL shared library, so is there something I should be doing differently?

Edit: I tried backing up watchedItems.p and re running the export script on the newly created database, and it created the same :Error: no such table: main.files" message. This is weird. I may have to just start my watched list again and plan better next time.
Reply
#84
(2013-03-02, 22:35)bmac88 Wrote:
(2013-02-12, 15:49)sargorn Wrote:
(2013-02-11, 18:52)BlackSack Wrote: Looks like you figured it out even so Tongue

Odd tuple errors and python's sqlite not having similar methods as mysql (no .info() ) made things take longer than they should have.

Almost gave up and re-wrote in perl. Wink

I ran your export script in Frodo (MyVideos75.db), deleted, relocated, re-scraped. I then ran the import function of your script ./xbmcwatched.py import /home/useromitted/.xbmc/userdata/Database/MyVideos75.db
Error: no such table: main.files

I checked the file watchedItems.p and it has all the shows and movies I have watched, it just seems it's not importing them properly. I am using the MySQL shared library, so is there something I should be doing differently?

Edit: I tried backing up watchedItems.p and re running the export script on the newly created database, and it created the same :Error: no such table: main.files" message. This is weird. I may have to just start my watched list again and plan better next time.

The SQL update command I use in my .net solution is slightly different - it uses 'myvideos75.files' instead of 'main.files'. Perhaps trying that will help.
Reply
#85
(2013-03-03, 12:43)hop6919 Wrote: The SQL update command I use in my .net solution is slightly different - it uses 'myvideos75.files' instead of 'main.files'. Perhaps trying that will help.

For MySQL installs the table is myvideos75.files
For SQLite installs the table is main.files

(2013-03-02, 22:35)bmac88 Wrote:
(2013-02-12, 15:49)sargorn Wrote:
(2013-02-11, 18:52)BlackSack Wrote: Looks like you figured it out even so Tongue

Odd tuple errors and python's sqlite not having similar methods as mysql (no .info() ) made things take longer than they should have.

Almost gave up and re-wrote in perl. Wink

I ran your export script in Frodo (MyVideos75.db), deleted, relocated, re-scraped. I then ran the import function of your script ./xbmcwatched.py import /home/useromitted/.xbmc/userdata/Database/MyVideos75.db
Error: no such table: main.files

I checked the file watchedItems.p and it has all the shows and movies I have watched, it just seems it's not importing them properly. I am using the MySQL shared library, so is there something I should be doing differently?

Edit: I tried backing up watchedItems.p and re running the export script on the newly created database, and it created the same :Error: no such table: main.files" message. This is weird. I may have to just start my watched list again and plan better next time.

Hi,

My script was modded for SQLite. If you're using MySQL use BlackSack's original script. (note that the syntax is different, but the output file format is the same. (your generated file should work iirc).

(2013-02-18, 21:10)lancewindew Wrote: Sargorn, I'm running XBMC over windows 7 64bit, I assume all those fancy terminal commands to activate the python are for use in a linux environment and so this wont work for me.

*EDIT: Ha ha, I just read my post - "activate the python"

If you're using MySQL and windows hop6919's .NET app should work for you.

Otherwise, there's always http://www.python.org/getit/windows/

Then you can play with the python all you like... on windows.
Reply
#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
#87
Here is an update to the .NET app that I wrote a little while ago. It can now set the watched flag for XBMC videos in either a shared MySQL library or the normal local SQLite .db file.

You can use this app in Frodo to import the watched.xml file created by the old add-on, and also export back out a similar xml file.

You don't need to install anything else as I've included all the dlls in the app folder. Source code is also included for anyone interested.

The local .db file doesn't need a password, but the username and password for the shared library is normally ‘xbmc’.

Here is the download:

http://code.google.com/p/xbmc-frodo-watc...loads/list

Hope it helps
Reply
#88
Hi

I am in need of exporting my watched tags as I need to remove my movie library and re-import. I am using a MYSQL database (5.5) and Frodo.

I have tried to run your utility on my server and used 127.0.0.1 as the IP, and used my xbmc username and PW (both just xbmc).

I set a file name to write to and click EXPORT but nothing seems to happen at all. I also tried to change the 127.0.0.1 to my server IP but still nothing. There are no logs created so not sure what else I can do. Any ideas? Do I need to try it on a different PC running XBMC or should it just connect directly to the DB?
Reply
#89
(2013-04-26, 09:52)phsyraxion Wrote: Hi

I am in need of exporting my watched tags as I need to remove my movie library and re-import. I am using a MYSQL database (5.5) and Frodo.

I have tried to run your utility on my server and used 127.0.0.1 as the IP, and used my xbmc username and PW (both just xbmc).

I set a file name to write to and click EXPORT but nothing seems to happen at all. I also tried to change the 127.0.0.1 to my server IP but still nothing. There are no logs created so not sure what else I can do. Any ideas? Do I need to try it on a different PC running XBMC or should it just connect directly to the DB?

Sorry you are having problems. You could try entering the external IP address for the server, instead of 127.0.0.1 - that's how I do it. You do need to specify a file to export to as well, by clicking the select file button.

Ill have to test it when I get a chance, and add some error logging to the app too.
Reply
#90
(2013-04-26, 10:28)hop6919 Wrote: Sorry you are having problems. You could try entering the external IP address for the server, instead of 127.0.0.1 - that's how I do it. You do need to specify a file to export to as well, by clicking the select file button.

Ill have to test it when I get a chance, and add some error logging to the app too.

Oops - I was at work when I read your post so didn't read your post properly. I would say that this is a problem with my app - the database name is different in Frodo to Eden, but is hard coded in my app. Ill look into changing it, but I believe that when you install Frodo over Eden it creates another database and transfers all your watched statuses over.
Reply
  • 1
  • 3
  • 4
  • 5
  • 6(current)
  • 7

Logout Mark Read Team Forum Stats Members Help
[RELEASE] Export Watched Data - Backup your watched status1