ypから配信情報を取得してみる。
最初は defstruct
というものを使ったんですが
Structs are obsolete. Use records instead. See defrecord.
とドキュメントにかかれていたので defrecord
を使いました。
pcyp.clj
(ns pcyp-clj.core
(:require [clojure.string :as str]))
(defrecord Info [name ip genre description kbps type comment])
;; get index.txt
(def txt (slurp "http://bayonet.ddo.jp/sp/index.txt"))
;; split
(def splited-txt (map #(str/split % #"<>") (str/split txt #"\n" )))
(def infos (for [x splited-txt]
(Info. (first x) (get x 2) (get x 4) (get x 5) (get x 8) (get x 9) (get x 17))))
;; 結果確認
(first infos)
誰か何かアイデアください