Mercurial > hg > camir-aes2014
comparison core/magnatagatune/fm_corresponding_artists.m @ 0:e9a9cd732c1e tip
first hg version after svn
author | wolffd |
---|---|
date | Tue, 10 Feb 2015 15:05:51 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e9a9cd732c1e |
---|---|
1 function [fmartist_name, fmartist_name_names] = fm_corresponding_artists(artists) | |
2 %[artists, fmartists] = fm_corresponding_artists(artists) | |
3 % | |
4 % searches last.fm for the artist given in a cell | |
5 % array of strings and saves the first hit into the output. | |
6 % | |
7 % returns -1 of no matches found | |
8 maxtry = 10; | |
9 | |
10 % artists = unique(artists); | |
11 i = 1; | |
12 numtry = 0; | |
13 while i <= numel(artists) | |
14 | |
15 % --- | |
16 % as sometimes this fails due to connection problems | |
17 % or other problems not yet identified, we TRY | |
18 % | |
19 % for fails, we may try one time again! | |
20 % --- | |
21 fprintf('%d percent: %s\n',floor(i*100/numel(artists)),char(artists{i})); | |
22 try | |
23 [tmp, tmpid] = fm_retrieve_album(char(artists{i})); | |
24 fmartist_name(i,:) = {artists{i}, tmp{1}, tmpid{1}}; | |
25 catch err | |
26 | |
27 % no work :( | |
28 warning(err.message); | |
29 fmartist_name(i,:) = {artists{i}, '-1', '-1'}; | |
30 | |
31 numtry = numtry + 1; | |
32 | |
33 % --- | |
34 % NOTE: we try gain in case it fails for < maxtry times | |
35 % --- | |
36 if numtry < maxtry | |
37 i = i - 1; | |
38 else | |
39 numtry = 0; | |
40 end | |
41 end | |
42 i = i + 1; | |
43 end | |
44 | |
45 fmartist_name_names = {'magnatagatune_album', 'fm_album', 'mbid'}; |