aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--awesompd.lua2
-rw-r--r--jamendo.lua13
2 files changed, 13 insertions, 2 deletions
diff --git a/awesompd.lua b/awesompd.lua
index 3b11ad7..4e76258 100644
--- a/awesompd.lua
+++ b/awesompd.lua
@@ -367,7 +367,7 @@ function awesompd:get_playback_menu()
self:command_toggle(),
self.ICONS.PLAY_PAUSE })
if self.connected and self.status ~= "Stopped" then
- if self.current_number ~= 1 then
+ if self.list_array[self.current_number-1] then
table.insert(new_menu,
{ "Prev: " ..
awesompd.protect_string(jamendo.replace_link(
diff --git a/jamendo.lua b/jamendo.lua
index d907f26..f805f2f 100644
--- a/jamendo.lua
+++ b/jamendo.lua
@@ -330,10 +330,12 @@ retrieve_cache()
function get_album_cover(track_id)
local track = jamendo_list[track_id]
local album_id = track.album_id
+
if album_id == 0 then -- No cover for tracks without album!
return nil
end
local file_path = album_covers_folder .. album_id .. ".jpg"
+
if not file_exists(file_path) then -- We need to download it
-- First check if cache directory exists
f = io.popen('test -d ' .. album_covers_folder .. ' && echo t')
@@ -341,7 +343,16 @@ function get_album_cover(track_id)
awful.util.spawn("mkdir " .. album_covers_folder)
end
f:close()
-
+
+ if not track.album_image then -- Wow! We have album_id, but
+ local a_id = tostring(album_id) --don't have album_image. Well,
+ local prefix = --it happens.
+ string.sub(a_id, 1, string.len(a_id) - 3)
+ track.album_image =
+ string.format("http://imgjam.com/albums/s%s/%s/covers/1.100.jpg",
+ prefix, a_id)
+ end
+
f = io.popen("wget " .. track.album_image .. " -O "
.. file_path .. " > /dev/null")
f:close()