JlSonic/get-missing-albums.jl

48 lines
1.3 KiB
Julia

artists = Beets.artists()
albums_id = getfield.(Beets.albums, :uuid)
albums_title = getfield.(Beets.albums, :title) .|> lowercase
owned_ids = getfield.(artists, :uuid)
counter = 0
releases = map(id -> begin
global counter
sleep(0.1)
@show counter += 1
MusicBrainz.releaselistbyid(id)
end, owned_ids)
alldata = map((a, rs) -> [(artist = a,
album = r.title, uuid = r.id)
for r in rs],
artists, releases) |> Iterators.flatten |> collect
todl = filter(x -> !(x.uuid in albums_id ||
x.album in lowercase.(getfield.(Beets.album(x.artist), :title))
), alldata)
found = []
foreach(x -> begin
global me, found
sleep(0.1)
push!(found,
RuTrackers.search(me, string(x.artist.name, " ", x.album),
verbose = true))
end, todl)
# added = []
for (n, r) in enumerate(found)
global me, rpc, added
@info "($(n)/$(length(found)))"
lossless = RuTrackers.islossless.(r)
discog = RuTrackers.isdiscography.(r)
m = findfirst(lossless .& .!discog)
m === nothing && continue
# Add it
TransmissionRPC.getauth(rpc)
TransmissionRPC.add(rpc, RuTrackers.download(me, r[m]))
# push!(added, found[n])
end