feat: support generate .plexmatch

This commit is contained in:
Simon Ding
2024-07-30 15:51:54 +08:00
parent 233970ef39
commit 6ef4bedebe
9 changed files with 142 additions and 32 deletions

View File

@@ -14,6 +14,8 @@ import (
type Storage interface {
Move(src, dest string) error
ReadDir(dir string) ([]fs.FileInfo, error)
ReadFile(string)([]byte, error)
WriteFile(string, []byte) error
}
func NewLocalStorage(dir string) (*LocalStorage, error) {
@@ -81,3 +83,12 @@ func (l *LocalStorage) Move(src, destDir string) error {
func (l *LocalStorage) ReadDir(dir string) ([]fs.FileInfo, error) {
return ioutil.ReadDir(filepath.Join(l.dir, dir))
}
func (l *LocalStorage) ReadFile(name string) ([]byte, error) {
return os.ReadFile(name)
}
func (l *LocalStorage) WriteFile(name string, data []byte) error {
return os.WriteFile(name, data, os.ModePerm)
}

View File

@@ -98,3 +98,13 @@ func (w *WebdavStorage) Move(local, remoteDir string) error {
func (w *WebdavStorage) ReadDir(dir string) ([]fs.FileInfo, error) {
return w.fs.ReadDir(filepath.Join(w.dir, dir))
}
func (w *WebdavStorage) ReadFile(name string) ([]byte, error) {
return w.fs.Read(filepath.Join(w.dir, name))
}
func (w *WebdavStorage) WriteFile(name string, data []byte) error {
return w.fs.Write(filepath.Join(w.dir, name), data, os.ModePerm)
}