Example #1
0
def get_fanart_path( database_id, type ):
    utils.log( "jsonrpc_calls.py - Retrieving Fanart Path for %s id: %s" % ( type, database_id ), xbmc.LOGDEBUG )
    if type in ( "cover", "cdart", "album" ) and database_id:
        json_query = '''{"jsonrpc": "2.0", "method": "AudioLibrary.GetAlbumDetails", "params": {"properties": ["fanart"], "albumid": %d}, "id": 1}''' % database_id
        json_fanart = retrieve_json_dict( json_query, items='albumdetails', force_log=False )
    elif type in ( "fanart", "clearlogo", "artistthumb", "artist" ) and database_id:
        json_query = '''{"jsonrpc": "2.0", "method": "AudioLibrary.GetArtistDetails", "params": {"properties": ["fanart"], "artistid": %d}, "id": 1}''' % database_id
        json_fanart = retrieve_json_dict( json_query, items='artistdetails', force_log=False )
    else:
        utils.log( "jsonrpc_calls.py - Improper type or database_id", xbmc.LOGDEBUG )
        return empty
    if json_fanart:
        return json_fanart["fanart"]
    else:
        return empty
def dirEntries( dir_name, media_type="files", recursive="FALSE", contains="" ):
    '''Returns a list of valid XBMC files from a given directory(folder)

       Method to call:
       dirEntries( dir_name, media_type, recursive )
            dir_name   - the name of the directory to be searched
            media_type - valid types: video, music, pictures, files, programs
            recursive  - Setting to "TRUE" searches Parent and subdirectories, Setting to "FALSE" only search Parent Directory
    '''
    xbmc.log( "[folder.py] - dirEntries Activated", level=xbmc.LOGDEBUG )
    fileList = []
    json_query = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"directory": "%s", "media": "%s"}, "id": 1}' % ( escapeDirJSON( dir_name ), media_type )
    json_folder_detail = retrieve_json_dict(json_query, items='files', force_log=True)
    if json_folder_detail:
        for f in json_folder_detail:
            try:
                if recursive == "TRUE" and f["filetype"] == "directory":
                    fileList.extend( dirEntries( f["file"], media_type, recursive, contains ) )
                elif not contains or ( contains and (contains in f["file"] ) ):
                    fileList.append( f["file"] )
                    #xbmc.log( "[folder.py] - File Path: %s" % f["file"], level=xbmc.LOGDEBUG ) 
                else:
                    continue
            except:
                continue
    return fileList
Example #3
0
def dirEntries( dir_name, media_type="files", recursive="FALSE", contains="" ):
    '''Returns a list of valid XBMC files from a given directory(folder)

       Method to call:
       dirEntries( dir_name, media_type, recursive )
            dir_name   - the name of the directory to be searched
            media_type - valid types: video, music, pictures, files, programs
            recursive  - Setting to "TRUE" searches Parent and subdirectories, Setting to "FALSE" only search Parent Directory
    '''
    log( "[folder.py] - dirEntries Activated" )
    fileList = []
    json_query = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"directory": "%s", "media": "%s"}, "id": 1}' % ( escapeDirJSON( dir_name ), media_type )
    json_folder_detail = retrieve_json_dict(json_query, items='files', force_log=True)
    if json_folder_detail:
        for f in json_folder_detail:
            try:
                if recursive == "TRUE" and f["filetype"] == "directory":
                    fileList.extend( dirEntries( f["file"], media_type, recursive, contains ) )
                elif not contains or ( contains and (contains in f["file"] ) ):
                    fileList.append( f["file"] )
                    #log( "[folder.py] - File Path: %s" % f["file"] ) 
                else:
                    continue
            except:
                continue
    return fileList
Example #4
0
def _movie_details(movie_id):
    movie_details = []
    utils.log("Retrieving Movie Details", xbmc.LOGNOTICE)
    json_query = '{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovieDetails", "params": {"movieid": %d, "properties": ["title", "file", "thumbnail", "streamdetails", "mpaa", "genre"]}, "id": 1}' % movie_id
    movie_details = retrieve_json_dict(json_query,
                                       items="moviedetails",
                                       force_log=False)
    return movie_details
Example #5
0
def retrieve_album_list():
    utils.log( "jsonrpc_calls.py - Retrieving Album List", xbmc.LOGDEBUG )
    json_query = '''{"jsonrpc": "2.0", "method": "AudioLibrary.GetAlbums", "params": { "limits": { "start": 0 }, "properties": ["title", "artist", "musicbrainzalbumid", "musicbrainzalbumartistid"], "sort": {"order":"ascending"}}, "id": 1}'''
    json_albums = retrieve_json_dict(json_query, items='albums', force_log=False )
    if json_albums:
        return json_albums, len(json_albums)
    else:
        return empty, 0
Example #6
0
def retrieve_artist_details( artist_id ):
    utils.log( "jsonrpc_calls.py - Retrieving Artist Details", xbmc.LOGDEBUG )
    json_query = '''{"jsonrpc": "2.0", "method": "AudioLibrary.GetArtistDetails", "params": {"properties": ["musicbrainzartistid"], "artistid": %d}, "id": 1}''' % artist_id
    json_artist_details = retrieve_json_dict(json_query, items='artistdetails', force_log=False )
    if json_artist_details:
        return json_artist_details
    else:
        return empty
def _movie_details(movie_id):
    movie_details = []
    utils.log("Retrieving Movie Details", xbmc.LOGNOTICE)
    json_query = (
        '{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovieDetails", "params": {"movieid": %d, "properties": ["title", "file", "thumbnail", "streamdetails", "mpaa", "genre"]}, "id": 1}'
        % movie_id
    )
    movie_details = retrieve_json_dict(json_query, items="moviedetails", force_log=False)
    return movie_details
