 (ns moomoo.rooms
   (:require [cljs.nodejs :as nodejs]
             [cljs.reader :as reader]
+            [clojure.string :as string]
             [cognitect.transit :as transit]))
 
 (defonce fs (nodejs/require "fs"))

(defonce redis-client (.createClient (nodejs/require "redis")))
(defonce redis-lua-loader (nodejs/require "redis-lua-loader"))
(defonce redis-lua (redis-lua-loader. redis-client #js {:src "./redis"}))

(defn redis-room-prefix [room-id suffix]
  (str "room:" room-id ":" suffix))

    (fn [err reply]
      (callback reply))))

(defn handle-album-art [tags track-id callback]
  (let [pictures (get tags "picture")]
    (if (nil? pictures)
      (callback tags)
      (let [picture (first (get tags "picture"))
            picture-format (get picture "format")
            picture-data   (get picture "data")
            filename  (subs track-id 0 7)
            file-path (str album-art-directory "/" filename "." picture-format)]
        (println "Saving album art to:" file-path)
        (.writeFile fs file-path picture-data)
        (callback (merge {"picture" (string/replace file-path "public" "")}
                         (dissoc tags "picture")))))))

(defn set-music-info [absolute-file-path
                      track-id
