PDA

View Full Version : [DOWNLOAD] MediaAssistent - XBMC Media Flagging Script


motyR
2009-04-12, 21:19
Hi,
i've being spending some time in the last few days writing xbmc script for configuring the media flags that aeon and alike can present, my main purpose here is to be able doing it all from within xbmc using the remote so was trying to utilising xbmc as much as i can.
the script will depend on the nfo's that xbmc produce during the "export to library" function, those are the nfo's that the media tags are going to be written to.
it will first look for the movies paths and names in the database video34db, for tags discovery the script is using MediaInfo metadata extractor as well as scanning for possible tags in the filename, after doing so it will output the extra data to the appropriate nfo file.

in order to to be able to see all those extra tags in aeon here is what u should do:
A - if u don't already have nfo's based library, first u need to export all the nfo's and pix files that xbmc configured during the content scan or while updating the library, u do that by using xbmc's function "export to library" then choose to export all tbn and alike as well as nfo to separate files.
B - run the script,it will scan the DB for the right nfo paths and will output all the extra info to the <studio> tag.
C - browse to your movie library, delete everything in there by setting the content to none.
D - now reload the library again by setting the content as it was prior to the library deletion and rescan it, this time xbmc will use the exported nfo and pix files so it will take place immediately

if it all went well u should see the extra tags with aeon
the script was tested only on linux and would not run under windows.
if u encounter any problems please use the debug log.
hope u'll make any use of it.:grin:

changelog:
- after some time playing with it, it turns out that Mediainfo would be way better for tags discovery, so hachoir was replaced by MediaInfo, it took a while to port it to xbmc's python 2.4 but all seems fine now.
- the writing procedure to the xml files was replaced as well, StringIO will be used instead of elementTree, there are way to many xml files which reports utf-8 but actually not so and therefore making elementTree to failed writing to those files.

a word for win users:
the script would not run on win box'es, there few binaries that needs to be hunt down and i don't really have any win machine to test it on, so i've figured that i would leave it as a linux script(there are few other win apps that can accomplished the task any way).
if there is some win python coder who willing to port it over, i'll be glad to help.

download 0.2.1: http://dl.getdropbox.com/u/283941/Media%20Assistant-0.2.1.rar

nc88keyz
2009-04-12, 22:27
cant figure out the error,

posted debug log below for your reference. thanks

motyR
2009-04-12, 22:44
10x, something is wrong with "Me dia Assistent" should be "Me dia Assistent".

nc88keyz
2009-04-12, 22:45
Traceback (most recent call last):
15:42:24 T:4856 M:1370124288 NOTICE: File "C:\Users\nc88keyz\AppData\Roaming\XBMC\scripts\Med ia Assistent\default.py", line 2, in ?
15:42:24 T:4856 M:1370124288 NOTICE:
15:42:24 T:4856 M:1370124288 NOTICE: from SqliteHandler import SqliteHandler
15:42:24 T:4856 M:1370124288 NOTICE: File "C:\Users\nc88keyz\AppData\Roaming\XBMC\scripts\Med ia Assistent\SqliteHandler.py", line 1, in ?
15:42:24 T:4856 M:1370124288 NOTICE:
15:42:24 T:4856 M:1370124288 NOTICE: from pysqlite2 import dbapi2 as sqlite
15:42:24 T:4856 M:1370124288 NOTICE: File "C:\Users\nc88keyz\AppData\Roaming\XBMC\scripts\Med ia Assistent\pysqlite2\dbapi2.py", line 27, in ?
15:42:24 T:4856 M:1370124288 NOTICE:
15:42:24 T:4856 M:1370124288 NOTICE: from pysqlite2._sqlite import *
15:42:24 T:4856 M:1370124288 NOTICE: ImportError
15:42:24 T:4856 M:1370124288 NOTICE: :
15:42:24 T:4856 M:1370124288 NOTICE: No module named _sqlite
15:42:24 T:4856 M:1370124288 NOTICE:
15:42:24 T:4856 M:1370124288 ERROR: Scriptresult: Error

logfile

motyR
2009-04-12, 22:55
10x for your help nc88keyz,

i guess the problem is that in linux it loads _sqlite.so from /Media Assistent/pysqlite2, but theres no eqviliant dll for windows there,
i'll have a look.

nc88keyz
2009-04-12, 23:02
ok , ill look forward to an update then. looked nice since it works off the xbmc video.db and therefore wouldnt have an issues like the other program with movies in one folder vs seperate.

I think anyways....but im no programmer or debugger for that matter

there is an sqlite3.dll

for windows binaryf ro sqlite explorer i think...

motyR
2009-04-12, 23:30
yes many issues been escaped by using the DB.
anyway i just saw how does AMT supply the sqlite dll within the rar, so i'll have a fix for that soon, till then it's not really usable for windows, i'll edit the first post.

10x again for your help.

lx01
2009-04-12, 23:46
Works great on Fedora 10!:)

Doesn't read the video resolution, but after taking a quick peek at the code, it looks to me that this simply isn't implemented yet?

