Data for a specific artist.
508400
def get_artist(self, id_):
        """"""
        endpoint = "artists/{id}".format(id=id_)
        return self._make_request(endpoint)
26286
def art(artname, number=1, text=""):
    
    if isinstance(artname, str) is False:
        raise artError(ART_TYPE_ERROR)
    artname = artname.lower()
    arts = sorted(art_dic.keys())
    if artname == "random" or artname == "rand" or artname == "rnd":
        filtered_arts = list(set(arts) - set(RANDOM_FILTERED_ARTS))
        artname = random.choice(filtered_arts)
    elif artname not in art_dic.keys():
        distance_list = list(map(lambda x: distance_calc(artname, x),
                                 arts))
        min_distance = min(distance_list)
        selected_art = arts[distance_list.index(min_distance)]
        threshold = max(len(artname), len(selected_art)) / 2
        if min_distance < threshold:
            artname = selected_art
        else:
            raise artError(ART_NAME_ERROR)
    art_value = art_dic[artname]
    if isinstance(number, int) is False:
        raise artError(NUMBER_TYPE_ERROR)
    if isinstance(art_value, str):
        return (art_value + " ") * number
    if isinstance(text, str) is False:
        raise artError(TEXT_TYPE_ERROR)
    return (art_value[0] + text + art_value[1] + " ") * number
210140
def get_album(self):
        """"""

        doc = self._request(self.ws_prefix + ".getInfo", True)

        albums = doc.getElementsByTagName("album")

        if len(albums) == 0:
            return

        node = doc.getElementsByTagName("album")[0]
        return Album(_extract(node, "artist"), _extract(node, "title"), self.network)
1274383
def _parse(self, data):
        
        super(Album, self)._parse(data)
        self.cover_id = data['cover']
        images = [Image(i['id'], i) for i in data['images']]
        self.image_ids[:] = [i.imgur_id for i in images]
        return images
21403
def get_artists(self, limit=50, cacheable=True):
        

        seq = []
        for node in _collect_nodes(
            limit, self, self.ws_prefix + ".getArtists", cacheable
        ):
            name = _extract(node, "name")

            playcount = _number(_extract(node, "playcount"))
            tagcount = _number(_extract(node, "tagcount"))

            seq.append(LibraryItem(Artist(name, self.network), playcount, tagcount))

        return seq
395085
def get_top_artists(self, limit=None, cacheable=True):
        """"""

        params = {}
        if limit:
            params["limit"] = limit

        doc = _Request(self, "chart.getTopArtists", params).execute(cacheable)

        return _extract_top_artists(doc, self)
801802
def _is_alive(artist):
    """"""
    return bool(artist
                and artist.axes
                and (artist.container in artist.axes.containers
                     if isinstance(artist, _pick_info.ContainerArtist) else
                     artist in _iter_axes_subartists(artist.axes)))
218729
def format(self, pattern):
        
        pattern = pattern.replace('%a', self.artist.name)
        pattern = pattern.replace('%s', self.name)
        pattern = pattern.replace('%A', self.album.name)
        return pattern.replace('/', '') \
                      .replace('\\', '') \
                      .replace(":", "") \
                      .replace("*", "") \
                      .replace("?", "") \
                      .replace('"', "") \
                      .replace("|", "") \
                      .replace("<", "") \
                      .replace(">", "")
763494
def get_album_artists(self, *args, **kwargs):
        
        args = tuple(['album_artists'] + list(args))
        return self.get_music_library_information(*args, **kwargs)
465723
def plot_data(self):
        """"""
        # Clear the plot before plotting onto it
        self.ax.cla()

        if self.sample is None:
            return

        if self.current_channels is None:
            self.current_channels = self.sample.channel_names[:2]

        channels = self.current_channels
        channels_to_plot = channels[0] if len(channels) == 1 else channels
        self.sample.plot(channels_to_plot, ax=self.ax)

        xaxis = self.ax.get_xaxis()
        yaxis = self.ax.get_yaxis()
        self.xlabel_artist = xaxis.get_label()
        self.ylabel_artist = yaxis.get_label()
        self.xlabel_artist.set_picker(5)
        self.ylabel_artist.set_picker(5)

        self.fig.canvas.draw()
496431
private ArrayList<Album> parseAlbumData(String json) {
    ArrayList<Album> albums = new ArrayList<>();
    try {
      JsonNode jsonNode = this.objectMapper.readTree(json);
      for (JsonNode albumNode : jsonNode.get("albums")) {
        JsonNode artistsNode = albumNode.get("artists");
        // Exclude albums with 0 artists
        if (artistsNode.size() >= 1) {
          // Only keeping the first artist for simplicity
          Artist artist = new Artist(artistsNode.get(0).get("name").asText());
          Album album = new Album(albumNode.get("name").asText(), artist);
          albums.add(album);
        }
      }
    } catch (IOException e) {
      throw new RuntimeException("Failed to parse JSON", e);
    }
    return albums;
  }
