umputun / feed-master

Pulls multiple podcast feeds (RSS) and republishes as a common feed, properly sorted and podcast-client friendly.
https://feed-master.umputun.dev
MIT License
116 stars 26 forks source link

YouTube feeds aren't processed if c.YouTube.Channels[*].Keep isn't set #98

Closed rantanevich closed 1 year ago

rantanevich commented 1 year ago

I have the following feed-master.yml:

youtube:
  channels:
  - id: UCuIE7-5QzeAR6EdZXwDRwuQ
    name: Дилетант
    type: channel
    lang: ru-ru

system:
  update: 10m
  max_per_feed: 5
  max_total: 30
  max_keep: 50
  base_url: http://localhost:8080

After running the server it logs that processor was activated with c.YouTube.Channels[0].Keep = 0:

2022/11/11 01:16:34.219 [INFO]  activate processor, feeds=0, &{Feeds:map[] System:{UpdateInterval:10m0s MaxItems:5 MaxTotal:30 MaxKeepInDB:50 Concurrent:8 BaseURL:http://localhost:8080} YouTube:{DlTemplate:yt-dlp --extract-audio --audio-format=mp3 --audio-quality=0 -f m4a/bestaudio "https://www.youtube.com/watch?v={{.ID}}" --no-progress -o {{.FileName}}.tmp BaseChanURL:https://www.youtube.com/feeds/videos.xml?channel_id= BasePlaylistURL:https://www.youtube.com/feeds/videos.xml?playlist_id= Channels:[{Name:Дилетант ID:UCuIE7-5QzeAR6EdZXwDRwuQ Type:channel Keep:0 Language:ru-ru Filter:{Include: Exclude:}}] BaseURL:http://localhost:8080/yt/media UpdateInterval:10m0s MaxItems:0 FilesLocation:var/yt RSSLocation:var/rss SkipShorts:0s}}
2022/11/11 01:16:34.219 [INFO]  starting youtube service
2022/11/11 01:16:34.219 [INFO]  youtube feed {Name:Дилетант ID:UCuIE7-5QzeAR6EdZXwDRwuQ Type:channel Keep:0 Language:ru-ru Filter:{Include: Exclude:}}
2022/11/11 01:16:34.637 [INFO]  got 15 entries for Дилетант, limit to 0
2022/11/11 01:16:34.637 [INFO]  all channels processed - channels: 1, entries: 1, processed: 0, updated: 0, removed: 0, ignored: 0, skipped: 0, lifetime: 0, feed size: 0
2022/11/11 01:16:34.637 [INFO]  last entry: {ChannelID:, VideoID:, Title:"", Published:0000-12-31T18:09:24-05:50, Updated:0000-12-31T18:09:24-05:50, Author:, File:, Duration:0s}

But if we set c.YouTube.Channels[0].Keep explicitly, it works.

youtube:
  channels:
  - id: UCuIE7-5QzeAR6EdZXwDRwuQ
    name: Дилетант
    type: channel
    lang: ru-ru
    keep: 5

system:
  update: 10m
  max_per_feed: 5
  max_total: 30
  max_keep: 50
  base_url: http://localhost:8080
2022/11/11 01:25:39.349 [INFO]  activate processor, feeds=0, &{Feeds:map[] System:{UpdateInterval:10m0s MaxItems:5 MaxTotal:30 MaxKeepInDB:50 Concurrent:8 BaseURL:http://localhost:8080} YouTube:{DlTemplate:yt-dlp --extract-audio --audio-format=mp3 --audio-quality=0 -f m4a/bestaudio "https://www.youtube.com/watch?v={{.ID}}" --no-progress -o {{.FileName}}.tmp BaseChanURL:https://www.youtube.com/feeds/videos.xml?channel_id= BasePlaylistURL:https://www.youtube.com/feeds/videos.xml?playlist_id= Channels:[{Name:Дилетант ID:UCuIE7-5QzeAR6EdZXwDRwuQ Type:channel Keep:5 Language:ru-ru Filter:{Include: Exclude:}}] BaseURL:http://localhost:8080/yt/media UpdateInterval:10m0s MaxItems:0 FilesLocation:var/yt RSSLocation:var/rss SkipShorts:0s}}
2022/11/11 01:25:39.349 [INFO]  starting youtube service
2022/11/11 01:25:39.349 [INFO]  youtube feed {Name:Дилетант ID:UCuIE7-5QzeAR6EdZXwDRwuQ Type:channel Keep:5 Language:ru-ru Filter:{Include: Exclude:}}
2022/11/11 01:25:39.856 [INFO]  got 15 entries for Дилетант, limit to 5
2022/11/11 01:25:39.856 [INFO]  new entry [1] QWQNPovr8zE, Гнездо Петрово и его птенцы / Дилетанты // 11.11.2022, Дилетант, {ChannelID:UCuIE7-5QzeAR6EdZXwDRwuQ, VideoID:QWQNPovr8zE, Title:"Гнездо Петрово и его птенцы / Дилетанты // 11.11.2022", Published:2022-11-10T11:20:47-06:00, Updated:2022-11-10T11:20:54-06:00, Author:Дилетант, File:, Duration:0s}

Seems the root cause is here:

https://github.com/umputun/feed-master/blob/0b7438d6e38cad9ac0a239e22d2e0ddbc57d7f89/app/config/config.go#L152-L157

As an option we can fix it like this:

for idx, f := range c.YouTube.Channels {
    if f.Keep == 0 {
        c.YouTube.Channels[idx].Keep = c.System.MaxItems
    }
}
umputun commented 1 year ago

Makes sense. Could you pls submit a PR?

rantanevich commented 1 year ago

Sure

rantanevich commented 1 year ago

PR #99 is created.