Skip to content

Commit

Permalink
Organise unknown podcasts a bit better
Browse files Browse the repository at this point in the history
Rather than showing a podcast's URL in the podcast menu, instead group
all unknown episodes under a single fake podcast called "Unrecognised".
This should make navigating one-off stuff a bit easier - as well as
making the UI nicer.
  • Loading branch information
ejv2 committed Jul 15, 2024
1 parent f74fe01 commit 787b781
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
17 changes: 15 additions & 2 deletions data/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@ var PossibleDirs = []string{
".newsboat",
}

// QueueFilename is the name of the file for the queue.
const QueueFilename = "queue"
const (
// QueueFilename is the name of the file for the queue.
QueueFilename = "queue"
// UnknownPodcastName is the name used for episodes from an unknown podcast.
UnknownPodcastName = "Unrecognised"
)

// Possible states of download queue.
const (
Expand Down Expand Up @@ -293,15 +297,24 @@ func (q *Queue) GetPodcasts() (podcasts []string) {
defer q.mutex.RUnlock()

seen := make(map[string]bool)
uncat := false

for i := range q.Items {
name := DB.GetFriendlyName(q.Items[i].URL)
if name == q.Items[i].URL {
uncat = true
continue
}

if !seen[name] {
podcasts = append(podcasts, name)
seen[name] = true
}
}

if uncat {
podcasts = append(podcasts, UnknownPodcastName)
}
return
}

Expand Down
7 changes: 6 additions & 1 deletion ui/library.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@ func (l *Library) renderEpisodes(x, y int) {

data.Q.RevRange(func(i int, elem *data.QueueItem) bool {
_, sel := l.men[0].GetSelection()
if data.DB.GetFriendlyName(elem.URL) == sel {
pc := data.DB.GetFriendlyName(elem.URL)

// Render this item if:
// - It is a member of the current podcast
// - It is uncategorised and we are showing those
if pc == sel || (sel == data.UnknownPodcastName && pc == elem.URL) {
var text string
entry, ok := data.Downloads.Query(elem.Path)
title := entry.Title
Expand Down

0 comments on commit 787b781

Please sign in to comment.