952801
def get_artist_tracks(self, artist, cacheable=False):
        
        # Not implemented:
        # "Can be limited to specific timeranges, defaults to all time."

        warnings.warn(
            "User.get_artist_tracks is deprecated and will be removed in a future "
            "version. User.get_track_scrobbles is a partial replacement. "
            "See https://github.com/pylast/pylast/issues/298",
            DeprecationWarning,
            stacklevel=2,
        )

        params = self._get_params()
        params["artist"] = artist

        seq = []
        for track in _collect_nodes(
            None, self, self.ws_prefix + ".getArtistTracks", cacheable, params
        ):
            title = _extract(track, "name")
            artist = _extract(track, "artist")
            date = _extract(track, "date")
            album = _extract(track, "album")
            timestamp = track.getElementsByTagName("date")[0].getAttribute("uts")

            seq.append(
                PlayedTrack(Track(artist, title, self.network), album, date, timestamp)
            )

        return seq
99078
def scanimage_artist_metadata(artist):
    """"""
    try:
        return json.loads(artist)
    except ValueError as exc:
        log.warning('scanimage_artist_metadata: %s: %s',
                    exc.__class__.__name__, exc)
1106926
def calculate_similar_artists(output_filename, model_name="als"):
    
    artists, users, plays = get_lastfm()

    # create a model from the input data
    model = get_model(model_name)

    # if we're training an ALS based model, weight input for last.fm
    # by bm25
    if issubclass(model.__class__, AlternatingLeastSquares):
        # lets weight these models by bm25weight.
        logging.debug("weighting matrix by bm25_weight")
        plays = bm25_weight(plays, K1=100, B=0.8)

        # also disable building approximate recommend index
        model.approximate_recommend = False

    # this is actually disturbingly expensive:
    plays = plays.tocsr()

    logging.debug("training model %s", model_name)
    start = time.time()
    model.fit(plays)
    logging.debug("trained model '%s' in %0.2fs", model_name, time.time() - start)

    # write out similar artists by popularity
    start = time.time()
    logging.debug("calculating top artists")

    user_count = np.ediff1d(plays.indptr)
    to_generate = sorted(np.arange(len(artists)), key=lambda x: -user_count[x])

    # write out as a TSV of artistid, otherartistid, score
    logging.debug("writing similar items")
    with tqdm.tqdm(total=len(to_generate)) as progress:
        with codecs.open(output_filename, "w", "utf8") as o:
            for artistid in to_generate:
                artist = artists[artistid]
                for other, score in model.similar_items(artistid, 11):
                    o.write("%s\t%s\t%s\n" % (artist, artists[other], score))
                progress.update(1)

    logging.debug("generated similar artists in %0.2fs",  time.time() - start)
192713
def getTracksForArtistInCollection(artist,user=nil,extras=nil)
      method = 'getTracksForArtistInCollection'
      type = Track
      args = {:artist=>artist}
      args[:user] = user if user
      args[:extras] = extras if extras
      return_object type,method,args
    end
1224893
public FTMusicArtist getMusicArtist(String id) throws FanartTvException {
        URL url = ftapi.getImageUrl(BaseType.ARTIST, id);
        String page = requestWebPage(url);

        FTMusicArtist artist = null;

        try {
            artist = mapper.readValue(page, FTMusicArtist.class);
        } catch (IOException ex) {
            throw new FanartTvException(ApiExceptionType.MAPPING_FAILED, "Fauled to get Music Artist with ID " + id, url, ex);
        }

        return artist;
    }
626347
def run(self):
        

        df = ArtistsInputData().load()

        # rename columns
        df.rename(columns={'artistLabel': 'name',
                           'year_of_birth': 'extra_1',
                           'genderLabel': 'extra_2'},
                  inplace=True)

        # columns that exist in the data model
        columns = ['name', 'wiki_id']

        # the extended model also stores the date of birth and gender, as strings
        if config.EXTENDED:
            columns.append('extra_1')
            columns.append('extra_2')
            df['extra_1'] = df['extra_1'].astype(str)
            df['extra_2'] = df['extra_2'].astype(str)

        # keep only columns that exist in the data model
        df = df[columns]

        # append an ID column
        df['id'] = range(len(df))

        # store everything, done
        df.to_sql(name=models.Artist.__tablename__,
                  con=self.client.engine,
                  if_exists='append',
                  index=False)

        self.done()