Ejemplo n.º 1
0
def check_size( path, type, size_w, size_h ):
    # first copy from source to work directory since Python does not support SMB://
    file_name = get_filename( type, path, "auto" )
    destination = os.path.join( addon_work_folder, "temp", file_name )
    source = os.path.join( path, file_name )
    log( "Checking Size", xbmc.LOGDEBUG )
    if exists( source ):
        file_copy( source, destination )
    else:
        return True
    try:
        # Helix: not really a Helix problem but file cannot be removed after Image.open locking it
        with open(str(destination), 'rb') as destf:
            artwork = Image.open( destf )
        log( "Image Size: %s px(W) X %s px(H)" % ( artwork.size[ 0 ], artwork.size[ 1 ] ), xbmc.LOGDEBUG )
        if artwork.size[0] < size_w and artwork.size[1] < size_h:  # if image is smaller than 1000 x 1000 and the image on fanart.tv = 1000
            delete_file( destination )
            log( "Image is smaller", xbmc.LOGDEBUG )
            return True
        else:
            delete_file( destination )
            log( "Image is same size or larger", xbmc.LOGDEBUG )
            return False
    except:
        log( "artwork does not exist. Source: %s" % source, xbmc.LOGDEBUG )
        return True
Ejemplo n.º 2
0
def _get_slides_xml( path ):
    source = os.path.join( path, "slides.xml" ).replace("\\\\","\\")
    destination = os.path.join( BASE_CURRENT_SOURCE_PATH, "slides.xml" ).replace("\\\\","\\")
    # if no slides.xml exists return false
    if not exists( source ):
        return False, "", "", "", ""
    # fetch data
    file_copy( source, destination )
    xml = open( destination ).read()
    # parse info
    mpaa, theme, question_format, clue_format, answer_format = re.search( "<slides?(?:.+?rating=\"([^\"]*)\")?(?:.+?theme=\"([^\"]*)\")?.*?>.+?<question.+?format=\"([^\"]*)\".*?/>.+?<clue.+?format=\"([^\"]*)\".*?/>.+?<answer.+?format=\"([^\"]*)\".*?/>", xml, re.DOTALL ).groups()
    delete_file ( destination )
    return True, mpaa, question_format, clue_format, answer_format
Ejemplo n.º 3
0
def thumbnail_copy( art_path, thumb_path, type="artwork" ):
    if not thumb_path.startswith("http://") or not thumb_path.startswith("image://"):
        if exists( art_path ):
            if file_copy( art_path, thumb_path ):
                log( "Successfully copied %s" % type, xbmc.LOGDEBUG )
            else:
                log( "Failed to copy to %s" % type, xbmc.LOGDEBUG )
            log( "Source Path: %s" % repr( art_path ), xbmc.LOGDEBUG )
            log( "Destination Path: %s" % repr( thumb_path ), xbmc.LOGDEBUG )
    elif thumb_path.startswith("http://") or thumb_path.startswith("image://"):
        log( "Destination Path is not able to be copied to: %s" % repr( thumb_path ), xbmc.LOGDEBUG )
Ejemplo n.º 4
0
def thumbnail_copy( art_path, thumb_path, type="artwork" ):
    if not thumb_path.startswith("http://") or not thumb_path.startswith("image://"):
        if exists( art_path ):
            if file_copy( art_path, thumb_path ):
                log( "Successfully copied %s" % type, xbmc.LOGDEBUG )
            else:
                log( "Failed to copy to %s" % type, xbmc.LOGDEBUG )
            log( "Source Path: %s" % repr( art_path ), xbmc.LOGDEBUG )
            log( "Destination Path: %s" % repr( thumb_path ), xbmc.LOGDEBUG )
    elif thumb_path.startswith("http://") or thumb_path.startswith("image://"):
        log( "Destination Path is not able to be copied to: %s" % repr( thumb_path ), xbmc.LOGDEBUG )
Ejemplo n.º 5
0
def copy_artwork(source_path, dest_path):
    log("Copying movie set artwork to cache", xbmc.LOGDEBUG)
    if dest_path.startswith("http://"):
        log("HTTP destination path is unsupported", xbmc.LOGDEBUG)
    if dest_path.startswith("image://"):
        dest_path = unquote(dest_path)[8:-1]

    log("Source Path: %s" % repr(source_path), xbmc.LOGDEBUG)
    log("Destination Path: %s" % repr(dest_path), xbmc.LOGDEBUG)

    if not file_exists(source_path):
        log("Source file does not exist", xbmc.LOGDEBUG)
    elif not file_copy(source_path, dest_path):
        log("Failed to copy file", xbmc.LOGDEBUG)
