diff --git a/Albumart/Albumart.lua b/Albumart/Albumart.lua index 7dec0bc..297f2f9 100644 --- a/Albumart/Albumart.lua +++ b/Albumart/Albumart.lua @@ -24,9 +24,10 @@ if rc == 1 then end -- Cache the fetched albumart and send it to the client -local file = mympd.covercache_write(out, mympd_arguments.uri) -if file then - return mympd.http_serve_file(file) +local filename +rc, filename = mympd.covercache_write(out, mympd_arguments.uri) +if rc == 0 then + return mympd.http_serve_file(filename) end return mympd.http_redirect("/assets/coverimage-notavailable") diff --git a/Covercache/CovercachePrepopulate.lua b/Covercache/CovercachePrepopulate.lua index e14b8d4..18ea69f 100644 --- a/Covercache/CovercachePrepopulate.lua +++ b/Covercache/CovercachePrepopulate.lua @@ -29,7 +29,9 @@ local function check_image(base) return false end -local rc, result = mympd.api("MYMPD_API_DATABASE_ALBUM_LIST", { +local rc, result, code, headers + +rc, result = mympd.api("MYMPD_API_DATABASE_ALBUM_LIST", { offset = 0, limit = 10000, expression = "", @@ -42,23 +44,22 @@ local existing = 0 local errors = 0 local downloaded = 0 for _, album in pairs(result.data) do - local path = mympd_env.cachedir_cover .. "/" .. mympd.hash_sha1(album.uri) .. "-0" - if not check_image(path) then - if not pcall(function() + if album.uri and album.uri ~= "" then + local path = mympd_env.cachedir_cover .. "/" .. mympd.hash_sha1(album.uri) .. "-0" + if not check_image(path) then local out = mympd.tmp_file() local uri = mympd_state.mympd_uri .. 'albumart-thumb?offset=0&uri=' .. mympd.urlencode(album.uri) - if mympd_http_download(uri, out) == 0 then + rc, code, headers = mympd_http_download(uri, out) + if rc == 0 then local name = mympd.covercache_write(out, album.uri) mympd.log(6, "Covercache: " .. name) downloaded = downloaded + 1 else errors = errors + 1 end - end) then - errors = errors + 1 + else + existing = existing + 1 end - else - existing = existing + 1 end end diff --git a/Covercache/README.md b/Covercache/README.md index fcb7336..79de9ac 100644 --- a/Covercache/README.md +++ b/Covercache/README.md @@ -2,4 +2,6 @@ ## CovercachePrepopulate -This scripts downloads abumart from myMPD and stores it in the covercache. +This scripts downloads abumart from myMPD and stores it in the covercache. This script works only for the advanced album mode (default). + + diff --git a/Lyrics/Lyrics.lua b/Lyrics/Lyrics.lua index 0fc4167..6d24cb1 100644 --- a/Lyrics/Lyrics.lua +++ b/Lyrics/Lyrics.lua @@ -1,7 +1,7 @@ -- {"order":1,"arguments":["uri"]} -- Import lyrics provider configuration local providers = require "scripts/LyricsProviders" -local rc, code, header, body, song, lyrics_text, desc +local rc, code, headers, body, song, lyrics_text, desc local function strip_html(str) str = str:gsub("", "") @@ -37,7 +37,7 @@ end local function get_lyrics_uri(provider, artist, title) local identity_uri = replace_vars_uri(provider.identity_uri, artist, title) - rc, code, header, body = mympd.http_client("GET", identity_uri, "", "") + rc, code, headers, body = mympd.http_client("GET", identity_uri, "", "") if rc == 0 and #body > 0 then local identity_pattern = replace_vars_pattern(provider.identity_pattern, artist, title) local lyrics_path = body:match(identity_pattern) @@ -66,7 +66,7 @@ for _, provider in pairs(providers) do lyrics_uri = replace_vars_uri(provider.lyrics_uri, artist, title) end if lyrics_uri then - rc, code, header, body = mympd.http_client("GET", lyrics_uri, "", "") + rc, code, headers, body = mympd.http_client("GET", lyrics_uri, "", "") if rc == 0 then local lyrics_pattern = replace_vars_pattern(provider.lyrics_pattern, artist, title) lyrics_text = body:match(lyrics_pattern) diff --git a/Tagart/Tagart.lua b/Tagart/Tagart.lua index 0f969b7..2550a39 100644 --- a/Tagart/Tagart.lua +++ b/Tagart/Tagart.lua @@ -21,9 +21,10 @@ if rc == 1 then end -- Cache the fetched tagart and send it to the client -local file = mympd.thumbscache_write(out, value) -if file then - return mympd.http_serve_file(file) +local filename +rc, filename = mympd.thumbscache_write(out, value) +if rc == 0 then + return mympd.http_serve_file(filename) end return mympd.http_redirect("/assets/coverimage-notavailable")