mirror of
https://github.com/simon-ding/polaris.git
synced 2026-06-26 02:34:58 +08:00
fix: add to watchlist
This commit is contained in:
7
server/activity.go
Normal file
7
server/activity.go
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
package server
|
||||||
|
|
||||||
|
import "github.com/gin-gonic/gin"
|
||||||
|
|
||||||
|
func (s *Server) GetRunningActivities(c *gin.Context) (interface{}, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
@@ -57,6 +57,7 @@ func (s *Server) Serve() error {
|
|||||||
tv.POST("/watchlist", HttpHandler(s.AddWatchlist))
|
tv.POST("/watchlist", HttpHandler(s.AddWatchlist))
|
||||||
tv.GET("/watchlist", HttpHandler(s.GetWatchlist))
|
tv.GET("/watchlist", HttpHandler(s.GetWatchlist))
|
||||||
tv.GET("/series/:id", HttpHandler(s.GetTvDetails))
|
tv.GET("/series/:id", HttpHandler(s.GetTvDetails))
|
||||||
|
tv.GET("/resolutions", HttpHandler(s.GetAvailableResolutions))
|
||||||
}
|
}
|
||||||
indexer := api.Group("/indexer")
|
indexer := api.Group("/indexer")
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -28,8 +28,9 @@ func (s *Server) SearchTvSeries(c *gin.Context) (interface{}, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type addWatchlistIn struct {
|
type addWatchlistIn struct {
|
||||||
TmdbID int `json:"id" binding:"required"`
|
TmdbID int `json:"tmdb_id" binding:"required"`
|
||||||
StorageID int `json:"storage_id"`
|
StorageID int `json:"storage_id" binding:"required"`
|
||||||
|
Resolution db.ResolutionType `json:"resolution" binding:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) AddWatchlist(c *gin.Context) (interface{}, error) {
|
func (s *Server) AddWatchlist(c *gin.Context) (interface{}, error) {
|
||||||
@@ -99,3 +100,11 @@ func (s *Server) GetTvDetails(c *gin.Context) (interface{}, error) {
|
|||||||
detail := s.db.GetSeriesDetails(id)
|
detail := s.db.GetSeriesDetails(id)
|
||||||
return detail, nil
|
return detail, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Server) GetAvailableResolutions(c *gin.Context) (interface{}, error) {
|
||||||
|
return []db.ResolutionType{
|
||||||
|
db.R720p,
|
||||||
|
db.R1080p,
|
||||||
|
db.R4k,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
@@ -28,10 +28,14 @@ class SearchPageData extends AutoDisposeAsyncNotifier<List<SearchResult>> {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> submit2Watchlist(int id) async {
|
Future<void> submit2Watchlist(int tmdbId, int storageId, String resolution) async {
|
||||||
final dio = await APIs.getDio();
|
final dio = await APIs.getDio();
|
||||||
var resp = await dio
|
var resp = await dio
|
||||||
.post(APIs.watchlistUrl, data: {"id": id, "folder": "/downloads"});
|
.post(APIs.watchlistUrl, data: {
|
||||||
|
"tmdb_id": tmdbId,
|
||||||
|
"storage_id": storageId,
|
||||||
|
"resolution": resolution
|
||||||
|
});
|
||||||
var sp = ServerResponse.fromJson(resp.data);
|
var sp = ServerResponse.fromJson(resp.data);
|
||||||
if (sp.code != 0) {
|
if (sp.code != 0) {
|
||||||
throw sp.message;
|
throw sp.message;
|
||||||
|
|||||||
@@ -90,9 +90,8 @@ class _SearchPageState extends ConsumerState<SearchPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _showSubmitDialog(BuildContext context, SearchResult item) {
|
Future<void> _showSubmitDialog(BuildContext context, SearchResult item) {
|
||||||
TextEditingController resolutionController =
|
String _resSelected = "1080p";
|
||||||
TextEditingController(text: "1080p");
|
int _storageSelected = 0;
|
||||||
TextEditingController storageController = TextEditingController();
|
|
||||||
var storage = ref.watch(storageSettingProvider);
|
var storage = ref.watch(storageSettingProvider);
|
||||||
return showDialog<void>(
|
return showDialog<void>(
|
||||||
context: context,
|
context: context,
|
||||||
@@ -104,22 +103,32 @@ class _SearchPageState extends ConsumerState<SearchPage> {
|
|||||||
children: [
|
children: [
|
||||||
DropdownMenu(
|
DropdownMenu(
|
||||||
label: const Text("清晰度"),
|
label: const Text("清晰度"),
|
||||||
controller: resolutionController,
|
initialSelection: _resSelected,
|
||||||
dropdownMenuEntries: const [
|
dropdownMenuEntries: const [
|
||||||
DropdownMenuEntry(value: "720p", label: "720p"),
|
DropdownMenuEntry(value: "720p", label: "720p"),
|
||||||
DropdownMenuEntry(value: "1080p", label: "1080p"),
|
DropdownMenuEntry(value: "1080p", label: "1080p"),
|
||||||
DropdownMenuEntry(value: "4k", label: "4k"),
|
DropdownMenuEntry(value: "4k", label: "4k"),
|
||||||
],
|
],
|
||||||
|
onSelected: (value) {
|
||||||
|
setState(() {
|
||||||
|
_resSelected = value!;
|
||||||
|
});
|
||||||
|
},
|
||||||
),
|
),
|
||||||
storage.when(
|
storage.when(
|
||||||
data: (v) {
|
data: (v) {
|
||||||
return DropdownMenu(
|
return DropdownMenu(
|
||||||
label: const Text("存储位置"),
|
label: const Text("存储位置"),
|
||||||
controller: storageController,
|
initialSelection: _storageSelected,
|
||||||
dropdownMenuEntries: v
|
dropdownMenuEntries: v
|
||||||
.map((s) =>
|
.map((s) =>
|
||||||
DropdownMenuEntry(label: s.name!, value: s.id))
|
DropdownMenuEntry(label: s.name!, value: s.id))
|
||||||
.toList(),
|
.toList(),
|
||||||
|
onSelected: (value) {
|
||||||
|
setState(() {
|
||||||
|
_storageSelected = value!;
|
||||||
|
});
|
||||||
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
error: (err, trace) => Text("$err"),
|
error: (err, trace) => Text("$err"),
|
||||||
@@ -144,7 +153,7 @@ class _SearchPageState extends ConsumerState<SearchPage> {
|
|||||||
onPressed: () {
|
onPressed: () {
|
||||||
ref
|
ref
|
||||||
.read(searchPageDataProvider.notifier)
|
.read(searchPageDataProvider.notifier)
|
||||||
.submit2Watchlist(item.id!);
|
.submit2Watchlist(item.id!, _storageSelected, _resSelected);
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user