aboutsummaryrefslogtreecommitdiff
path: root/awesompd.lua
diff options
context:
space:
mode:
authorAlexander Yakushev <yakushev.alex@gmail.com>2012-01-03 15:40:42 +0200
committerAlexander Yakushev <yakushev.alex@gmail.com>2012-01-03 15:40:42 +0200
commit45dbf9edbdc728e6835a473fff08c62829961de2 (patch)
tree176df9e4db2cc6097729c7dd76a61219e4888cf1 /awesompd.lua
parentd5363cbbc1a05881bed2490904bae5953abc5869 (diff)
downloadawesompd-45dbf9edbdc728e6835a473fff08c62829961de2.tar.gz
awesompd-45dbf9edbdc728e6835a473fff08c62829961de2.tar.bz2
Asynchronous download album cover for the next track
When the current track changes and if the next track is a Jamendo stream, asynchronously download the album cover for it (if it is not already there) to avoid freezes because of the slow connection.
Diffstat (limited to 'awesompd.lua')
-rw-r--r--awesompd.lua11
1 files changed, 11 insertions, 0 deletions
diff --git a/awesompd.lua b/awesompd.lua
index d88f8d1..10c45f3 100644
--- a/awesompd.lua
+++ b/awesompd.lua
@@ -25,6 +25,7 @@ function awesompd.try_require(module)
end
awesompd.try_require("utf8")
+awesompd.try_require("asyncshell")
awesompd.try_require("jamendo")
local beautiful = require('beautiful')
local naughty = naughty
@@ -940,6 +941,16 @@ function awesompd:update_track(file)
self.recreate_list = true
self.current_number = tonumber(self.find_pattern(status_line,"%d+"))
self:update_widget_text()
+
+ -- If the track is not the last, asynchronously download
+ -- the cover for the next track.
+ if self.list_array and self.current_number ~= table.getn(self.list_array) then
+ -- Get the link (in case it is Jamendo stream) to the next track
+ local next_track =
+ self:command_read('playlist -f "%file%" | head -' ..
+ self.current_number + 1 .. ' | tail -1', "*line")
+ jamendo.try_get_cover_async(next_track)
+ end
end
local tmp_pst = string.find(status_line,"%d+%:%d+%/")
local progress = self.find_pattern(status_line,"%#%d+/%d+") .. " " .. string.sub(status_line,tmp_pst)