@Test public void testArtistLookup() { Metadata meta = mHelper.lookupArtistInfo("foxes"); Assertions.assertThat(meta).isNotNull(); }
@DebugLog public Metadata lookupArtistInfo(final String artistName) { Call<Artist> call = mLastFM.getArtist(artistName); Response<Artist> response; try { response = call.execute(); } catch (IOException|IllegalArgumentException e) { return null; } Artist artist = response.body(); if (artist == null) { Timber.w("Failed to retrieve artist %s", artistName); return null; } Metadata.Builder bob = Metadata.builder(); bob.putString(KEY_ARTIST_NAME, artist.getName()); bob.putString(KEY_ARTIST_SUMMARY, artist.getWikiSummary()); bob.putString(KEY_ARTIST_BIO, artist.getWikiText()); Date lastChanged = artist.getWikiLastChanged(); if (lastChanged != null) { bob.putLong(KEY_LAST_MODIFIED, lastChanged.getTime()); } bob.putUri(KEY_ARTIST_URL_URI, Uri.parse(artist.getUrl())); bob.putString(KEY_ARTIST_MBID, artist.getMbid()); return bob.build(); }
LastFMHelper { @DebugLog public Metadata lookupArtistInfo(final String artistName) { Call<Artist> call = mLastFM.getArtist(artistName); Response<Artist> response; try { response = call.execute(); } catch (IOException|IllegalArgumentException e) { return null; } Artist artist = response.body(); if (artist == null) { Timber.w("Failed to retrieve artist %s", artistName); return null; } Metadata.Builder bob = Metadata.builder(); bob.putString(KEY_ARTIST_NAME, artist.getName()); bob.putString(KEY_ARTIST_SUMMARY, artist.getWikiSummary()); bob.putString(KEY_ARTIST_BIO, artist.getWikiText()); Date lastChanged = artist.getWikiLastChanged(); if (lastChanged != null) { bob.putLong(KEY_LAST_MODIFIED, lastChanged.getTime()); } bob.putUri(KEY_ARTIST_URL_URI, Uri.parse(artist.getUrl())); bob.putString(KEY_ARTIST_MBID, artist.getMbid()); return bob.build(); } }
LastFMHelper { @DebugLog public Metadata lookupArtistInfo(final String artistName) { Call<Artist> call = mLastFM.getArtist(artistName); Response<Artist> response; try { response = call.execute(); } catch (IOException|IllegalArgumentException e) { return null; } Artist artist = response.body(); if (artist == null) { Timber.w("Failed to retrieve artist %s", artistName); return null; } Metadata.Builder bob = Metadata.builder(); bob.putString(KEY_ARTIST_NAME, artist.getName()); bob.putString(KEY_ARTIST_SUMMARY, artist.getWikiSummary()); bob.putString(KEY_ARTIST_BIO, artist.getWikiText()); Date lastChanged = artist.getWikiLastChanged(); if (lastChanged != null) { bob.putLong(KEY_LAST_MODIFIED, lastChanged.getTime()); } bob.putUri(KEY_ARTIST_URL_URI, Uri.parse(artist.getUrl())); bob.putString(KEY_ARTIST_MBID, artist.getMbid()); return bob.build(); } @Inject  LastFMHelper(LastFM mLastFM); }
LastFMHelper { @DebugLog public Metadata lookupArtistInfo(final String artistName) { Call<Artist> call = mLastFM.getArtist(artistName); Response<Artist> response; try { response = call.execute(); } catch (IOException|IllegalArgumentException e) { return null; } Artist artist = response.body(); if (artist == null) { Timber.w("Failed to retrieve artist %s", artistName); return null; } Metadata.Builder bob = Metadata.builder(); bob.putString(KEY_ARTIST_NAME, artist.getName()); bob.putString(KEY_ARTIST_SUMMARY, artist.getWikiSummary()); bob.putString(KEY_ARTIST_BIO, artist.getWikiText()); Date lastChanged = artist.getWikiLastChanged(); if (lastChanged != null) { bob.putLong(KEY_LAST_MODIFIED, lastChanged.getTime()); } bob.putUri(KEY_ARTIST_URL_URI, Uri.parse(artist.getUrl())); bob.putString(KEY_ARTIST_MBID, artist.getMbid()); return bob.build(); } @Inject  LastFMHelper(LastFM mLastFM); @DebugLog Metadata lookupAlbumInfo(final String albumArtist, final String albumName); @DebugLog Metadata lookupArtistInfo(final String artistName); Observable<Album> getAlbum(final String mbid); Observable<Artist> getArtist(final String mbid); static boolean hasFeaturedArtist(String artist); static String resolveAlbumArtistFromTrackArtist(String trackArtist); static String resolveTrackArtist(String trackArtist); }
LastFMHelper { @DebugLog public Metadata lookupArtistInfo(final String artistName) { Call<Artist> call = mLastFM.getArtist(artistName); Response<Artist> response; try { response = call.execute(); } catch (IOException|IllegalArgumentException e) { return null; } Artist artist = response.body(); if (artist == null) { Timber.w("Failed to retrieve artist %s", artistName); return null; } Metadata.Builder bob = Metadata.builder(); bob.putString(KEY_ARTIST_NAME, artist.getName()); bob.putString(KEY_ARTIST_SUMMARY, artist.getWikiSummary()); bob.putString(KEY_ARTIST_BIO, artist.getWikiText()); Date lastChanged = artist.getWikiLastChanged(); if (lastChanged != null) { bob.putLong(KEY_LAST_MODIFIED, lastChanged.getTime()); } bob.putUri(KEY_ARTIST_URL_URI, Uri.parse(artist.getUrl())); bob.putString(KEY_ARTIST_MBID, artist.getMbid()); return bob.build(); } @Inject  LastFMHelper(LastFM mLastFM); @DebugLog Metadata lookupAlbumInfo(final String albumArtist, final String albumName); @DebugLog Metadata lookupArtistInfo(final String artistName); Observable<Album> getAlbum(final String mbid); Observable<Artist> getArtist(final String mbid); static boolean hasFeaturedArtist(String artist); static String resolveAlbumArtistFromTrackArtist(String trackArtist); static String resolveTrackArtist(String trackArtist);  }