2026-02-28 22:11:18 -06:00
|
|
|
package ytdlp
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
|
|
|
|
|
"codeberg.org/danjones000/my-log/files"
|
|
|
|
|
"codeberg.org/danjones000/my-log/models"
|
|
|
|
|
ytd "github.com/lrstanley/go-ytdlp"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Drop adds the URL specified by the url to the watched log.
|
2026-02-28 23:36:08 -06:00
|
|
|
func Drop(ctx context.Context, url string) (models.Log, error) {
|
2026-03-01 00:02:39 -06:00
|
|
|
select {
|
|
|
|
|
case <-ctx.Done():
|
|
|
|
|
return models.Log{}, context.Cause(ctx)
|
|
|
|
|
default:
|
2026-02-28 22:11:18 -06:00
|
|
|
}
|
|
|
|
|
|
2026-03-01 00:02:39 -06:00
|
|
|
log, err := GetLog(ctx, url)
|
2026-02-28 22:11:18 -06:00
|
|
|
if err != nil {
|
2026-02-28 23:36:08 -06:00
|
|
|
return log, err
|
2026-02-28 22:11:18 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if err := files.Append(log); err != nil {
|
2026-02-28 23:36:08 -06:00
|
|
|
return log, err
|
2026-02-28 22:11:18 -06:00
|
|
|
}
|
|
|
|
|
|
2026-02-28 23:36:08 -06:00
|
|
|
return log, nil
|
2026-02-28 22:11:18 -06:00
|
|
|
}
|