Ejemplo n.º 6
0
def copy_artwork( source_path, dest_path ):
    log( "Copying movie set artwork to cache", xbmc.LOGDEBUG )
    if dest_path.startswith("http://"):
        log( "HTTP destination path is unsupported", xbmc.LOGDEBUG )
    if dest_path.startswith("image://"):
        dest_path = unquote(dest_path)[8:-1]

    log( "Source Path: %s" % repr( source_path ), xbmc.LOGDEBUG )
    log( "Destination Path: %s" % repr( dest_path ), xbmc.LOGDEBUG )
    
    if not file_exists( source_path ):
        log( "Source file does not exist", xbmc.LOGDEBUG )
    elif not file_copy( source_path, dest_path ):
        log( "Failed to copy file", xbmc.LOGDEBUG )
Ejemplo n.º 7
0
from slides import _fetch_slides
from new_trailer_downloader import downloader
from utils import settings_to_log

from pre_eden_code import _store_playlist, _get_queued_video_info, _build_playlist
from xbmcvfs import delete as delete_file
from xbmcvfs import exists as exists
from xbmcvfs import copy as file_copy

#TODO: Check to see if module is moved to /userdata/addon_data/script.cinema.experience
try:
    if not exists( os.path.join( BASE_CURRENT_SOURCE_PATH, "ha_scripts", "home_automation.py" ) ) and _S_( "ha_enable") == "true":
        source = os.path.join( BASE_RESOURCE_PATH, "ha_scripts", "home_automation.py" )
        destination = os.path.join( BASE_CURRENT_SOURCE_PATH, "ha_scripts", "home_automation.py" )
        os.mkdir( os.path.join( BASE_CURRENT_SOURCE_PATH, "ha_scripts" ) )        
        file_copy( source, destination )
        xbmc.log( "[ script.cinema.experience ] - home_automation.py copied", level=xbmc.LOGNOTICE )
    sys.path.append( os.path.join( BASE_CURRENT_SOURCE_PATH, "ha_scripts" ) )
    from home_automation import activate_on
    # Import HA module set ha_imported to True if successful
    ha_imported = True
except ImportError:
    # or ha_imported to False if unsuccessful
    ha_imported = False

