diff options
author | Marco Ziener <mziener@lavabit.com> | 2010-10-14 10:52:19 +0200 |
---|---|---|
committer | Marco Ziener <mziener@lavabit.com> | 2010-10-14 10:52:19 +0200 |
commit | 487a46b7a4407ac3612c840d9ead93d73c642d8a (patch) | |
tree | 59c727ffe4761a4d1f7e6e2ba6fc3d86d4318bed | |
parent | da9da98db8f80ce58383b1f9976da3ae5e813c5b (diff) | |
parent | 1b6c636b0584d1264209fab522c4476082f0e0fd (diff) | |
download | erlang-487a46b7a4407ac3612c840d9ead93d73c642d8a.tar.gz erlang-487a46b7a4407ac3612c840d9ead93d73c642d8a.tar.xz erlang-487a46b7a4407ac3612c840d9ead93d73c642d8a.zip |
merged
-rw-r--r-- | client/client.erl | 2 | ||||
-rw-r--r-- | server/media.erl | 13 |
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) -> |