从 MusicBrainz Web Service 检索元数据



我正在尝试使用第三方java库从MusicBrainz下载元数据:musicbrainzws2-java

我正在尝试检索指定专辑中单个歌曲的元数据。我已经检索了专辑的MBID,但是当我尝试搜索专辑中的歌曲时,我没有得到任何回报。

这是我的代码:

public static void main (String args []) throws MBWS2Exception {
    String artistName = "Imagine Dragons";
    String album_id = null;
     Artist artist = new Artist();
     artist.search(artistName);
     List<ArtistResultWs2> results  =  artist.getFullSearchResultList();
     ArtistWs2 song = results.get(0).getArtist();
     artist = new Artist();
     song = artist.lookUp(song);
     List<ReleaseGroupWs2> rgl = artist.getFullReleaseGroupList();

     for(int i =0; i<rgl.size(); i++){
         System.out.println(rgl.get(i).getTitle());
         if(rgl.get(i).getTitle().equals("Night Visions")){
             album_id = rgl.get(i).getId();
         }
     }
     System.out.println("Night visions ID: " + album_id);
     Release release = new Release();
     release.search(album_id);
     List<ReleaseResultWs2> list = release.getFullSearchResultList();
     for(int i =0; i<list.size(); i++)
            System.out.println(list.get(i).getEntity());

有人可以给我一些指示。谢谢

设法检索信息代码如下:

public static void main (String args []) throws MBWS2Exception {
    String artistName = "Imagine Dragons";
    String albumName = "Night Visions";
    String album_id = null;
    Artist artistsearch = new Artist();
    artistsearch.search(artistName);

    List<ArtistResultWs2> result = artistsearch.getFullSearchResultList();
    ArtistWs2 artist = new ArtistWs2();
    for(ArtistResultWs2 x : result){
        if(x.getArtist().toString().equals(artistName)){
            artist = x.getArtist();     
            break;
        }
    }
     artistsearch = new Artist();
     artistsearch.lookUp(artist);
     List<ReleaseGroupWs2> release_groups = artistsearch.getFullReleaseGroupList();
     ReleaseGroupWs2 releasegroup = null;

     for(ReleaseGroupWs2 x : release_groups)
         if(x.getTitle().equals(albumName)){
             releasegroup = x;
         }
     ReleaseGroup releasegroupsearch = new ReleaseGroup();
     releasegroupsearch.lookUp(releasegroup);
     List<ReleaseWs2> releases = releasegroupsearch.getFullReleaseList();
     ReleaseWs2 album = releases.get(0);
     Release releaselist = new Release();
     releaselist.lookUp(album);
     MediumListWs2 releaselist1 = releaselist.getComplete(album).getMediumList();
     List<TrackWs2> tracklist = releaselist1.getCompleteTrackList();
     System.out.println("artist: " + artist);
     System.out.println("album: " + album);
     System.out.println("title: " + tracklist.get(0).getRecording().getTitle());
     System.out.println("genre: " + tracklist.get(0).getRecording().getTags().get(0).getName());
     System.out.println("track: " + tracklist.get(0).getPosition());
     System.out.println("year: " + album.getYear());
     System.out.println("disc no.: " + releaselist1.getMedia().get(0));
     System.out.println("label: " + album.getLabelInfoString());
     System.out.println("artist sort : " + tracklist.get(0).getRecording().getArtistCreditString());
     System.out.println("comment: " + tracklist.get(0).getRecording().getDisambiguation());

}

}

相关内容

  • 没有找到相关文章

最新更新