How to use the pylast._extract function in pylast

To help you get started, we’ve selected a few pylast examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github beetbox / beets / beetsplug / lastimport.py View on Github external
"""Returns a list of the most played thing_types by this thing, in a
        tuple with the total number of pages of results. Includes an MBID, if
        found.
        """
        doc = self._request(
            self.ws_prefix + "." + method, cacheable, params)

        toptracks_node = doc.getElementsByTagName('toptracks')[0]
        total_pages = int(toptracks_node.getAttribute('totalPages'))

        seq = []
        for node in doc.getElementsByTagName(thing):
            title = _extract(node, "name")
            artist = _extract(node, "name", 1)
            mbid = _extract(node, "mbid")
            playcount = _number(_extract(node, "playcount"))

            thing = thing_type(artist, title, self.network)
            thing.mbid = mbid
            seq.append(TopItem(thing, playcount))

        return seq, total_pages
github clinton-hall / nzbToMedia / libs / beetsplug / lastimport.py View on Github external
def _get_things(self, method, thing, thing_type, params=None,
                    cacheable=True):
        """Returns a list of the most played thing_types by this thing, in a
        tuple with the total number of pages of results. Includes an MBID, if
        found.
        """
        doc = self._request(
            self.ws_prefix + "." + method, cacheable, params)

        toptracks_node = doc.getElementsByTagName('toptracks')[0]
        total_pages = int(toptracks_node.getAttribute('totalPages'))

        seq = []
        for node in doc.getElementsByTagName(thing):
            title = _extract(node, "name")
            artist = _extract(node, "name", 1)
            mbid = _extract(node, "mbid")
            playcount = _number(_extract(node, "playcount"))

            thing = thing_type(artist, title, self.network)
            thing.mbid = mbid
            seq.append(TopItem(thing, playcount))

        return seq, total_pages
github clinton-hall / nzbToMedia / libs / beetsplug / lastimport.py View on Github external
cacheable=True):
        """Returns a list of the most played thing_types by this thing, in a
        tuple with the total number of pages of results. Includes an MBID, if
        found.
        """
        doc = self._request(
            self.ws_prefix + "." + method, cacheable, params)

        toptracks_node = doc.getElementsByTagName('toptracks')[0]
        total_pages = int(toptracks_node.getAttribute('totalPages'))

        seq = []
        for node in doc.getElementsByTagName(thing):
            title = _extract(node, "name")
            artist = _extract(node, "name", 1)
            mbid = _extract(node, "mbid")
            playcount = _number(_extract(node, "playcount"))

            thing = thing_type(artist, title, self.network)
            thing.mbid = mbid
            seq.append(TopItem(thing, playcount))

        return seq, total_pages
github Hoaas / Supybot-plugins / LastFM / plugin.py View on Github external
Returns some info on the tag ."""
        try:
            summaryLength = 260
            outputString = "%s%s%s%s"
            summaryString = "\"%s\" "
            artistsString = " Top artists: %s."
            #tracksString = " Top tracks: %s."
            #tagsString = " Similar tags: %s."
            sString = "'s%s"
            nothingString = " has no top artists."
            urlString = " %s"
            tagRef = network.get_tag(tag)
            tag = tagRef.get_name(properly_capitalized = True)
            tag = tag[0].upper() + tag[1:]
            summary = pylast._extract(tagRef._request("tag.getInfo", True), "summary")
            if summary != None and summary != "":
                summary = re.sub("\<[^<]+\>", "", summary)
                summary = re.sub("\s+", " ", summary)
                summary = summary[:summaryLength] + "..." if (summary[:summaryLength] != summary) else summary
            topArtists = tagRef.get_top_artists()
            if len(topArtists) > 3:
                topArtists = topArtists[:3]
            topArtistsText = commaAndify([x.item.get_name() for x in topArtists])
            if len(topArtistsText) > 0:
                topArtistsText = artistsString % topArtistsText
            
            #topTracks = tagRef.get_top_tracks()
            #if len(topTracks) > 3:
            #    topTracks = topTracks[:3]
            #topTracksText = commaAndify([x.item.get_artist().get_name() 
            #    + " - " + x.item.get_name() for x in topTracks]).encode("utf-8")
github beetbox / beets / beetsplug / lastimport.py View on Github external
cacheable=True):
        """Returns a list of the most played thing_types by this thing, in a
        tuple with the total number of pages of results. Includes an MBID, if
        found.
        """
        doc = self._request(
            self.ws_prefix + "." + method, cacheable, params)

        toptracks_node = doc.getElementsByTagName('toptracks')[0]
        total_pages = int(toptracks_node.getAttribute('totalPages'))

        seq = []
        for node in doc.getElementsByTagName(thing):
            title = _extract(node, "name")
            artist = _extract(node, "name", 1)
            mbid = _extract(node, "mbid")
            playcount = _number(_extract(node, "playcount"))

            thing = thing_type(artist, title, self.network)
            thing.mbid = mbid
            seq.append(TopItem(thing, playcount))

        return seq, total_pages
github clinton-hall / nzbToMedia / libs / beetsplug / lastimport.py View on Github external
"""Returns a list of the most played thing_types by this thing, in a
        tuple with the total number of pages of results. Includes an MBID, if
        found.
        """
        doc = self._request(
            self.ws_prefix + "." + method, cacheable, params)

        toptracks_node = doc.getElementsByTagName('toptracks')[0]
        total_pages = int(toptracks_node.getAttribute('totalPages'))

        seq = []
        for node in doc.getElementsByTagName(thing):
            title = _extract(node, "name")
            artist = _extract(node, "name", 1)
            mbid = _extract(node, "mbid")
            playcount = _number(_extract(node, "playcount"))

            thing = thing_type(artist, title, self.network)
            thing.mbid = mbid
            seq.append(TopItem(thing, playcount))

        return seq, total_pages
github beetbox / beets / beetsplug / lastimport.py View on Github external
def _get_things(self, method, thing, thing_type, params=None,
                    cacheable=True):
        """Returns a list of the most played thing_types by this thing, in a
        tuple with the total number of pages of results. Includes an MBID, if
        found.
        """
        doc = self._request(
            self.ws_prefix + "." + method, cacheable, params)

        toptracks_node = doc.getElementsByTagName('toptracks')[0]
        total_pages = int(toptracks_node.getAttribute('totalPages'))

        seq = []
        for node in doc.getElementsByTagName(thing):
            title = _extract(node, "name")
            artist = _extract(node, "name", 1)
            mbid = _extract(node, "mbid")
            playcount = _number(_extract(node, "playcount"))

            thing = thing_type(artist, title, self.network)
            thing.mbid = mbid
            seq.append(TopItem(thing, playcount))

        return seq, total_pages