 (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"))

        (callback (clj->js track-order))))))

(defn change-track [room track-num sound-id callback]
  (println "Chainging track in room " room
           "to" track-num "with sound-id" sound-id)
  ((.scriptWrap redis-lua "changeTrack")
    0 room track-num sound-id

    (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
