def get(self, album, extra):
        if not (album.albumartist and album.album):
            return

        # Find the name of the cover art filename on DBpedia
        cover_filename, page_id = None, None
        dbpedia_response = self.request(
            self.DBPEDIA_URL,
            params={
                'format': 'application/sparql-results+json',
                'timeout': 2500,
                'query': self.SPARQL_QUERY.format(
                    artist=album.albumartist.title(), album=album.album)
            },
            headers={'content-type': 'application/json'},
        )
        try:
            data = dbpedia_response.json()
            results = data['results']['bindings']
            if results:
                cover_filename = 'File:' + results[0]['coverFilename']['value']
                page_id = results[0]['pageId']['value']
            else:
                self._log.debug(u'wikipedia: album not found on dbpedia')
        except (ValueError, KeyError, IndexError):
            self._log.debug(u'wikipedia: error scraping dbpedia response: {}',
                            dbpedia_response.text)

        # Ensure we have a filename before attempting to query wikipedia
        if not (cover_filename and page_id):
            return

        # DBPedia sometimes provides an incomplete cover_filename, indicated
        # by the filename having a space before the extension, e.g., 'foo .bar'
        # An additional Wikipedia call can help to find the real filename.
        # This may be removed once the DBPedia issue is resolved, see:
        # https://github.com/dbpedia/extraction-framework/issues/396
        if ' .' in cover_filename and \
           '.' not in cover_filename.split(' .')[-1]:
            self._log.debug(
                u'wikipedia: dbpedia provided incomplete cover_filename'
            )
            lpart, rpart = cover_filename.rsplit(' .', 1)

            # Query all the images in the page
            wikipedia_response = self.request(
                self.WIKIPEDIA_URL,
                params={
                    'format': 'json',
                    'action': 'query',
                    'continue': '',
                    'prop': 'images',
                    'pageids': page_id,
                },
                headers={'content-type': 'application/json'},
            )

            # Try to see if one of the images on the pages matches our
            # imcomplete cover_filename
            try:
                data = wikipedia_response.json()
                results = data['query']['pages'][page_id]['images']
                for result in results:
                    if re.match(re.escape(lpart) + r'.*?\.' + re.escape(rpart),
                                result['title']):
                        cover_filename = result['title']
                        break
            except (ValueError, KeyError):
                self._log.debug(
                    u'wikipedia: failed to retrieve a cover_filename'
                )
                return

        # Find the absolute url of the cover art on Wikipedia
        wikipedia_response = self.request(
            self.WIKIPEDIA_URL,
            params={
                'format': 'json',
                'action': 'query',
                'continue': '',
                'prop': 'imageinfo',
                'iiprop': 'url',
                'titles': cover_filename.encode('utf-8'),
            },
            headers={'content-type': 'application/json'},
        )

        try:
            data = wikipedia_response.json()
            results = data['query']['pages']
            for _, result in results.iteritems():
                image_url = result['imageinfo'][0]['url']
                yield self._candidate(url=image_url,
                                      match=Candidate.MATCH_EXACT)
        except (ValueError, KeyError, IndexError):
            self._log.debug(u'wikipedia: error scraping imageinfo')
            return
dataset/ETHPy150Open beetbox/beets/beetsplug/fetchart.py/Wikipedia.get/original