comparison core/magnatagatune/fm_corresponding_albums.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 [fmalbums, fmalbum_names] = fm_corresponding_albums(albums)
2 %fmalbums = fm_corresponding_albums(albums)
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 % fmalbum_names = {magnatagatune_artist, fm_artist};
8 %
9 % returns -1 of no matches found
10 maxtry = 3;
11
12 albums = unique(albums);
13 i = 1;
14 numtry = 0;
15 while i < numel(albums)
16
17 % ---
18 % as sometimes this fails due to connection problems
19 % or other problems not yet identified, we TRY
20 %
21 % for fails, we may try one time again!
22 % ---
23 fprintf('%d percent: %s\n',floor(i*100/numel(albums)),char(albums{i}));
24 try
25 [tmp, tmpid] = fm_retrieve_album(char(albums{i}));
26 fmalbums(i,:) = {albums{i}, tmp{1}, tmpid{1}};
27 catch err
28
29 % no work :(
30 warning(err.message);
31 fmalbums{i} = '-1';
32
33 numtry = numtry + 1;
34
35 % ---
36 % NOTE: we try again in case it fails for < maxtry times
37 % ---
38 if numtry < maxtry
39 i = i - 1;
40 else
41 numtry = 0;
42 end
43 end
44 i = i + 1;
45 end
46
47 fmalbum_names = {'magnatagatune_album', 'fm_album', 'mbid'};