mirror of
https://github.com/simon-ding/polaris.git
synced 2026-03-07 18:10:49 +08:00
feat: change progress display
This commit is contained in:
@@ -247,7 +247,8 @@ func (s *Server) downloadImage(url string, mediaID int, name string) error {
|
||||
|
||||
type MediaWithStatus struct {
|
||||
*ent.Media
|
||||
Status string `json:"status"`
|
||||
MonitoredNum int `json:"monitored_num"`
|
||||
DownloadedNum int `json:"downloaded_num"`
|
||||
}
|
||||
|
||||
//missing: episode aired missing
|
||||
@@ -260,26 +261,38 @@ func (s *Server) GetTvWatchlist(c *gin.Context) (interface{}, error) {
|
||||
res := make([]MediaWithStatus, len(list))
|
||||
for i, item := range list {
|
||||
var ms = MediaWithStatus{
|
||||
Media: item,
|
||||
Status: "downloaded",
|
||||
Media: item,
|
||||
MonitoredNum: 0,
|
||||
DownloadedNum: 0,
|
||||
}
|
||||
|
||||
details := s.db.GetMediaDetails(item.ID)
|
||||
|
||||
for _, ep := range details.Episodes {
|
||||
monitored := false
|
||||
if ep.SeasonNumber == 0 {
|
||||
continue
|
||||
}
|
||||
t, err := time.Parse("2006-01-02", ep.AirDate)
|
||||
if err != nil { //airdate not exist
|
||||
ms.Status = "monitoring"
|
||||
if item.DownloadHistoryEpisodes {
|
||||
monitored = true
|
||||
} else {
|
||||
if item.CreatedAt.Sub(t) > 24*time.Hour { //剧集在加入watchlist之前,不去下载
|
||||
continue
|
||||
}
|
||||
if ep.Status == episode.StatusMissing {
|
||||
ms.Status = "monitoring"
|
||||
t, err := time.Parse("2006-01-02", ep.AirDate)
|
||||
if err != nil { //airdate not exist, maybe airdate not set yet
|
||||
monitored = true
|
||||
} else {
|
||||
if item.CreatedAt.Sub(t) > 24*time.Hour { //剧集在加入watchlist之前,不去下载
|
||||
continue
|
||||
}
|
||||
monitored = true
|
||||
}
|
||||
}
|
||||
if monitored {
|
||||
ms.MonitoredNum++
|
||||
if ep.Status == episode.StatusDownloaded {
|
||||
ms.DownloadedNum++
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
res[i] = ms
|
||||
}
|
||||
@@ -292,14 +305,15 @@ func (s *Server) GetMovieWatchlist(c *gin.Context) (interface{}, error) {
|
||||
for i, item := range list {
|
||||
var ms = MediaWithStatus{
|
||||
Media: item,
|
||||
Status: "monitoring",
|
||||
MonitoredNum: 1,
|
||||
DownloadedNum: 0,
|
||||
}
|
||||
dummyEp, err := s.db.GetMovieDummyEpisode(item.ID)
|
||||
if err != nil {
|
||||
log.Errorf("get dummy episode: %v", err)
|
||||
} else {
|
||||
if dummyEp.Status != episode.StatusMissing {
|
||||
ms.Status = "downloaded"
|
||||
if dummyEp.Status == episode.StatusDownloaded {
|
||||
ms.DownloadedNum++
|
||||
}
|
||||
}
|
||||
res[i] = ms
|
||||
|
||||
@@ -7,7 +7,7 @@ import 'package:ui/providers/APIs.dart';
|
||||
import 'package:ui/providers/server_response.dart';
|
||||
|
||||
final tvWatchlistDataProvider = FutureProvider.autoDispose((ref) async {
|
||||
final dio = APIs.getDio();
|
||||
final dio = APIs.getDio();
|
||||
var resp = await dio.get(APIs.watchlistTvUrl);
|
||||
var sp = ServerResponse.fromJson(resp.data);
|
||||
List<MediaDetail> favList = List.empty(growable: true);
|
||||
@@ -155,22 +155,23 @@ class MediaDetail {
|
||||
String? resolution;
|
||||
int? storageId;
|
||||
String? airDate;
|
||||
String? status;
|
||||
int? monitoredNum;
|
||||
int? downloadedNum;
|
||||
|
||||
MediaDetail({
|
||||
this.id,
|
||||
this.tmdbId,
|
||||
this.mediaType,
|
||||
this.name,
|
||||
this.originalName,
|
||||
this.overview,
|
||||
this.posterPath,
|
||||
this.createdAt,
|
||||
this.resolution,
|
||||
this.storageId,
|
||||
this.airDate,
|
||||
this.status,
|
||||
});
|
||||
MediaDetail(
|
||||
{this.id,
|
||||
this.tmdbId,
|
||||
this.mediaType,
|
||||
this.name,
|
||||
this.originalName,
|
||||
this.overview,
|
||||
this.posterPath,
|
||||
this.createdAt,
|
||||
this.resolution,
|
||||
this.storageId,
|
||||
this.airDate,
|
||||
this.monitoredNum,
|
||||
this.downloadedNum});
|
||||
|
||||
MediaDetail.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
@@ -184,7 +185,8 @@ class MediaDetail {
|
||||
resolution = json["resolution"];
|
||||
storageId = json["storage_id"];
|
||||
airDate = json["air_date"];
|
||||
status = json["status"];
|
||||
monitoredNum = json["monitored_num"]??0;
|
||||
downloadedNum = json["download_num"]??0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ class WelcomePage extends ConsumerWidget {
|
||||
))
|
||||
]
|
||||
: List.generate(value.length, (i) {
|
||||
var item = value[i];
|
||||
final item = value[i];
|
||||
return Card(
|
||||
margin: const EdgeInsets.all(4),
|
||||
clipBehavior: Clip.hardEdge,
|
||||
@@ -68,14 +68,15 @@ class WelcomePage extends ConsumerWidget {
|
||||
children: [
|
||||
LinearProgressIndicator(
|
||||
value: 1,
|
||||
color: item.status == "downloaded"
|
||||
color: item.downloadedNum ==
|
||||
item.monitoredNum
|
||||
? Colors.green
|
||||
: Colors.blue,
|
||||
),
|
||||
Text(
|
||||
item.name!,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.bold,
|
||||
height: 2.5),
|
||||
|
||||
Reference in New Issue
Block a user