Пример #1
0
def _coverart_downloaded(album, metadata, release, try_list, coverinfos, data, http, error):
    album._requests -= 1

    if error or len(data) < 1000:
        if error:
            log.error(str(http.errorString()))
    else:
        QObject.tagger.window.set_statusbar_message(N_("Coverart %s downloaded"),
                http.url().toString())
        mime = mimetype.get_from_data(data, default="image/jpeg")
        filename = None
        if not is_front_image(coverinfos) and config.setting["caa_image_type_as_filename"]:
            filename = coverinfos['type']
        metadata.add_image(mime, data, filename, coverinfos)
        for track in album._new_tracks:
            track.metadata.add_image(mime, data, filename, coverinfos)

    # If the image already was a front image, there might still be some
    # other front images in the try_list - remove them.
    if is_front_image(coverinfos):
        for item in try_list[:]:
            if is_front_image(item) and 'archive.org' not in item['host']:
                # Hosts other than archive.org only provide front images
                try_list.remove(item)
    _walk_try_list(album, metadata, release, try_list)
Пример #2
0
def _coverart_downloaded(album, metadata, release, try_list, coverinfos, data, http, error):
    album._requests -= 1

    if error or len(data) < 1000:
        if error:
            _coverart_http_error(album, http)
    else:
        QObject.tagger.window.set_statusbar_message(N_("Coverart %s downloaded"),
                http.url().toString())
        mime = mimetype.get_from_data(data, default="image/jpeg")
        filename = None
        if not is_front_image(coverinfos) and config.setting["caa_image_type_as_filename"]:
            filename = coverinfos['type']
        metadata.add_image(mime, data, filename, coverinfos)
        for track in album._new_tracks:
            track.metadata.add_image(mime, data, filename, coverinfos)

    # If the image already was a front image, there might still be some
    # other front images in the try_list - remove them.
    if is_front_image(coverinfos):
        for item in try_list[:]:
            if is_front_image(item) and 'archive.org' not in item['host']:
                # Hosts other than archive.org only provide front images
                try_list.remove(item)
    _walk_try_list(album, metadata, release, try_list)
Пример #3
0
def _coverart_downloaded(album, metadata, release, try_list, coverinfos, data, http, error):
    album._requests -= 1

    if error or len(data) < 1000:
        if error:
            _coverart_http_error(album, http)
    else:
        QObject.tagger.window.set_statusbar_message(
            N_("Cover art of type '%(type)s' downloaded for %(albumid)s from %(host)s"),
            {
                'type': coverinfos['type'].title(),
                'albumid': album.id,
                'host': coverinfos['host']
            }
        )
        mime = mimetype.get_from_data(data, default="image/jpeg")

        try:
            metadata.make_and_add_image(mime, data,
                                        imagetype=coverinfos['type'],
                                        comment=coverinfos['desc'])
            for track in album._new_tracks:
                track.metadata.make_and_add_image(mime, data,
                                                  imagetype=coverinfos['type'],
                                                  comment=coverinfos['desc'])
        except (IOError, OSError) as e:
            album.error_append(e.message)
            album._finalize_loading(error=True)
            # It doesn't make sense to store/download more images if we can't
            # save them in the temporary folder, abort.
            return

    # If the image already was a front image, there might still be some
    # other front images in the try_list - remove them.
    if is_front_image(coverinfos):
        for item in try_list[:]:
            if is_front_image(item) and 'archive.org' not in item['host']:
                # Hosts other than archive.org only provide front images
                try_list.remove(item)
    _walk_try_list(album, metadata, release, try_list)
Пример #4
0
 def set_metadata(self, metadata, item):
     self.item = item
     data = None
     if metadata and metadata.images:
         for image in metadata.images:
             if is_front_image(image):
                 data = image
                 break
         else:
             # There's no front image, choose the first one available
             data = metadata.images[0]
     self.__set_data(data)
     release = None
     if metadata:
         release = metadata.get("musicbrainz_albumid", None)
     if release:
         self.coverArt.setActive(True)
         self.coverArt.setToolTip(_(u"View release on MusicBrainz"))
     else:
         self.coverArt.setActive(False)
         self.coverArt.setToolTip("")
     self.release = release
Пример #5
0
                                        imagetype=coverinfos['type'],
                                        comment=coverinfos['desc'])
            for track in album._new_tracks:
                track.metadata.make_and_add_image(mime, data,
                                                  imagetype=coverinfos['type'],
                                                  comment=coverinfos['desc'])
        except (IOError, OSError), e:
            album.error_append(e.message)
            album._finalize_loading(error=True)
            # It doesn't make sense to store/download more images if we can't
            # save them in the temporary folder, abort.
            return

    # If the image already was a front image, there might still be some
    # other front images in the try_list - remove them.
    if is_front_image(coverinfos):
        for item in try_list[:]:
            if is_front_image(item) and 'archive.org' not in item['host']:
                # Hosts other than archive.org only provide front images
                try_list.remove(item)
    _walk_try_list(album, metadata, release, try_list)


def _caa_json_downloaded(album, metadata, release, try_list, data, http, error):
    album._requests -= 1
    caa_front_found = False
    if error:
        _coverart_http_error(album, http)
    else:
        try:
            caa_data = json.loads(data)