mirror of
https://github.com/simon-ding/polaris.git
synced 2026-05-28 13:37:43 +08:00
feat: seprate tv and movie path
This commit is contained in:
16
db/db.go
16
db/db.go
@@ -274,14 +274,16 @@ type StorageInfo struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type LocalDirSetting struct {
|
type LocalDirSetting struct {
|
||||||
Path string `json:"path"`
|
TvPath string `json:"tv_path"`
|
||||||
|
MoviePath string `json:"movie_path"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type WebdavSetting struct {
|
type WebdavSetting struct {
|
||||||
URL string `json:"url"`
|
URL string `json:"url"`
|
||||||
Path string `json:"path"`
|
TvPath string `json:"tv_path"`
|
||||||
User string `json:"user"`
|
MoviePath string `json:"movie_path"`
|
||||||
Password string `json:"password"`
|
User string `json:"user"`
|
||||||
|
Password string `json:"password"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) AddStorage(st *StorageInfo) error {
|
func (c *Client) AddStorage(st *StorageInfo) error {
|
||||||
@@ -343,10 +345,10 @@ func (s *Storage) ToWebDavSetting() WebdavSetting {
|
|||||||
return webdavSetting
|
return webdavSetting
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Storage) GetPath() string {
|
func (s *Storage) GetPath() (tvPath string, moviePath string) {
|
||||||
var m map[string]string
|
var m map[string]string
|
||||||
json.Unmarshal([]byte(s.Settings), &m)
|
json.Unmarshal([]byte(s.Settings), &m)
|
||||||
return m["path"]
|
return m["tv_path"], m["movie_path"]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) GetStorage(id int) *Storage {
|
func (c *Client) GetStorage(id int) *Storage {
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ func (c *Client) Download(magnet, dir string) (*Torrent, error) {
|
|||||||
type Torrent struct {
|
type Torrent struct {
|
||||||
//t *transmissionrpc.Torrent
|
//t *transmissionrpc.Torrent
|
||||||
c *transmissionrpc.Client
|
c *transmissionrpc.Client
|
||||||
ID int64 `json: "id"`
|
ID int64 `json:"id"`
|
||||||
Config
|
Config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -85,7 +85,11 @@ func (s *Server) moveCompletedTask(id int) (err error) {
|
|||||||
var stImpl storage.Storage
|
var stImpl storage.Storage
|
||||||
if st.Implementation == storage1.ImplementationWebdav {
|
if st.Implementation == storage1.ImplementationWebdav {
|
||||||
ws := st.ToWebDavSetting()
|
ws := st.ToWebDavSetting()
|
||||||
storageImpl, err := storage.NewWebdavStorage(ws.URL, ws.User, ws.Password, ws.Path)
|
targetPath := ws.TvPath
|
||||||
|
if series.MediaType == media.MediaTypeMovie {
|
||||||
|
targetPath = ws.MoviePath
|
||||||
|
}
|
||||||
|
storageImpl, err := storage.NewWebdavStorage(ws.URL, ws.User, ws.Password, targetPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "new webdav")
|
return errors.Wrap(err, "new webdav")
|
||||||
}
|
}
|
||||||
@@ -93,7 +97,12 @@ func (s *Server) moveCompletedTask(id int) (err error) {
|
|||||||
|
|
||||||
} else if st.Implementation == storage1.ImplementationLocal {
|
} else if st.Implementation == storage1.ImplementationLocal {
|
||||||
ls := st.ToLocalSetting()
|
ls := st.ToLocalSetting()
|
||||||
storageImpl, err := storage.NewLocalStorage(ls.Path)
|
targetPath := ls.TvPath
|
||||||
|
if series.MediaType == media.MediaTypeMovie {
|
||||||
|
targetPath = ls.MoviePath
|
||||||
|
}
|
||||||
|
|
||||||
|
storageImpl, err := storage.NewLocalStorage(targetPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "new storage")
|
return errors.Wrap(err, "new storage")
|
||||||
}
|
}
|
||||||
@@ -130,7 +139,12 @@ func (s *Server) checkFileExists(series *ent.Media) error {
|
|||||||
switch st.Implementation {
|
switch st.Implementation {
|
||||||
case storage1.ImplementationLocal:
|
case storage1.ImplementationLocal:
|
||||||
ls := st.ToLocalSetting()
|
ls := st.ToLocalSetting()
|
||||||
storageImpl1, err := storage.NewLocalStorage(ls.Path)
|
targetPath := ls.TvPath
|
||||||
|
if series.MediaType == media.MediaTypeMovie {
|
||||||
|
targetPath = ls.MoviePath
|
||||||
|
}
|
||||||
|
|
||||||
|
storageImpl1, err := storage.NewLocalStorage(targetPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "new local")
|
return errors.Wrap(err, "new local")
|
||||||
}
|
}
|
||||||
@@ -138,7 +152,12 @@ func (s *Server) checkFileExists(series *ent.Media) error {
|
|||||||
|
|
||||||
case storage1.ImplementationWebdav:
|
case storage1.ImplementationWebdav:
|
||||||
ws := st.ToWebDavSetting()
|
ws := st.ToWebDavSetting()
|
||||||
storageImpl1, err := storage.NewWebdavStorage(ws.URL, ws.User, ws.Password, ws.Path)
|
targetPath := ws.TvPath
|
||||||
|
if series.MediaType == media.MediaTypeMovie {
|
||||||
|
targetPath = ws.MoviePath
|
||||||
|
}
|
||||||
|
|
||||||
|
storageImpl1, err := storage.NewWebdavStorage(ws.URL, ws.User, ws.Password, targetPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "new webdav")
|
return errors.Wrap(err, "new webdav")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -472,24 +472,26 @@ class _SystemSettingsPageState extends ConsumerState<SystemSettingsPage> {
|
|||||||
|
|
||||||
Future<void> showStorageDetails(
|
Future<void> showStorageDetails(
|
||||||
AsyncSnapshot<void> snapshot, BuildContext context, Storage s) {
|
AsyncSnapshot<void> snapshot, BuildContext context, Storage s) {
|
||||||
|
|
||||||
return showDialog<void>(
|
return showDialog<void>(
|
||||||
context: context,
|
context: context,
|
||||||
barrierDismissible: true, // user must tap button!
|
barrierDismissible: true, // user must tap button!
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
var nameController = TextEditingController(text: s.name);
|
var nameController = TextEditingController(text: s.name);
|
||||||
var pathController = TextEditingController();
|
var tvPathController = TextEditingController();
|
||||||
|
var moviePathController = TextEditingController();
|
||||||
var urlController = TextEditingController();
|
var urlController = TextEditingController();
|
||||||
var userController = TextEditingController();
|
var userController = TextEditingController();
|
||||||
var passController = TextEditingController();
|
var passController = TextEditingController();
|
||||||
if (s.settings != null) {
|
if (s.settings != null) {
|
||||||
pathController.text = s.settings!["path"];
|
tvPathController.text = s.settings!["tv_path"] ?? "";
|
||||||
urlController.text = s.settings!["url"];
|
moviePathController.text = s.settings!["movie_path"] ?? "";
|
||||||
userController.text = s.settings!["user"];
|
urlController.text = s.settings!["url"]?? "";
|
||||||
passController.text = s.settings!["password"];
|
userController.text = s.settings!["user"] ?? "";
|
||||||
|
passController.text = s.settings!["password"] ?? "";
|
||||||
}
|
}
|
||||||
|
|
||||||
String _selectImpl = s.implementation == null? "local": s.implementation!;
|
String _selectImpl =
|
||||||
|
s.implementation == null ? "local" : s.implementation!;
|
||||||
return StatefulBuilder(builder: (context, setState) {
|
return StatefulBuilder(builder: (context, setState) {
|
||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
title: const Text('存储'),
|
title: const Text('存储'),
|
||||||
@@ -513,12 +515,9 @@ class _SystemSettingsPageState extends ConsumerState<SystemSettingsPage> {
|
|||||||
decoration: const InputDecoration(labelText: "名称"),
|
decoration: const InputDecoration(labelText: "名称"),
|
||||||
controller: nameController,
|
controller: nameController,
|
||||||
),
|
),
|
||||||
_selectImpl == "local"
|
_selectImpl != "local"
|
||||||
? TextField(
|
?
|
||||||
decoration: const InputDecoration(labelText: "路径"),
|
Column(
|
||||||
controller: pathController,
|
|
||||||
)
|
|
||||||
: Column(
|
|
||||||
children: [
|
children: [
|
||||||
TextField(
|
TextField(
|
||||||
decoration: const InputDecoration(
|
decoration: const InputDecoration(
|
||||||
@@ -535,12 +534,15 @@ class _SystemSettingsPageState extends ConsumerState<SystemSettingsPage> {
|
|||||||
const InputDecoration(labelText: "密码"),
|
const InputDecoration(labelText: "密码"),
|
||||||
controller: passController,
|
controller: passController,
|
||||||
),
|
),
|
||||||
TextField(
|
|
||||||
decoration:
|
|
||||||
const InputDecoration(labelText: "路径"),
|
|
||||||
controller: pathController,
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
|
): Container(),
|
||||||
|
TextField(
|
||||||
|
decoration: const InputDecoration(labelText: "电视剧路径"),
|
||||||
|
controller: tvPathController,
|
||||||
|
),
|
||||||
|
TextField(
|
||||||
|
decoration: const InputDecoration(labelText: "电影路径"),
|
||||||
|
controller: moviePathController,
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -573,7 +575,8 @@ class _SystemSettingsPageState extends ConsumerState<SystemSettingsPage> {
|
|||||||
name: nameController.text,
|
name: nameController.text,
|
||||||
implementation: _selectImpl,
|
implementation: _selectImpl,
|
||||||
settings: {
|
settings: {
|
||||||
"path": pathController.text,
|
"tv_path": tvPathController.text,
|
||||||
|
"movie_path": moviePathController.text,
|
||||||
"url": urlController.text,
|
"url": urlController.text,
|
||||||
"user": userController.text,
|
"user": userController.text,
|
||||||
"password": passController.text
|
"password": passController.text
|
||||||
|
|||||||
Reference in New Issue
Block a user