Skip to content

Commit

Permalink
Fix setting default YouTube.Channels[*].Keep
Browse files Browse the repository at this point in the history
  • Loading branch information
rantanevich authored and umputun committed Nov 11, 2022
1 parent 0b7438d commit b0a9228
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ func (c *Conf) setDefaults() {
c.YouTube.UpdateInterval = c.System.UpdateInterval
}

for _, f := range c.YouTube.Channels {
for idx, f := range c.YouTube.Channels {
if f.Keep == 0 {
f.Keep = c.System.MaxItems
c.YouTube.Channels[idx].Keep = c.System.MaxItems
}

}
Expand Down
4 changes: 2 additions & 2 deletions app/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ func TestLoad(t *testing.T) {
assert.Equal(t, "https://bbb.com/u1", r.Feeds["second"].Sources[0].URL)
assert.Equal(t, "^filterme*", r.Feeds["filtered"].Filter.Title)
assert.Equal(t, time.Second*600, r.System.UpdateInterval)
assert.Equal(t, []ytfdeed.FeedInfo{{Name: "name1", ID: "id1", Type: "playlist"},
{Name: "name2", ID: "id2", Type: "channel", Language: "ru-ru"}},
assert.Equal(t, []ytfdeed.FeedInfo{{Name: "name1", ID: "id1", Type: "playlist", Keep: 15},
{Name: "name2", ID: "id2", Type: "channel", Language: "ru-ru", Keep: 5}},
r.YouTube.Channels, "2 yt")
assert.Equal(t, "yt-dlp --extract-audio --audio-format=mp3 -f m4a/bestaudio \"https://www.youtube.com/watch?v={{.ID}}\" --no-progress -o {{.Filename}}.tmp", r.YouTube.DlTemplate)
assert.Equal(t, "https://www.youtube.com/videos.xml?channel_id=", r.YouTube.BaseChanURL)
Expand Down
2 changes: 1 addition & 1 deletion app/config/testdata/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ youtube:
base_playlist_url: "https://www.youtube.com/videos.xml?playlist_id="
rss_location: ./var/rss
channels:
- {id: id1, name: name1, type: playlist}
- {id: id1, name: name1, type: playlist, keep: 15}
- {id: id2, name: name2, lang: ru-ru, type: channel}

0 comments on commit b0a9228

Please sign in to comment.