29 lines
525 B
Go
29 lines
525 B
Go
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.
|
|
func Drop(ctx context.Context, url string) (models.Log, error) {
|
|
select {
|
|
case <-ctx.Done():
|
|
return models.Log{}, context.Cause(ctx)
|
|
default:
|
|
}
|
|
|
|
log, err := GetLog(ctx, url)
|
|
if err != nil {
|
|
return log, err
|
|
}
|
|
|
|
if err := files.Append(log); err != nil {
|
|
return log, err
|
|
}
|
|
|
|
return log, nil
|
|
}
|