-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmagicalstick.el
54 lines (41 loc) · 1.85 KB
/
magicalstick.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
;;; magicalstick.el --- さなボタンをアレするツール
;; Copyright (C) 2018 shibafu528
;; Author: shibafu <[email protected]>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; Inspired by https://github.com/himanoa/magicalstick
;;; Code:
(require 'dom)
(defvar magicalstick:host "www.natorisana.love")
(defvar magicalstick:prefix "sounds/")
(defvar magicalstick:protocol "https")
(defvar magicalstick:ext "mp3")
(defun magicalstick-get-dom ()
"Get sana button DOM."
(let ((url-request-method "GET"))
(with-current-buffer (url-retrieve-synchronously (format "%s://%s" magicalstick:protocol magicalstick:host))
(goto-char (point-min))
(re-search-forward "^$")
(delete-region (point) (point-min))
(libxml-parse-html-region (point-min) (point-max)))))
(defun magicalstick ()
"Get sana button resource list."
(mapcar (lambda (node)
(format "%s://%s/%s%s.%s"
magicalstick:protocol
magicalstick:host
magicalstick:prefix
(replace-regexp-in-string "^\./" "" (dom-attr node 'data-file))
magicalstick:ext))
(dom-by-class (magicalstick-get-dom) "sounds")))
(provide 'magicalstick)
;;; magicalstick.el ends here