aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--client/client.erl2
-rw-r--r--server/media.erl13
2 files changed, 14 insertions, 1 deletions
diff --git a/client/client.erl b/client/client.erl
index 85f0e9d..67be4ee 100644
--- a/client/client.erl
+++ b/client/client.erl
@@ -74,7 +74,7 @@ handle(Cmd, Server) ->
{{error, {unknown_command, Cmd}}, Server}.
%queries the server for the current votes this client possesses
-getVotes() ->
+getVotes(Server) ->
rpc(Server, getVotes, self()),
receive
Msg ->
diff --git a/server/media.erl b/server/media.erl
index 1c41c89..851cc21 100644
--- a/server/media.erl
+++ b/server/media.erl
@@ -1,5 +1,6 @@
-module(media).
-export([init/0,insert/3, ask/2, all/0, play/3, vote/2, devote/2]).
+-define(TESTPATTERN, "../ac/*.mp3").
% Since we are not willing to calculate and deliver all the id3 tags everytime they are requested,
% we try to get something persistent with mnesia.
@@ -24,8 +25,20 @@ init() ->
mnesia:create_schema([node()]),
mnesia:start(),
mnesia:create_table(track, [], {index, [y]}, {type, bag}, [{attributes, record_info(fields, track)}]),
+ read_files(filelib:wildcard(?TESTPATTERN),0,0),
io:format("Initialisation of mnesia successful.\n").
+read_files([FN|Rest],Total,Fail) ->
+ case id3v2:read_file(FN) of
+ {ok, Props} -> % insert entry into mnesia DB
+ Artist = proplists:get_value(tpe1, Props),
+ Title = proplists:get_value(tit2, Props),
+ insert(bitstring_to_list(Artist), bitstring_to_list(Title), FN),
+ read_files(Rest, Total+1, Fail);
+ not_found -> read_files(Rest, Total+1, Fail+1)
+ end;
+read_files([],Total,Fail) -> io:format("Total: ~w, Failed: ~w~n", [Total, Fail]).
+
% Basic insertion of entrys into the database. Some entries are left out because they are 0 or false.
insert(Artist, Title, Filepath) ->