diff --git a/lisp/init-func.el b/lisp/init-func.el index cf10086..5d6e885 100644 --- a/lisp/init-func.el +++ b/lisp/init-func.el @@ -137,27 +137,25 @@ Directory entries are excluded from the returned list." (setq has-stream t)))) (and has-index has-movie-object has-playlist has-stream))) +(defun creature/directory-file-match-p (dir regexp) + "Return non-nil when DIR contains a regular file matching REGEXP." + (when (file-directory-p dir) + (let* ((case-fold-search t) + (path (car (directory-files dir t regexp t 1)))) + (and path (file-regular-p path))))) + (defun creature/bluray-directory-p (dir) "Return non-nil when DIR looks like a Blu-ray directory tree." (let* ((bdmv-dir (file-name-concat dir "BDMV")) (index-file (file-name-concat bdmv-dir "index.bdmv")) (movie-object-file (file-name-concat bdmv-dir "MovieObject.bdmv")) (playlist-dir (file-name-concat bdmv-dir "PLAYLIST")) - (stream-dir (file-name-concat bdmv-dir "STREAM")) - (playlist-files (and (file-directory-p playlist-dir) - (directory-files playlist-dir t nil t))) - (stream-files (and (file-directory-p stream-dir) - (directory-files stream-dir t nil t)))) - (and (file-regular-p index-file) + (stream-dir (file-name-concat bdmv-dir "STREAM"))) + (and (file-directory-p dir) + (file-regular-p index-file) (file-regular-p movie-object-file) - (seq-some (lambda (path) - (and (file-regular-p path) - (string-suffix-p ".mpls" path t))) - playlist-files) - (seq-some (lambda (path) - (and (file-regular-p path) - (string-suffix-p ".m2ts" path t))) - stream-files)))) + (creature/directory-file-match-p playlist-dir "\\.mpls\\'") + (creature/directory-file-match-p stream-dir "\\.m2ts\\'")))) (defun creature/play-with-mpv (filename) "Play local media FILENAME with mpv, including Blu-ray directories and images."