aboutsummaryrefslogtreecommitdiff
path: root/jamendo.lua
diff options
context:
space:
mode:
authorAlexander Yakushev <yakushev.alex@gmail.com>2011-10-28 19:18:45 +0300
committerAlexander Yakushev <yakushev.alex@gmail.com>2011-10-28 19:18:45 +0300
commit89a7c1516bad4e259655b08ff8de5ffb72077ac4 (patch)
tree8aad317eccc050ed79aaafdfc79f618317bbacbf /jamendo.lua
parent1c42de6a7800164d35713fded24070ae3c881561 (diff)
downloadawesompd-89a7c1516bad4e259655b08ff8de5ffb72077ac4.tar.gz
awesompd-89a7c1516bad4e259655b08ff8de5ffb72077ac4.tar.bz2
Show album name in notification box for local tracks
Diffstat (limited to 'jamendo.lua')
-rw-r--r--jamendo.lua11
1 files changed, 7 insertions, 4 deletions
diff --git a/jamendo.lua b/jamendo.lua
index 7f56f6a..fd38281 100644
--- a/jamendo.lua
+++ b/jamendo.lua
@@ -13,6 +13,9 @@ local io = io
local pairs = pairs
local type = type
local assert = assert
+local print = print
+local tonumber = tonumber
+local math = math
module('jamendo')
@@ -292,7 +295,7 @@ end
-- Jamendo returns Unicode symbols as \uXXXX. Lua does not transform
-- them into symbols so we need to do it ourselves.
-local function utf8_codes_to_symbols (s)
+function utf8_codes_to_symbols (s)
local hexnums = "[%dabcdefABCDEF]"
local pattern = string.format("\\u(%s%s%s%s?%s?)",
hexnums, hexnums, hexnums, hexnums, hexnums)
@@ -360,7 +363,7 @@ end
-- Saves track IDs to track names and album IDs mapping into the cache
-- file.
-local function save_cache()
+function save_cache()
local bus = io.open(cache_file, "w")
bus:write(cache_header .. "\n")
for id,track in pairs(jamendo_list) do
@@ -456,12 +459,12 @@ function perform_request(reqest_string)
bus:close()
-- Curl with popen can sometimes fail to fetch data when the
-- connection is slow. Let's try again if it fails.
- if (string.len(response) == 0) then
+ if string.len(response) == 0 then
bus = assert(io.popen(reqest_string,'r'))
response = bus:read("*all")
bus:close()
-- If it still can't read anything, return nil
- if (string.len(response) ~= 0) then
+ if string.len(response) ~= 0 then
return nil
end
end