Matching XBE Title to Title in Titlemeta.xbx
#1
Im currently writing a script that reads apps/emu directories and tries to match them against the corresponding UDATA directory.

This works but in some instances the XBE Title does not match the Text in TitleMeta.xbx

Here is my Sample code:
Code:
import os,struct,operator,codecs,string

home    = os.getcwd()
apps    = home +'\\apps'
emus    = home +'\\emus'
tdata   = home +'\\UDATA'

def GetXbeName(path,XbeTitle,XbePath):
    for i in os.listdir(path):
        mybase = path+'\\'+ i
        if os.path.isdir(mybase):
            mydef = mybase +'\\default.xbe'
            if os.path.isfile(mydef):
                RealName = ''
                xbe = open(mydef,'rb')
                xbe.seek(0x0184,0)
                for dta in struct.unpack(operator.repeat('H',40),xbe.read(0x0050)):
                    try     :
                        if dta != 00  :   RealName += str(unichr(dta))
                    except  :   pass
                XbeTitle.append(RealName)
                XbePath.append(mybase)
                xbe.close()
    return XbeTitle,XbePath

def GetXbeSave(path):
    Title   =   []
    Id      =   []
    for i in os.listdir(path):
        mybase = path+'\\'+ i
        if os.path.isdir(mybase):
            mydef = mybase +'\\TitleMeta.xbx'
            if os.path.isfile(mydef):
                try :
                    xbe = codecs.open(mydef,'r','utf-16')
                    data = xbe.read()
                except  :
                    xbe.close()
                    xbe = open(mydef,'r')
                    data = xbe.read()
                if data[0:10] == 'TitleName=':
                    Title.append(string.strip(data[10:60],'\n\r'))
                    Id.append(mybase)
                xbe.close()
    return Title,Id


XbeTitle,XbePath = GetXbeName(apps,[],[])
XbeTitle,XbePath = GetXbeName(emus,XbeTitle,XbePath)
Title,Id = GetXbeSave(tdata)

FullArray   =   []
for Item in range(len(XbeTitle)):
    try     :   Result  =   Title.index(XbeTitle[Item])
    except  :   Result  =   -1
    if Result == -1 :   print 'Cannot Find: '+ str(XbeTitle[Item])
    else            :   FullArray.append([XbeTitle[Item],XbePath[Item],Title[Result],os.path.basename(Id[Result])])
    

for i in FullArray:
    print i[0],i[1],i[2],i[3]

Here is my Output:
Code:
Cannot Find: Dvd 2 Xbox
Cannot Find: DVD Player
Cannot Find: Evo-X Dash
Cannot Find: Web Browser
Cannot Find: UnleashX Dash
Cannot Find: z26x
Xbox Media Center E:\XBOX - Stuff\XBOX-E\apps\XBMC Xbox Media Center 0face008
vicex E:\XBOX - Stuff\XBOX-E\emus\Commodore-64 vicex 07162006
MAMEoX Launcher E:\XBOX - Stuff\XBOX-E\emus\MAMEoX MAMEoX Launcher 4d414d45
Surreal 64 E:\XBOX - Stuff\XBOX-E\emus\N64 Surreal 64 a64fea57
mednafenx_nes E:\XBOX - Stuff\XBOX-E\emus\Nintendo mednafenx_nes 03182006
NeoGenesis E:\XBOX - Stuff\XBOX-E\emus\SegaMegaDrive NeoGenesis 02282006
ZsnexBox E:\XBOX - Stuff\XBOX-E\emus\SuperNintendo ZsnexBox 00000000

Heres the problematic ones..
XbeTitle = Dvd 2 Xbox - TitleMeta = dvd2xbox
XbeTitle = Web Browser - TitleMeta = LinksBoks
XbeTitle = UnleashX Dash - TitleMeta = UnleashX Xbox Launcher

Basically What im asking is what links the xbe to the gamesave directory. Is there something in the xbe header that identifies the directory to create. I have looked at alot of xbe header info but cannot find anything that states a link between the two..

Any Help appreciated..
I know that the latest version does support getting the xbetitle in python but for those on 2.0.1 this feature will not be present..
Server: FreeNas 9 NAS: 6*3TB - Kodi Sql Database
Kodi Systems: Nvidia Shield Pro, G-Box Q (OpenElec), RikoMagic MK802 IV[
Skin: reFocus
Reply
#2
bump!

Surely someone knows the answer to this or even point me to where I can find the c code in the xbmc svn so I can try and rework a python version..
Server: FreeNas 9 NAS: 6*3TB - Kodi Sql Database
Kodi Systems: Nvidia Shield Pro, G-Box Q (OpenElec), RikoMagic MK802 IV[
Skin: reFocus
Reply
#3
Here is a script based on what the newer versions of xbmc do but for those still on 2.0.1 who have not got the ability builtin.

Basically call it with the full xbe path and it will return a dictionary with the following keys:
'Path' = Full Path name sent to the procedure.
'Title' = Title of the XBE from inside the file.
'Id' = Id of the xbe. This will match upto the corresponding directory in UDATA.

This script was basically a conversion of what XBMC's procedure does..

Anyho heres the script ofr those interested..:
Code:
import os,struct,operator,string

def XbeInfo(FileName):
    try :
        XbeDta          =   {}
        if os.path.isfile(FileName) and FileName.endswith('.xbe')   :
            xbe         =   open(FileName,'rb')
            ## Get XbeId Data ##
            xbe.seek(0x104)
            tLoadAddr   =   xbe.read(4)
            xbe.seek(0x118)
            tCertLoc    =   xbe.read(4)
            LoadAddr    =   struct.unpack('L',tLoadAddr)
            CertLoc     =   struct.unpack('L',tCertLoc)
            CertBase    =   CertLoc[0] - LoadAddr[0]
            CertBase    +=  8
            IdStart     =   xbe.seek(CertBase)
            tIdData     =   xbe.read(4)
            IdData      =   struct.unpack('L',tIdData)
            ## Get Xbe Title ##
            XbeTitle    =   ''
            for dta in struct.unpack(operator.repeat('H',40),xbe.read(0x0050)):
                try     :
                    if dta != 00  :   XbeTitle += str(unichr(dta))
                except  :   pass
            XbeDta['Title']     =   str(XbeTitle)
            XbeDta['Id']        =   str(hex(IdData[0])[2:-1]).lower().rjust(8,'0')
            XbeDta['Path']      =   str(FileName)
            xbe.close()
        return XbeDta
    except  :
        xbe.close()
        return {}
Server: FreeNas 9 NAS: 6*3TB - Kodi Sql Database
Kodi Systems: Nvidia Shield Pro, G-Box Q (OpenElec), RikoMagic MK802 IV[
Skin: reFocus
Reply
#4
Try to contact "Donno". He wrote a game save manager for xbmc (python).

Sollie.
Image
Reply

Logout Mark Read Team Forum Stats Members Help
Matching XBE Title to Title in Titlemeta.xbx0