Library: mark titles that are downloading
While the Library is visible it reads the Radarr and Sonarr queues (on opening, every 10 s, and shortly after a grab) and matches them to the titles by movieId / seriesId. Those titles get a blue dot instead of the green or grey one, and their details say how far the download is. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -345,3 +345,39 @@ func TestSeasonPoster(t *testing.T) {
|
||||
t.Errorf("a season poster that cannot be loaded falls back to the series poster: %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDownloadingTitlesAreMarked(t *testing.T) {
|
||||
movies := queueByTitle([]arr.QueueItem{
|
||||
{MovieID: 3, Size: 100, SizeLeft: 55, TimeLeft: "00:06:12"},
|
||||
{MovieID: 0}, // not matched to a movie
|
||||
}, false)
|
||||
series := queueByTitle([]arr.QueueItem{{SeriesID: 7, Size: 10, SizeLeft: 10}, {SeriesID: 7}, {MovieID: 3}}, true)
|
||||
if len(movies) != 1 || movies[3].count != 1 || movies[3].progress != 45 || movies[3].dlLine() != "[blue]Downloading[-] 45% · 00:06:12 left\n" {
|
||||
t.Errorf("movies %+v", movies)
|
||||
}
|
||||
if len(series) != 1 || series[7].count != 2 || series[7].dlLine() != "[blue]Downloading[-] 2 episodes\n" {
|
||||
t.Errorf("series %+v", series)
|
||||
}
|
||||
|
||||
a := newTestApp(t)
|
||||
v := newLibraryView(a, a.radarr, a.sonarr)
|
||||
p := v.panes[kindMovies]
|
||||
p.all, p.loaded = []libItem{
|
||||
{id: 3, title: "Dune", label: "Dune (2021)", monitored: true, details: detailText{head: "Dune\n"}},
|
||||
{id: 4, title: "Heat", label: "Heat (1995)", monitored: true},
|
||||
}, true
|
||||
v.downloading[kindMovies] = movies
|
||||
v.render()
|
||||
cell := func(row int) string { return p.table.GetCell(row, 0).Text }
|
||||
if !strings.HasPrefix(cell(1), "[blue]●[-]") || !strings.HasPrefix(cell(2), "[green]●[-]") {
|
||||
t.Errorf("marks: %q / %q", cell(1), cell(2))
|
||||
}
|
||||
p.table.Select(1, 0)
|
||||
v.renderDetails()
|
||||
if !strings.Contains(v.details.detail.head, "Downloading[-] 45%") {
|
||||
t.Errorf("details %q", v.details.detail.head)
|
||||
}
|
||||
if libMark(false, true) != "[blue]○[-]" {
|
||||
t.Error("an unmonitored title in the queue keeps the hollow mark")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user