My steps to improving the addon compatiblity

Discussion of XBMC4XBOX development.
Post Reply
skatulskijean
Posts: 1028
Joined: Wed Jul 04, 2012 8:01 am
Has thanked: 1 time
Been thanked: 148 times

My steps to improving the addon compatiblity

Post by skatulskijean » Sat Oct 18, 2014 10:33 am

Xbmc4xbox 3.5 is most compatible as the xbmc4xbox build before but with this little steps you improve the main-xbmc addon compatibility.

First most main xbmcaddons using xbmcvfsFile as example gomovies , burningseries (from my friend chmee) and many more but on xbmc4xbox is the the xbmccvfsFile class on the xbmcvfs.py not aviable:

So i added the Fileclass to xbmcvfs.py and the access over the xbmcvfsFile is on xbmc4xbox 3.5 working to:

Code new xbmcvfs.py with the integrated File class:

Code: Select all

"""
    module xbmcvfs for xbox and/or dharma
"""

import os
import xbmc


def _encode( text, encoding='utf-8' ):
    try: text = text.encode( encoding )
    except: pass
    return text


def exists( filename ):
    """ exists(path)

        path        : file or folder
        example:
          success = xbmcvfs.exists(path)
    """
    msg = 'false'
    if filename:
        filename = _encode( filename )
        msg = xbmc.executehttpapi( "FileExists(%s)" % ( filename ) ).replace( "<li>", "" ).lower()
        xbmc.log( "[xbmcvfs] %s, exists(%s)" % ( msg, filename ), xbmc.LOGDEBUG )
    return ( msg == 'true' )


def copy( source, destination ):
    """ copy(source, destination) -- copy file to destination, returns true/false.

        source          : file to copy.
        destination     : destination file
        example:
          success = xbmcvfs.copy(source, destination)
    """
    msg = xbmc.executehttpapi( "FileCopy(%s,%s)" % ( source, destination ) ).replace( "<li>", "" )
    xbmc.log( "[xbmcvfs] %s, copy(%s,%s)" % ( msg, source, destination ), xbmc.LOGDEBUG )
    return exists( destination )


def delete( filename ):
    """ delete(file)

        file        : file to delete
        example:
          xbmcvfs.delete(file)
    """
    filename = _encode( filename )
    msg = xbmc.executehttpapi( "FileDelete(%s)" % ( filename ) ).replace( "<li>", "" )
    xbmc.log( "[xbmcvfs] %s, delete(%s)" % ( msg, filename ), xbmc.LOGDEBUG )
    return ( not exists( filename ) )


def mkdir( path ):
    """ mkdir(path) -- Create a folder.

        path        : folder
        example:
         - success = xbmcvfs.mkdir(path)
    """
    try:
        #os.mkdir( path )
        os.makedirs( path )
        msg = "OK"
    except Exception, e:
        xbmc.log( "[xbmcvfs] %s" % str( e ), xbmc.LOGERROR )
        msg = "ERROR"
    xbmc.log( "[xbmcvfs] %s, mkdir(%s)" % ( msg, path ), xbmc.LOGDEBUG )
    return os.path.exists( path )

def mkdirs( path ):
    return mkdir( path )
    

def rename( oldName, newName ):
    """ rename(file, newFileName)

        file        : file to rename newFileName : new filename, including the full path
        example:
          success = xbmcvfs.rename(file,newFileName)
    """
    try:
        os.rename( oldName, newName )
        msg = "OK"
    except Exception, e:
        xbmc.log( "[xbmcvfs] %s" % str( e ), xbmc.LOGERROR )
        msg = "ERROR"
    xbmc.log( "[xbmcvfs] %s, rename(%s,%s)" % ( msg, oldName, newName ), xbmc.LOGDEBUG )
    return exists( newName )


def rmdir( path ):
    """ rmdir(path) -- Remove a folder.

        path        : folder
        example:
         - success = xbmcvfs.rmdir(path)
    """
    try:
        os.rmdir( path )
        msg = "OK"
    except Exception, e:
        xbmc.log( "[xbmcvfs] %s" % str( e ), xbmc.LOGERROR )
        msg = "ERROR"
    xbmc.log( "[xbmcvfs] %s, rmdir(%s)" % ( msg, path ), xbmc.LOGDEBUG )
    return ( not os.path.exists( path ) )


