fixed yt-dlp duplicated playlist entries
This commit is contained in:
@@ -56,7 +56,7 @@ func (m *MessageQueue) downloadConsumer() {
|
|||||||
|
|
||||||
m.eventBus.SubscribeAsync(queueName, func(p *Process) {
|
m.eventBus.SubscribeAsync(queueName, func(p *Process) {
|
||||||
//TODO: provide valid context
|
//TODO: provide valid context
|
||||||
sem.Acquire(context.TODO(), 1)
|
sem.Acquire(context.Background(), 1)
|
||||||
defer sem.Release(1)
|
defer sem.Release(1)
|
||||||
|
|
||||||
m.logger.Info("received process from event bus",
|
m.logger.Info("received process from event bus",
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -41,21 +42,24 @@ func PlaylistDetect(req DownloadRequest, mq *MessageQueue, db *MemoryDB, logger
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Info("decoded metadata", slog.String("url", req.URL))
|
if err := cmd.Wait(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Info("decoded playlist metadata", slog.String("url", req.URL))
|
||||||
|
|
||||||
if m.Type == "" {
|
if m.Type == "" {
|
||||||
cmd.Wait()
|
|
||||||
return errors.New("probably not a valid URL")
|
return errors.New("probably not a valid URL")
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.Type == "playlist" {
|
if m.Type == "playlist" {
|
||||||
logger.Info(
|
entries := slices.CompactFunc(slices.Compact(m.Entries), func(a DownloadInfo, b DownloadInfo) bool {
|
||||||
"playlist detected",
|
return a.URL == b.URL
|
||||||
slog.String("url", req.URL),
|
})
|
||||||
slog.Int("count", m.Count),
|
|
||||||
)
|
|
||||||
|
|
||||||
for _, meta := range m.Entries {
|
logger.Info("playlist detected", slog.String("url", req.URL), slog.Int("count", len(entries)))
|
||||||
|
|
||||||
|
for _, meta := range entries {
|
||||||
// detect playlist title from metadata since each playlist entry will be
|
// detect playlist title from metadata since each playlist entry will be
|
||||||
// treated as an individual download
|
// treated as an individual download
|
||||||
req.Rename = strings.Replace(
|
req.Rename = strings.Replace(
|
||||||
@@ -81,9 +85,6 @@ func PlaylistDetect(req DownloadRequest, mq *MessageQueue, db *MemoryDB, logger
|
|||||||
db.Set(proc)
|
db.Set(proc)
|
||||||
mq.Publish(proc)
|
mq.Publish(proc)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = cmd.Wait()
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
proc := &Process{
|
proc := &Process{
|
||||||
|
|||||||
Reference in New Issue
Block a user