Example #8
0
def retrieve_album_details( album_id ):
    utils.log( "jsonrpc_calls.py - Retrieving Album Details", xbmc.LOGDEBUG )
    album_details = []
    json_query = '''{"jsonrpc": "2.0", "method": "AudioLibrary.GetAlbumDetails", "params": {"properties": ["artist", "title", "musicbrainzalbumid", "musicbrainzalbumartistid"], "albumid": %d}, "id": 1}''' % album_id
    json_album_details = retrieve_json_dict(json_query, items='albumdetails', force_log=False )
    if json_album_details:
        album_details.append( json_album_details )
        return album_details
    else:
        return empty
Example #9
0
def get_all_local_artists( all_artists = True ):
    utils.log( "jsonrpc_calls.py - Retrieving all local artists", xbmc.LOGDEBUG )
    if all_artists:
        json_query = '''{"jsonrpc": "2.0", "method": "AudioLibrary.GetArtists", "params": { "albumartistsonly": false }, "id": 1}'''
    else:
        json_query = '''{"jsonrpc": "2.0", "method": "AudioLibrary.GetArtists", "params": { "albumartistsonly": true }, "id": 1}'''
    json_artists = retrieve_json_dict(json_query, items='artists', force_log=False )
    if json_artists:
        return json_artists
    else:
        return empty
Example #10
0
def get_album_path( album_id ):
    utils.log( "jsonrpc_calls.py - Retrieving Album Path", xbmc.LOGDEBUG )
    paths = []
    albumartistmbids = []
    albumreleasembids = []
    json_query = '''{"jsonrpc": "2.0", "method": "AudioLibrary.GetSongs", "params": { "properties": ["file", "musicbrainzalbumartistid", "musicbrainzalbumid"], "filter": { "albumid": %d }, "sort": {"method":"path","order":"ascending"} }, "id": 1}''' % album_id
    json_songs_detail = retrieve_json_dict(json_query, items='songs', force_log=False )
    if json_songs_detail:
        for song in json_songs_detail:
            path = os.path.dirname( song['file'] )
            paths.append( path )
            albumartistmbid = song['musicbrainzalbumartistid']
            albumartistmbids.append( albumartistmbid )
            albumreleasembid = song['musicbrainzalbumid']
            albumreleasembids.append( albumreleasembid )
        return paths, albumartistmbids, albumreleasembids
    else:
        return empty
def getFolders( dir_name, recursive="FALSE" ):
    '''Returns a list of valid XBMC files from a given directory(folder)

       Method to call:
       getFolders( dir_name, , recursive )
            dir_name   - the name of the directory to be searched
            recursive  - Setting to "TRUE" searches Parent and subdirectories, Setting to "FALSE" only search Parent Directory
    '''
    xbmc.log( "[folder.py] - getFolders Activated", level=xbmc.LOGDEBUG )
    folderList = []
    json_query = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"directory": "%s", "media": "files"}, "id": 1}' % ( escapeDirJSON( dir_name ) )
    json_folder_detail = retrieve_json_dict(json_query, items='files', force_log=True)
    if json_folder_detail:
        for f in json_folder_detail:
            if f["filetype"] == "directory":
                folderList.append( match.group(1) )
                #xbmc.log( "[folder.py] - Folder Path: %s" % f["file"], level=xbmc.LOGDEBUG )
                if recursive == "TRUE":
                    fileList.extend( getFolders( f["file"], recursive ) ) 
            else:
                continue
    return folderList
Example #12
0
def getFolders( dir_name, recursive="FALSE" ):
    '''Returns a list of valid XBMC files from a given directory(folder)

       Method to call:
       getFolders( dir_name, , recursive )
            dir_name   - the name of the directory to be searched
            recursive  - Setting to "TRUE" searches Parent and subdirectories, Setting to "FALSE" only search Parent Directory
    '''
    log( "[folder.py] - getFolders Activated" )
    folderList = []
    json_query = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"directory": "%s", "media": "files"}, "id": 1}' % ( escapeDirJSON( dir_name ) )
    json_folder_detail = retrieve_json_dict(json_query, items='files', force_log=True)
    if json_folder_detail:
        for f in json_folder_detail:
            if f["filetype"] == "directory":
                folderList.append( match.group(1) )
                #log( "[folder.py] - Folder Path: %s" % f["file"] )
                if recursive == "TRUE":
                    fileList.extend( getFolders( f["file"], recursive ) ) 
            else:
                continue
    return folderList
Example #13
0
def _store_playlist():
    p_list = []
    utils.log("Storing Playlist in memory", xbmc.LOGNOTICE)
    json_query = '{"jsonrpc": "2.0", "method": "Playlist.GetItems", "params": {"playlistid": 1, "properties": ["title", "file", "thumbnail", "streamdetails", "mpaa", "genre"] }, "id": 1}'
    p_list = retrieve_json_dict(json_query, items="items", force_log=False)
    return p_list
def _store_playlist():
    p_list = []
    log( "Storing Playlist in memory", xbmc.LOGNOTICE )
    json_query = '{"jsonrpc": "2.0", "method": "Playlist.GetItems", "params": {"playlistid": 1, "properties": ["title", "file", "thumbnail", "streamdetails", "mpaa", "genre"] }, "id": 1}'
    p_list = retrieve_json_dict( json_query, items="items", force_log=False )
    return p_list