#ce_pause_time = float( int( _S_("pause_time") ) )
ce_pause_time = float( 2.5 )
__builtin__.slide_settings = {  "trivia_total_time": int( float( _S_( "trivia_total_time" ) ) ),
                                    "trivia_folder": xbmc.translatePath( _S_( "trivia_folder" ) ),
                                "trivia_slide_time": int( float( _S_( "trivia_slide_time" ) ) ),
                                     "trivia_intro": _S_( "trivia_intro" ),
Ejemplo n.º 8
0
def download_art( url_cdart, album, database_id, type, mode, size, background = False ):
    log( "Downloading artwork... ", xbmc.LOGDEBUG )
    download_success = False 
    thumb_path = ""
    percent = 1
    is_canceled = False
    if mode == "auto":
        dialog_msg( "update", percent = percent, background = background )
    else:
        dialog_msg( "create", heading = __language__(32047), background = background )
        #Onscreen Dialog - "Downloading...."
    file_name = get_filename( type, url_cdart, mode )
    #Helix: paths MUST end with trailing slash
    path = os.path.join(album["path"].replace( "\\\\" , "\\" ), '')
    if file_name == "unknown":
        log( "Unknown Type ", xbmc.LOGDEBUG )
        message = [ __language__(32026), __language__(32025), "File: %s" % get_unicode( path ), "Url: %s" % get_unicode( url_cdart ) ]
        return message, download_success
    if type in ( "artistthumb", "cover" ):
        thumbnail_path = get_thumbnail_path( database_id, type )
    else:
        thumbnail_path = ""
    if type == "fanart" and mode in ( "manual", "single" ):
        thumbnail_path = get_fanart_path( database_id, type )
    if not exists( path ):
        try:
            pathsuccess = _makedirs( album["path"].replace( "\\\\" , "\\" ) )
        except:
            pass
    log( "Path: %s" % path, xbmc.LOGDEBUG )
    log( "Filename: %s" % file_name, xbmc.LOGDEBUG )
    log( "url: %s" % url_cdart, xbmc.LOGDEBUG )
    
    # cosmetic: use subfolder for downloading instead of work folder
    if not exists( os.path.join(tempgfx_folder, '').replace( "\\\\","\\" )):
        _makedirs(os.path.join(tempgfx_folder, '').replace( "\\\\","\\" ))
    destination = os.path.join(tempgfx_folder, file_name).replace( "\\\\","\\" ) # download to work folder first
    final_destination = os.path.join( path, file_name ).replace( "\\\\","\\" )
    try:
        #this give the ability to use the progress bar by retrieving the downloading information
        #and calculating the percentage
        def _report_hook( count, blocksize, totalsize ):
            try:
                percent = int( float( count * blocksize * 100 ) / totalsize )
                if percent < 1:
                    percent = 1
                if percent > 100:
                    percent = 100
            except:
                percent = 1
            if type in ( "fanart", "clearlogo", "artistthumb", "musicbanner" ):
                dialog_msg( "update", percent = percent, line1 = "%s%s" % ( __language__(32038) , get_unicode( album["artist"] ) ), background = background )
            else:
                dialog_msg( "update", percent = percent, line1 = "%s%s" % ( __language__(32038) , get_unicode( album["artist"] ) ), line2 = "%s%s" % ( __language__(32039) , get_unicode( album["title"] ) ), background = background )
            if mode == "auto":
                if dialog_msg( "iscanceled", background = background ):
                    is_canceled = True  
        if exists( path ):
            fp, h = urllib.urlretrieve(url_cdart, destination, _report_hook)
            #message = ["Download Sucessful!"]
            message = [__language__(32023), __language__(32024), "File: %s" % get_unicode( path ), "Url: %s" % get_unicode( url_cdart )]
            success = file_copy( destination, final_destination ) # copy it to album folder
            # update database
            try:
                conn = sqlite3.connect(addon_db)
                c = conn.cursor()
                if type == "cdart":
                    c.execute('''UPDATE alblist SET cdart="True" WHERE path="%s"''' % ( get_unicode( album["path"] ) ) )
                elif type == "cover":
                    c.execute('''UPDATE alblist SET cover="True" WHERE path="%s"''' % ( get_unicode( album["path"] ) ) )
                conn.commit()
                c.close()
            except:
                log( "Error updating database", xbmc.LOGDEBUG )
                print_exc()
            download_success = True
        else:
            log( "Path error", xbmc.LOGDEBUG )
            log( "    file path: %s" % repr( destination ), xbmc.LOGDEBUG )
            message = [ __language__(32026),  __language__(32025) , "File: %s" % get_unicode( path ), "Url: %s" % get_unicode( url_cdart ) ]
            #message = Download Problem, Check file paths - Artwork Not Downloaded]           
        # always cleanup downloaded files
        #if type == "fanart":
        delete_file( destination )
    except:
        log( "General download error", xbmc.LOGDEBUG )
        message = [ __language__(32026), __language__(32025), "File: %s" % get_unicode( path ), "Url: %s" % get_unicode( url_cdart ) ]
        #message = [Download Problem, Check file paths - Artwork Not Downloaded]           
        print_exc()
    if mode == "auto" or mode == "single":
        return message, download_success, final_destination, is_canceled  # returns one of the messages built based on success or lack of
    else:
        dialog_msg( "close", background = background )
        return message, download_success, is_canceled
Ejemplo n.º 9
0
try:
    conn_l = sqlite3.connect(addon_db)
    c = conn_l.cursor()
    c.execute(query)
    version=c.fetchall()
    c.close
    if version[0][0] == __dbversion__:
        log( "Database matched", xbmc.LOGNOTICE )
    elif version[0][0] == __dbversionold__:
        log( "Version 2.7.8 found, Removing Bach MBID's from database", xbmc.LOGNOTICE )
        mbid_repair()
    elif version[0][0] == __dbversionancient__:
        log( "Version 1.5.3 found, Adding new column to Local Album Artist and Local Artists", xbmc.LOGNOTICE )
        all_artists  = []
        local_artists  = []
        file_copy( addon_db,addon_db_update )
        conn = sqlite3.connect( addon_db )
        c = conn.cursor()
        try:
            c.execute('ALTER TABLE lalist ADD COLUMN fanarttv_has_art;')
        except:
            traceback.print_exc()
        try:
            c.execute('ALTER TABLE local_artists ADD COLUMN fanarttv_has_art;')
        except:
            traceback.print_exc()
        c.close()
        local_artist_count, album_count, artist_count, cdart_existing = new_local_count()
        store_counts( local_artist_count, artist_count, album_count, cdart_existing )
        local_artists = get_local_artists_db( mode="album_artists" )
        if enable_all_artists:
Ejemplo n.º 10
0
 version = c.fetchall()
 c.close
 if version[0][0] == __dbversion__:
     log("Database matched", xbmc.LOGNOTICE)
 elif version[0][0] == __dbversionold__:
     log(
         "Version 2.7.8 found, Removing Bach MBID's from database",
         xbmc.LOGNOTICE)
     mbid_repair()
 elif version[0][0] == __dbversionancient__:
     log(
         "Version 1.5.3 found, Adding new column to Local Album Artist and Local Artists",
         xbmc.LOGNOTICE)
     all_artists = []
     local_artists = []
     file_copy(addon_db, addon_db_update)
     conn = sqlite3.connect(addon_db)
     c = conn.cursor()
     try:
         c.execute(
             'ALTER TABLE lalist ADD COLUMN fanarttv_has_art;'
         )
     except:
         traceback.print_exc()
     try:
         c.execute(
             'ALTER TABLE local_artists ADD COLUMN fanarttv_has_art;'
         )
     except:
         traceback.print_exc()
     c.close()