Last active
December 16, 2015 02:09
-
-
Save sluchin/5360649 to your computer and use it in GitHub Desktop.
Revisions
-
sluchin revised this gist
Apr 11, 2013 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -94,7 +94,6 @@ (set-buffer (get-buffer-create file)) (erase-buffer) (set-buffer tmp) (dolist (dir (directory-files dirs t)) (when (and (file-directory-p dir) (not (member -
sluchin revised this gist
Apr 11, 2013 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -96,7 +96,6 @@ (set-buffer tmp) (message "directory-files: %s" (directory-files dirs)) (dolist (dir (directory-files dirs t)) (when (and (file-directory-p dir) (not (member (file-name-nondirectory dir) '("." "..")))) -
sluchin revised this gist
Apr 11, 2013 . 1 changed file with 10 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -24,9 +24,9 @@ (file (read-string "Filename: " default nil default)) (tmp " *xspf") tmpbuf) (or (when (file-exists-p file) (not (y-or-n-p (concat "Overwrite `" file "'? ")))) (if (or (not (file-exists-p file)) (file-writable-p file)) (progn (vlc-xml2csv-tempbuffer tmp "creator" "title" "annotation" "location") @@ -43,16 +43,17 @@ (message "Can not write: %s" file)) (message "Write file %s...done" file)))) ;; location タグのディレクトリが実際に存在するかどうか調べる (defun vlc-check-location () "Check if directory of location tag exists." (interactive) (let* ((default "check-location") (file (read-string "Filename: " default nil default)) (tmp " *xspf") string) (or (when (file-exists-p file) (not (y-or-n-p (concat "Overwrite `" file "'? ")))) (if (or (not (file-exists-p file)) (file-writable-p file)) (progn (vlc-xml2csv-tempbuffer tmp "location") @@ -75,6 +76,7 @@ (message "Can not write: %s" file)) (message "Write file %s...done" file)))) ;; ディレクトリが location タグに網羅されているかどうか調べる (defun vlc-check-directory () "Check if directories exist in location tag." (interactive) @@ -83,16 +85,18 @@ (dirs (read-string "Directory name: " nil nil nil)) (tmp " *xspf") string) (or (when (file-exists-p file) (not (y-or-n-p (concat "Overwrite `" file "'? ")))) (if (or (not (file-exists-p file)) (file-writable-p file)) (progn (vlc-xml2csv-tempbuffer tmp "location") (set-buffer (get-buffer-create file)) (erase-buffer) (set-buffer tmp) (message "directory-files: %s" (directory-files dirs)) (dolist (dir (directory-files dirs t)) (message "dir: %s" dir) (when (and (file-directory-p dir) (not (member (file-name-nondirectory dir) '("." "..")))) -
sluchin revised this gist
Apr 11, 2013 . 1 changed file with 18 additions and 17 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -24,23 +24,24 @@ (file (read-string "Filename: " default nil default)) (tmp " *xspf") tmpbuf) (and (when (file-exists-p file) (y-or-n-p (concat "Overwrite `" file "'? "))) (if (or (not (file-exists-p file)) (file-writable-p file)) (progn (vlc-xml2csv-tempbuffer tmp "creator" "title" "annotation" "location") (switch-to-buffer (get-buffer-create file)) (erase-buffer) (insert-buffer-substring (get-buffer tmp)) (goto-char (point-min)) (while (search-forward "'" nil t) (replace-match "")) (goto-char (point-min)) (delete-other-windows) (set-visited-file-name file) (save-buffer)) (message "Can not write: %s" file)) (message "Write file %s...done" file)))) (defun vlc-check-location () "Check if directory of location tag exists." -
sluchin created this gist
Apr 11, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,116 @@ ;;; VLC プレイリストのための XML パーサー ;; (install-elisp-from-emacswiki "xml-parse.el") ;; CSV 形式で一時バッファに出力する (defun vlc-xml2csv-tempbuffer (tmpbuf &rest tags) "Output temporary buffer from xml to csv." (when (eval-and-compile (require 'xml-parse nil t)) (goto-char (point-min)) (with-output-to-temp-buffer tmpbuf (dolist (tracklst (read-xml)) (when (string= (xml-tag-name tracklst) "trackList") (dolist (track (xml-tag-children tracklst)) (when (string= (xml-tag-name track) "track") (dolist (tag tags) (princ (car (xml-tag-children (xml-tag-child track tag)))) (if (string= tag (car (last tags))) (princ "\n") (princ ",")))))))))) ;; CSV 形式でファイルに出力する (defun vlc-xml2csv-file () "Conversion from xml to csv for vlc." (interactive) (let* ((default "vlc.csv") (file (read-string "Filename: " default nil default)) (tmp " *xspf") tmpbuf) (or (when (file-exists-p file) (not (y-or-n-p (concat "Overwrite `" file "'? ")))) (if (or (not (file-exists-p file)) (file-writable-p file)) (progn (vlc-xml2csv-tempbuffer tmp "creator" "title" "annotation" "location") (switch-to-buffer (get-buffer-create file)) (erase-buffer) (insert-buffer-substring (get-buffer tmp)) (goto-char (point-min)) (while (search-forward "'" nil t) (replace-match "")) (goto-char (point-min)) (delete-other-windows) (set-visited-file-name file) (save-buffer)) (message "Can not write: %s" file)) (message "Write file %s...done" file)))) (defun vlc-check-location () "Check if directory of location tag exists." (interactive) (let* ((default "check-location") (file (read-string "Filename: " default nil default)) (tmp " *xspf") string) (and (when (file-exists-p file) (y-or-n-p (concat "Overwrite `" file "'? "))) (if (or (not (file-exists-p file)) (file-writable-p file)) (progn (vlc-xml2csv-tempbuffer tmp "location") (set-buffer (get-buffer-create file)) (erase-buffer) (set-buffer tmp) (goto-char (point-min)) (while (not (eobp)) (setq string (buffer-substring (point-at-bol) (point-at-eol))) (with-current-buffer file (unless (file-exists-p (substring string 7)) (insert string) (insert "\n"))) (forward-line 1)) (switch-to-buffer file) (delete-other-windows) (goto-char (point-min)) (set-visited-file-name file) (save-buffer)) (message "Can not write: %s" file)) (message "Write file %s...done" file)))) (defun vlc-check-directory () "Check if directories exist in location tag." (interactive) (let* ((default "check-directory") (file (read-string "Filename name: " default nil default)) (dirs (read-string "Directory name: " nil nil nil)) (tmp " *xspf") string) (and (when (file-exists-p file) (y-or-n-p (concat "Overwrite `" file "'? "))) (if (or (not (file-exists-p file)) (file-writable-p file)) (progn (vlc-xml2csv-tempbuffer tmp "location") (set-buffer (get-buffer-create file)) (erase-buffer) (set-buffer tmp) (dolist (dir (directory-files dirs t)) (when (and (file-directory-p dir) (not (member (file-name-nondirectory dir) '("." "..")))) (goto-char (point-min)) (unless (catch 'found (while (not (eobp)) (setq string (buffer-substring (point-at-bol) (point-at-eol))) (when (string= dir (substring string 7)) (throw 'found t)) (forward-line 1)) nil) (with-current-buffer file (insert dir) (insert "\n"))))) (switch-to-buffer file) (delete-other-windows) (goto-char (point-min)) (set-visited-file-name file) (save-buffer)) (message "Can not write: %s" file)) (message "Write file %s...done" file))))