Skip to content

Conversation

ewok
Copy link

@ewok ewok commented Aug 22, 2024

No description provided.

Copy link

@Ivana- Ivana- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Виден прогресс в освоении Кложи, радует :)

0 (String. (byte-array text) "ISO-8859-1")
1 (String. (byte-array text) "UTF-16")
2 (String. (byte-array text) "UTF-16BE")
3 (String. (byte-array text) "UTF-8")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно без дублирования (String. (byte-array text) (case id ...


; "TALB — Album"
(defmethod decode-frame :TALB
[data]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Больше дестракчеринга богу дестракчеринга:
[{:keys [enc-byte body] :as data}]

$49 44 33 yy yy xx zz zz zz zz"
[header]
(let [[h1 h2 h3 yy1 yy2 _ zz1 zz2 zz3 zz4] header]
(and (every? true? (map = [\I \D \3] [h1 h2 h3]))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я ошибаюсь, или это просто (= [\I \D \3] [h1 h2 h3]) == (= "ID3" (str h1 h2 h3)) ?

body (map int (drop 1 all-body))
header-size (+ 10 data-size)]
(lazy-seq (cons (decode-frame (zipmap [:id :size :enc-byte :body]
[(keyword (apply str id)) header-size enc-byte body]))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вопрос вкуса, но имхо читаемее просто литерал мапы:

{:id (keyword (apply str id))
:size header-size
:enc-byte enc-byte
:body body}

[header]
(let [flag-bit (int (nth header 5))]
(zipmap [:unsync :extended :exp :footer]
[(bit-test flag-bit 7) (bit-test flag-bit 6) (bit-test flag-bit 5)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я за литерал мапы :)

(let [flag-bit (int (nth header 5))
     bt #(bit-test flag-bit %)]
{:unsync (bt 7)
:extended (bt 6)
....

(if errors
(apply println errors)
(let [what-to-show (set (keys (dissoc opts :filename)))
frames (:frames (id3/get-id3-header (:filename opts)))]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я за тред-макросы :)

(if (empty? what-to-show)
(print (usage summary))
(dorun (map #(println (string/join " - " %))
(for [frame frames
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я за дестракчеринг:
(for [{:keys [id title body]} frames

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants