aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Yakushev <yakushev.alex@gmail.com>2011-09-17 14:07:37 +0300
committerAlexander Yakushev <yakushev.alex@gmail.com>2011-09-17 14:07:37 +0300
commitd53a40346f463939f08a8078e7aa2eb14aab945c (patch)
treef15dddb887d2968242da19515e9e80a3d61db914
parent183a0dc5a9daabc6f1527bf0d71f267de319db66 (diff)
downloadawesompd-d53a40346f463939f08a8078e7aa2eb14aab945c.tar.gz
awesompd-d53a40346f463939f08a8078e7aa2eb14aab945c.tar.bz2
Adapt to use modified Jamendo API
-rw-r--r--jamendo.lua33
1 files changed, 15 insertions, 18 deletions
diff --git a/jamendo.lua b/jamendo.lua
index cc8bc83..870a421 100644
--- a/jamendo.lua
+++ b/jamendo.lua
@@ -166,7 +166,7 @@ function return_track_table(request_table)
parse_table[i].stream = get_link_by_id(parse_table[i].id)
end
_, _, parse_table[i].artist_link_name =
- string.find(parse_table[i].artist_url, "jamendo.com\\/artist\\/(.+)")
+ string.find(parse_table[i].artist_url, "\\/artist\\/(.+)")
parse_table[i].display_name =
parse_table[i].artist_name .. " - " .. parse_table[i].name
-- Do Jamendo a favor, extract album_id for the track yourself
@@ -187,26 +187,25 @@ end
-- current_request_table.
function form_request(request_table)
local curl_str = "curl -A 'Mozilla/4.0' -fsm 5 \"%s\""
- local url = "http://api.jamendo.com/get2/%s/%s/json/%s/?%s"
+ local url = "http://api.jamendo.com/en/?m=get2%s%s"
request_table = request_table or current_request_table
local fields = request_table.fields or current_request_table.fields
- -- Form field string (like field1+field2+fieldN)
- local field_string = ""
+ local joins = request_table.joins or current_request_table.joins
+ local unit = request_table.unit or current_request_table.unit
+
+ -- Form field&joins string (like field1+field2+fieldN%2Fjoin+)
+ local fnj_string = "&m_params="
for i = 1, table.getn(fields) do
- field_string = field_string .. fields[i] .. "+"
+ fnj_string = fnj_string .. fields[i] .. "+"
end
- field_string = string.sub(field_string,1,string.len(field_string)-1)
-
- local unit = request_table.unit or current_request_table.unit
-
- local joins = request_table.joins or current_request_table.joins
- local join_string = ""
- -- Form join string (like table1+table2+tableN)
+ fnj_string = string.sub(fnj_string,1,string.len(fnj_string)-1)
+
+ fnj_string = fnj_string .. "%2F" .. unit .. "%2Fjson%2F"
for i = 1, table.getn(joins) do
- join_string = join_string .. joins[i] .. "+"
+ fnj_string = fnj_string .. joins[i] .. "+"
end
- join_string = string.sub(join_string,1,string.len(join_string)-1)
+ fnj_string = fnj_string .. "%2F"
local params = {}
-- If parameters where supplied in request_table, add them to the
@@ -231,12 +230,10 @@ function form_request(request_table)
v = v.value
end
v = string.gsub(v, " ", "+")
- param_string = param_string .. k .. "=" .. v .. "&"
+ param_string = param_string .. "&" .. k .. "=" .. v
end
- param_string = string.sub(param_string,1,string.len(param_string)-1)
- return string.format(curl_str, string.format(url, field_string, unit,
- join_string, param_string))
+ return string.format(curl_str, string.format(url, fnj_string, param_string))
end
-- Primitive function for parsing Jamendo API JSON response. Does not