51 lines
801 B
Go
51 lines
801 B
Go
package controller
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/lrstanley/go-ytdlp"
|
|
)
|
|
|
|
type SourceUpdater struct {
|
|
sources []VirtDirSource
|
|
}
|
|
|
|
type SourcedDirSource string
|
|
|
|
const (
|
|
SourcedDirYtDlp SourcedDirSource = "yt-dlp-playlist"
|
|
)
|
|
|
|
type VirtDirSource interface {
|
|
Source() SourcedDirSource
|
|
}
|
|
|
|
var _ VirtDirSource = (*SourcedDirYtDlpPlaylist)(nil)
|
|
|
|
type SourcedDirYtDlpPlaylist struct {
|
|
URL string `json:"url"`
|
|
}
|
|
|
|
func (SourcedDirYtDlpPlaylist) Source() SourcedDirSource {
|
|
return SourcedDirYtDlp
|
|
}
|
|
|
|
type SDController struct {
|
|
sources []VirtDirSource
|
|
}
|
|
|
|
func (sd *SourcedDirYtDlpPlaylist) Update(ctx context.Context) error {
|
|
_, err := ytdlp.Install(ctx, nil)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
dl := ytdlp.New().PrintJSON()
|
|
|
|
_, err = dl.Run(ctx, sd.URL)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|