From 99c15791372a7cfcd06e4d43f745589ed2ec71b4 Mon Sep 17 00:00:00 2001 From: dreamer Date: Wed, 14 Oct 2020 12:25:52 +0200 Subject: [PATCH] we have fixed the date stamp now --- code/config.lua | 2 +- code/handlers/splhandler.lua | 34 +++++++++------------------------- splimport/decode.py | 11 ++++++++--- 3 files changed, 18 insertions(+), 29 deletions(-) diff --git a/code/config.lua b/code/config.lua index e3d62b3..6d443ac 100644 --- a/code/config.lua +++ b/code/config.lua @@ -5,7 +5,7 @@ config({"development", "production"}, { postgres = { host = "postgres", user = "postgres", - -- password = "the_password", + password = "the_password", database = "postgres" } }) diff --git a/code/handlers/splhandler.lua b/code/handlers/splhandler.lua index 32fc744..90fcfb1 100644 --- a/code/handlers/splhandler.lua +++ b/code/handlers/splhandler.lua @@ -70,35 +70,19 @@ local function Splhandler(self) return end - -- we have to split the `hr:min:sec` and `month/day/year` strings from SPL - -- and since SPL uses both "." and "-" for dates .. somehow .. we have to do more dirty tricks .. - local function Split(s, delimiters) - - for i, delimiter in ipairs(delimiters) do - local result = {} - - if delimiter == "." then - for match in string.gmatch(s, "[^%.]+") do - table.insert(result, match) - end - else - for match in (s..delimiter):gmatch("(.-)"..delimiter) do - table.insert(result, match) - end - end - - if table.getn(result) == 3 then - return result - else - print("something is wrong: ".. s) - end - + -- we have to split the `hr:min:sec` and `year-month-day` strings from SPL + local function Split(s, delimiter) + local result = {} + for match in (s..delimiter):gmatch("(.-)"..delimiter) do + table.insert(result, match) end + return result end - local split_airtime = Split(airtime, {":"}) + + local split_airtime = Split(airtime, ":") local airtime_hr, airtime_min, airtime_sec = split_airtime[1], split_airtime[2], split_airtime[3] - local split_airdate = Split(airdate, {"/", ".", "-"}) + local split_airdate = Split(airdate, "-") local airdate_year, airdate_month, airdate_day = split_airdate[1], split_airdate[2], split_airdate[3] local airtime_stamp = os.time{year=airdate_year, month=airdate_month, day=airdate_day, hour=airtime_hr, min=airtime_min, sec=airtime_sec} diff --git a/splimport/decode.py b/splimport/decode.py index 82c38f4..9c10909 100644 --- a/splimport/decode.py +++ b/splimport/decode.py @@ -24,7 +24,12 @@ ignore_tags = [ "XLastScheduled", "EAN/UPC", "Comment", "Record Date", "XEndDate", "XRestrictions" ] -query_params = {} +host = 'http://localhost:8082' +# host = 'https://tracks.intergalactic.fm' + +query_params = { + # "secret": "secret" +} if len(sys.argv) <= 1: sys.exit("no argument passed") @@ -60,7 +65,7 @@ for item in ape.tag.frames: # print(Y,M,D,h,m,s) time_list.append("{}:{}:{}".format(h, m, s)) - date_list.append("{}/{}/{}".format(M, D, Y)) + date_list.append("{}-{}-{}".format(Y, M, D)) elif key == "Other": query_params["country"] = value.decode() elif key == "Year": @@ -88,7 +93,7 @@ while i < len(time_list): # print(query_params) response = requests.get( - 'http://localhost:8082/spl/1', + '{}/spl/1'.format(host), params=query_params ) # print(response)