2019-05-21 11:05:53 +02:00
|
|
|
playlistfile(path) = joinpath(path, "playlists.jsonl")
|
|
|
|
|
|
|
|
function saveplaylists(; file = playlistfile(Beets.confdir()))
|
|
|
|
global user_playlists
|
|
|
|
open(file, "w") do f
|
|
|
|
write(f,
|
|
|
|
join(JSON2.write.(user_playlists), "\n"))
|
|
|
|
end
|
2019-05-17 20:22:01 +02:00
|
|
|
end
|
2019-05-21 11:05:53 +02:00
|
|
|
|
|
|
|
function loadplaylists(; file = playlistfile(Beets.confdir()))
|
|
|
|
global user_playlists
|
|
|
|
isfile(file) || touch(file)
|
|
|
|
ps = JSON2.readlines(file)
|
|
|
|
empty!(user_playlists)
|
|
|
|
for p in ps
|
|
|
|
try
|
|
|
|
pl = JSON2.read(p, Playlist)
|
|
|
|
push!(user_playlists, pl)
|
|
|
|
catch e
|
|
|
|
@warn "Failed to read with error $e"
|
|
|
|
isa(e, ArgumentError) && continue
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function saveusers(file = expanduser("~/.config/beets/users.jsonl"))
|
|
|
|
global users
|
|
|
|
open(file, "w") do f
|
|
|
|
write(f, join(JSON2.write.(users), "\n"))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function loadusers(; file = expanduser("~/.config/beets/users.jsonl"))
|
|
|
|
global users
|
|
|
|
isfile(file) || touch(file)
|
|
|
|
ps = JSON2.readlines(file)
|
|
|
|
p = JSON2.read.(ps, JlSonic.User)
|
|
|
|
empty!(users)
|
|
|
|
for pl in p
|
|
|
|
push!(users, pl)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|