Ejemplo n.º 1
0
    def _gui_mode(self, currentmedia):
        global download_arttypes
        global image_list
        # Close the 'checking for artwork' dialog before opening the GUI list
        dialog_msg('close', background=setting['background'])
        # Look for argument matching artwork types
        for item in sys.argv:
            for type in arttype_list:
                if item == type['art_type'] and startup['mediatype'] == type[
                        'media_type']:
                    log('- Custom %s mode art_type: %s' %
                        (type['media_type'], type['art_type']))
                    download_arttypes.append(item)
        gui_selected_type = False
        # If only one specified and not extrafanart/extrathumbs
        if ((len(download_arttypes) == 1) and startup['dbid']
                and not 'extrathumbs' in download_arttypes
                and not 'extrafanart' in download_arttypes):
            imagelist = False
            for gui_arttype in download_arttypes:
                gui_selected_type = gui_arttype
                break
            # Add parse the image restraints
            if gui_selected_type:
                for arttype in arttype_list:
                    if gui_selected_type == arttype['art_type'] and startup[
                            'mediatype'] == arttype['media_type']:
                        # Get image list for that specific imagetype
                        imagelist = gui_imagelist(image_list,
                                                  gui_selected_type)
                        # Some debug log output
                        for image in imagelist:
                            log('- Image put to GUI: %s' % image)
                        break
        else:
            # Create empty list and set bool to false that there is a list
            enabled_type_list = []
            imagelist = False
            # Fill GUI art type list
            for arttype in arttype_list:
                if (arttype['solo_enabled'] == 'true'
                        and startup['mediatype'] == arttype['media_type']
                        and hasimages(image_list, arttype['art_type'])):
                    gui = __localize__(arttype['gui_string'])
                    enabled_type_list.append(gui)
            # Not sure what this does again
            if len(enabled_type_list) == 1:
                enabled_type_list[0] = 'True'
            # Fills imagelist with image that fit the selected imagetype
            type_list = choice_type(enabled_type_list, startup, arttype_list)
            if (len(enabled_type_list) == 1) or type_list:
                imagelist = gui_imagelist(image_list, type_list['art_type'])
                # Some debug log output
                for image in imagelist:
                    log('- Image put to GUI: %s' % image)

        # Download the selected image
        # If there's a list, send the imagelist to the selection dialog
        if imagelist:
            image_list = choose_image(imagelist)
            if image_list:
                # Create a progress dialog so you can see the progress,
                #Send the selected image for processing, Initiate the batch download
                dialog_msg('create')
                for art_type in arttype_list:
                    if image_list['art_type'][0] == art_type['art_type']:
                        self._download_art(currentmedia, art_type,
                                           currentmedia['artworkdir'])
                        self._batch_download(download_list)
                        break
                # When not succesfull show failure dialog
                if not download_succes:
                    dialog_msg('okdialog',
                               line1=__localize__(32006),
                               line2=__localize__(32007))
        # When no images found or nothing selected
        if not imagelist and gui_selected_type:
            log('- No artwork found')
            dialog_msg('okdialog',
                       line1=currentmedia['name'],
                       line2=__localize__(arttype['gui_string']) + ' ' +
                       __localize__(32022))
        # When download succesfull
        elif download_succes:
            log('- Download succesfull')
        # Selection was cancelled
        else:
            global cancelled
            cancelled = True
Ejemplo n.º 2
0
    def _gui_mode(self, currentmedia):
        global download_arttypes
        global image_list
        # Close the 'checking for artwork' dialog before opening the GUI list
        dialog_msg('close',
           background = setting['background'])
        # Look for argument matching artwork types
        for item in sys.argv:
            for type in arttype_list:
                if item == type['art_type'] and startup['mediatype'] == type['media_type']:
                    log('- Custom %s mode art_type: %s' %(type['media_type'],type['art_type']))
                    download_arttypes.append(item)
        gui_selected_type = False
        # If only one specified and not extrafanart/extrathumbs
        if ((len(download_arttypes) == 1) and
            startup['dbid'] and not
            'extrathumbs' in download_arttypes and not
            'extrafanart' in download_arttypes):
            imagelist = False
            for gui_arttype in download_arttypes:
                gui_selected_type = gui_arttype
                break
            # Add parse the image restraints
            if gui_selected_type:
                for arttype in arttype_list:
                    if gui_selected_type == arttype['art_type'] and startup['mediatype'] == arttype['media_type']:
                        # Get image list for that specific imagetype
                        imagelist = gui_imagelist(image_list, gui_selected_type)
                        # Some debug log output
                        for image in imagelist:
                            log('- Image put to GUI: %s' %image)
                        break
        else:
            # Create empty list and set bool to false that there is a list
            enabled_type_list = []
            imagelist = False
            # Fill GUI art type list
            for arttype in arttype_list:
                if (arttype['solo_enabled'] == 'true' and
                    startup['mediatype'] == arttype['media_type'] and
                    hasimages(image_list, arttype['art_type'])):
                    gui = __localize__(arttype['gui_string'])
                    enabled_type_list.append(gui)
            # Not sure what this does again
            if len(enabled_type_list) == 1:
                enabled_type_list[0] = 'True'
            # Fills imagelist with image that fit the selected imagetype
            type_list = choice_type(enabled_type_list, startup, arttype_list)
            if (len(enabled_type_list) == 1) or type_list:
                imagelist = gui_imagelist(image_list, type_list['art_type'])
                # Some debug log output
                for image in imagelist:
                    log('- Image put to GUI: %s' %image)

        # Download the selected image
        # If there's a list, send the imagelist to the selection dialog
        if imagelist:
            image_list = choose_image(imagelist)
            if image_list:
                for art_type in arttype_list:
                    if image_list['art_type'][0] == art_type['art_type']:
                        self._download_art(currentmedia, art_type, currentmedia['artworkdir'])
                        self._batch_download(download_list)
                        break
                # When not succesfull show failure dialog
                if not download_succes:
                    dialog_msg('close',
                               background = setting['background'])
                    dialog_msg('okdialog',
                               line1 = __localize__(32006),
                               line2 = __localize__(32007))
        # When no images found or nothing selected
        if not imagelist and gui_selected_type:
            log('- No artwork found')
            dialog_msg('okdialog',
                       line1 = currentmedia['name'],
                       line2 = __localize__(arttype['gui_string']) + ' ' + __localize__(32022))
        # When download succesfull
        elif download_succes:
            log('- Download succesfull')
        # Selection was cancelled
        else:
            global cancelled
            cancelled = True