mirror of
https://github.com/simon-ding/polaris.git
synced 2026-06-05 09:27:43 +08:00
update
This commit is contained in:
26
db/db.go
26
db/db.go
@@ -135,9 +135,15 @@ func (c *Client) SaveTorznabInfo(name string, setting TorznabSetting) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) GetAllTorznabInfo() map[string]TorznabSetting {
|
type TorznabInfo struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
TorznabSetting
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Client) GetAllTorznabInfo() []*TorznabInfo {
|
||||||
res := c.ent.Indexers.Query().Where(indexers.Implementation(IndexerTorznabImpl)).AllX(context.TODO())
|
res := c.ent.Indexers.Query().Where(indexers.Implementation(IndexerTorznabImpl)).AllX(context.TODO())
|
||||||
var m = make(map[string]TorznabSetting, len(res))
|
|
||||||
|
var l = make([]*TorznabInfo, 0, len(res))
|
||||||
for _, r := range res {
|
for _, r := range res {
|
||||||
var ss TorznabSetting
|
var ss TorznabSetting
|
||||||
err := json.Unmarshal([]byte(r.Settings), &ss)
|
err := json.Unmarshal([]byte(r.Settings), &ss)
|
||||||
@@ -145,9 +151,12 @@ func (c *Client) GetAllTorznabInfo() map[string]TorznabSetting {
|
|||||||
log.Errorf("unmarshal torznab %s error: %v", r.Name, err)
|
log.Errorf("unmarshal torznab %s error: %v", r.Name, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
m[r.Name] = ss
|
l = append(l, &TorznabInfo{
|
||||||
|
Name: r.Name,
|
||||||
|
TorznabSetting: ss,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
return m
|
return l
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) SaveTransmission(name, url, user, password string) error {
|
func (c *Client) SaveTransmission(name, url, user, password string) error {
|
||||||
@@ -165,3 +174,12 @@ func (c *Client) GetTransmission() *ent.DownloadClients {
|
|||||||
}
|
}
|
||||||
return dc
|
return dc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Client) GetAllDonloadClients() []*ent.DownloadClients {
|
||||||
|
cc, err := c.ent.DownloadClients.Query().All(context.TODO())
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("no download client")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return cc
|
||||||
|
}
|
||||||
|
|||||||
@@ -16,10 +16,10 @@ func (s *Server) searchTvWithTorznab(name string, season, episode int) []torznab
|
|||||||
|
|
||||||
var res []torznab.Result
|
var res []torznab.Result
|
||||||
allTorznab := s.db.GetAllTorznabInfo()
|
allTorznab := s.db.GetAllTorznabInfo()
|
||||||
for name, setting := range allTorznab {
|
for _, tor := range allTorznab {
|
||||||
resp, err := torznab.Search(setting.URL, setting.ApiKey, q)
|
resp, err := torznab.Search(tor.URL, tor.ApiKey, q)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("search %s error: %v", name, err)
|
log.Errorf("search %s error: %v", tor.Name, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
res = append(res, resp...)
|
res = append(res, resp...)
|
||||||
@@ -48,6 +48,14 @@ func (s *Server) AddTorznabInfo(c *gin.Context) (interface{}, error) {
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Server) GetAllIndexers(c *gin.Context) (interface{}, error) {
|
||||||
|
indexers := s.db.GetAllTorznabInfo()
|
||||||
|
if len(indexers) == 0 {
|
||||||
|
return nil, fmt.Errorf("no indexer found")
|
||||||
|
}
|
||||||
|
return indexers, nil
|
||||||
|
}
|
||||||
|
|
||||||
type searchAndDownloadIn struct {
|
type searchAndDownloadIn struct {
|
||||||
ID int `json:"id"`
|
ID int `json:"id"`
|
||||||
Season int `json:"season"`
|
Season int `json:"season"`
|
||||||
@@ -109,3 +117,11 @@ func (s *Server) AddDownloadClient(c *gin.Context) (interface{}, error) {
|
|||||||
}
|
}
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Server) GetAllDonloadClients(c *gin.Context) (interface{}, error) {
|
||||||
|
res := s.db.GetAllDonloadClients()
|
||||||
|
if len(res) == 0 {
|
||||||
|
return nil, fmt.Errorf("no download client")
|
||||||
|
}
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
@@ -64,12 +64,14 @@ func (s *Server) Serve() error {
|
|||||||
}
|
}
|
||||||
indexer := api.Group("/indexer")
|
indexer := api.Group("/indexer")
|
||||||
{
|
{
|
||||||
|
indexer.GET("/", HttpHandler(s.GetAllIndexers))
|
||||||
indexer.POST("/add", HttpHandler(s.AddTorznabInfo))
|
indexer.POST("/add", HttpHandler(s.AddTorznabInfo))
|
||||||
indexer.POST("/download", HttpHandler(s.SearchAndDownload))
|
indexer.POST("/download", HttpHandler(s.SearchAndDownload))
|
||||||
}
|
}
|
||||||
|
|
||||||
downloader := api.Group("/downloader")
|
downloader := api.Group("/downloader")
|
||||||
{
|
{
|
||||||
|
downloader.GET("/", HttpHandler(s.GetAllDonloadClients))
|
||||||
downloader.POST("/add", HttpHandler(s.AddDownloadClient))
|
downloader.POST("/add", HttpHandler(s.AddDownloadClient))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,42 +29,40 @@ class _WeclomePageState extends State<WelcomePage> {
|
|||||||
return GridView.builder(
|
return GridView.builder(
|
||||||
itemCount: favList.length,
|
itemCount: favList.length,
|
||||||
gridDelegate:
|
gridDelegate:
|
||||||
const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 4),
|
const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 6),
|
||||||
itemBuilder: (context, i) {
|
itemBuilder: (context, i) {
|
||||||
var item = TvSeries.fromJson(favList[i]);
|
var item = TvSeries.fromJson(favList[i]);
|
||||||
return Container(
|
return Card(
|
||||||
child: Card(
|
margin: const EdgeInsets.all(4),
|
||||||
margin: const EdgeInsets.all(4),
|
clipBehavior: Clip.hardEdge,
|
||||||
clipBehavior: Clip.hardEdge,
|
child: InkWell(
|
||||||
child: InkWell(
|
//splashColor: Colors.blue.withAlpha(30),
|
||||||
//splashColor: Colors.blue.withAlpha(30),
|
onTap: () {
|
||||||
onTap: () {
|
context.go(TvDetailsPage.toRoute(item.id!));
|
||||||
context.go(TvDetailsPage.toRoute(item.id!));
|
//showDialog(context: context, builder: builder)
|
||||||
//showDialog(context: context, builder: builder)
|
},
|
||||||
},
|
child: Column(
|
||||||
child: Column(
|
children: <Widget>[
|
||||||
children: <Widget>[
|
Flexible(
|
||||||
Flexible(
|
child: SizedBox(
|
||||||
child: SizedBox(
|
width: 300,
|
||||||
width: 300,
|
height: 600,
|
||||||
height: 600,
|
child: Image.network(
|
||||||
child: Image.network(
|
APIs.tmdbImgBaseUrl + item.posterPath!,
|
||||||
APIs.tmdbImgBaseUrl + item.posterPath!,
|
fit: BoxFit.contain,
|
||||||
fit: BoxFit.contain,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Flexible(
|
),
|
||||||
child: Text(
|
Flexible(
|
||||||
item.name!,
|
child: Text(
|
||||||
style: const TextStyle(
|
item.name!,
|
||||||
fontSize: 14, fontWeight: FontWeight.bold),
|
style: const TextStyle(
|
||||||
),
|
fontSize: 14, fontWeight: FontWeight.bold),
|
||||||
)
|
),
|
||||||
],
|
)
|
||||||
),
|
],
|
||||||
)),
|
),
|
||||||
);
|
));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user