def listdir ( path ):
    """ listdir(path) -- returns a tuple containing separate lists of directory and file names in given path.

        example:
          dirs, files = xbmcfs.listdir(path)
    """
    xbmc.log( "[xbmcvfs] listdir(%s)" % ( path ), xbmc.LOGDEBUG )
    listdir = os.listdir( path )
    dirs    = [ d for d in listdir if os.path.isdir ( os.path.join( path, d ) ) ]
    files   = [ f for f in listdir if os.path.isfile( os.path.join( path, f ) ) ]
    return dirs, files


class File:

	def __init__(self, path, mode='r'):
		self.path = path;
		self.file = open(self.path, mode)

	def read(self, n=-1):
		return self.file.read(n)

	def write(self, b):
		return self.file.write(b)

	def size(self):
		return os.path.getsize(self.path)

	def seek(self, offset, whence=0):
		return self.file.seek(offset, whence)

	def close(self):
		self.file.close()
Second Most main xbmc addons since not working while she simple want to access the addon_data Folder on the UserData Folder but xbmc4xbox have the Folder not so the addons give a scripterror.
Yes we can fix that and change the Code from this addons to access the plugin_data Folder but we must fix that on the addon code self .
A better solution is simple create the addon_data Folder under UserData and we have nothing to fix on the addon Code self.

User avatar
sahib12
Posts: 285
Joined: Wed Jan 02, 2013 3:13 pm
Location: Liberty City
Has thanked: 8 times
Been thanked: 16 times
Contact:

Re: My steps to improving the addon compatiblity

Post by sahib12 » Sun Oct 19, 2014 7:48 pm

glad to see you back jan...
Image

skatulskijean
Posts: 1028
Joined: Wed Jul 04, 2012 8:01 am
Has thanked: 1 time
Been thanked: 148 times

Re: My steps to improving the addon compatiblity

Post by skatulskijean » Sat Nov 01, 2014 6:50 am

With the TotalInstall4xbox

You want not copy the code or add the Folders what most main xbmc wants to your xbmc4xbox.
He do that all and many more .

skatulskijean
Posts: 1028
Joined: Wed Jul 04, 2012 8:01 am
Has thanked: 1 time
Been thanked: 148 times

Re: My steps to improving the addon compatiblity

Post by skatulskijean » Thu Nov 06, 2014 9:24 am

All new steps to improving the addon compatibilty on xbmc4xbox.
working on future only when you install over the TOTALXBMCINSTALLER4xbox.
It is then A huge differend when you install a addon over the addon4xbox Installer or manual the addons since not working only with the Install over the TotalxbmcInstaller can you cleanup this fucking isue.

self with the Testversion its improve the addon compatibilty .

excample all addons what will have a newer xbmcwift Version xbmcswift2
working only over the Install with the TotaslxbmcInstaller4xbox

all addons what want xbmcvfsFile working only with the install over the TotalxbmcInstaller4xbox

all addons what wants the folder addon and packages working only with the install over the Totalxbmcinstaller4xbox

with the next release it make many more compatible but only when you use the TotalxbmcInstaller4xbox

with the next version you have a ever uptodate scriptmodule urlresolver withfixes what make it full compatible

with the next version you can install from zip

with the next version you can view the log and when it give a error you see only the error from the log on the screen

with the next version you can install xbmc4xbox builds and the winbuilds and tools what he want to develop skins for xbmc4xbox on windows to.

with the next version you can download and install skins

and i think so many more when i have the time for it.

Regards Jan

User avatar
BuZz
Site Admin
Posts: 1889
Joined: Wed Jul 04, 2012 12:50 am
Location: UK
Has thanked: 62 times
Been thanked: 422 times
Contact:

Re: My steps to improving the addon compatiblity

Post by BuZz » Thu Nov 06, 2014 4:34 pm

if you have improvements for compatibility (such as updates of the xbmcvfs module / xbmcswift2) - please submit back patches to the project.

Post Reply