motyR
2009-04-12, 23:59
Ha glad to hear it :grin:
the thing is that when i extract the resolution data from the metadata within the file then it only reports 720 or 1280 but not 720i or 720p
so i have no certain way to be sure about it, all though if the resolution it's found in the file name then it will be picked(hopefully).

sensei73
2009-04-12, 23:59
deleted== working=

motyR
2009-04-17, 15:42
0.2 was uploaded, please have a look at the first post for more info.

theophile
2009-04-17, 15:58
Not to be overly picky, but the word is spelled "assistant."

motyR
2009-04-17, 16:00
:laugh:

10x

lx01
2009-04-17, 19:53
Not to be overly picky, but the word is spelled "assistant."
Not in germany;)

lx01
2009-04-17, 22:03
Ok, got this:


[...]
20:29:29 T:2867301264 M:777740288 NOTICE: File "/home/mythtv/.xbmc/scripts/Media Assistent/libs/MediaInfo/MediaInfoDLL.py", line 37, in ?
20:29:29 T:2867301264 M:777740288 NOTICE:
20:29:29 T:2867301264 M:777740288 NOTICE: MediaInfoDLL_Handler = CDLL("/home/moty/Workspace/python/projects/MediaAssistent/src/libs/MediaInfo/libmediainfo.so.0")
[...]
20:29:29 T:2867301264 M:777740288 NOTICE: /home/moty/Workspace/python/projects/MediaAssistent/src/libs/MediaInfo/libmediainfo.so.0: cannot open shared object file: No such file or directory


Fixed it myself by replacing line 37 in libs/MediaInfo/MediaInfoDLL.py with this one:

MediaInfoDLL_Handler = CDLL(os.path.join(os.getcwd(),"libs","MediaInfo","libmediainfo.so.0"))


But now i get an error about a missing libzen.so.0 (which seems to be linked to by libmediainfo.so.0).

So, WTF is "libzen" and where do i get it?:)

Update:
There simply seems to be no libmediainfo/libzen in fedora's default repos, so i installed libzen from here:
http://mediainfo.sourceforge.net/en/Download#Fedora_10.i386

But now only 1 file gets scanned. After that the scripts ends without errors..

motyR
2009-04-17, 23:59
amm i left the /home/moty path, damn
any way i'll bundle it all and upload it soon
10x and nice catch BTW

kautious
2009-04-18, 02:21
Does this run on the xbox???? Because everytime I run it I get:
" Error Python script failed: Q:\scripts\Media Assisten\default.py"
Then it freezes my box.

lx01
2009-04-18, 02:27
About my "only 1 file gets scanned" issue:
It seemed to have something to do with special characters in the <studio>-tag (it was a french "é" in this case), but after some fiddling with the nfo-file in question i cannot reproduce this anymore.. strange..

Does this run on the xbox???? Because everytime I run it I get:
" Error Python script failed: Q:\scripts\Media Assisten\default.py"
Then it freezes my box.

From first post:
a word for win users:
the script would not run on win box'es, there few binaries that needs to be hunt down and i don't really have any win machine to test it on, so i've figured that i would leave it as a linux script
My guess is this also applies to xbox (and probably mac)

motyR
2009-04-18, 03:08
Hi lx01,
ok i've hunt down the problem, it seems that when ever linux ctypes is loading shared object it search for it in the ldconfig path which faced a problem for me since i want to supply all the external libs with in my package, so i had to patch ctypes a bit to make it work correctly.

now about your second problem, i've switched over from xml parsing just because this issue so if u can reproduce it please let me know, and offcourse your overall impression whether the script gets the job done.

any way i'm uploading the fixed one please test it if u can.

and no it would not run on xbox(i think) but as said i know exactly how to solve the problem but i need some help from some win python coder who can test it.

download: http://dl.getdropbox.com/u/283941/Media%20Assistant-0.2.1.rar

BTW it could be that the supplied mediainfo lib and your libzen are not from the same version so i guess it would be wize to uninstall libzen, all the extra libs are allready supplied within the package so that it would work without any external deps.

lx01
2009-04-18, 04:13
About the library problem:
Deinstalled libzen, installed your new version, works great:)

About the special char problem:
I think i just hit another bug while trying to reproduce the problem, but on the other hand i just realized that i'm currently way too tired to do or write anything that makes sense (3am here). So i will go to bed first and try tomorrow...

lx01
2009-04-18, 19:00
After trying some more, i think it's either a xbmc bug or something's wrong with my current build:
If i run the FileHandler from cli ("python MediaAssistant/FileHandler.py") after modifying it to point to the nfo-file in question, everything's ok.

Oh, and:
Found some (unimportant) typo in various files: It's called "Codec", not "Codeck";)

hotlobster
2009-04-26, 12:34
Hello

I've tryed this script with latest svn on Debian 5.

After i click on yes for scanning content, script stops and xbmc is locked:

here are my logs: http://pastebin.com/f48f7a6d0