Add date/time flag to command and update functions

This commit is contained in:
Dan Jones 2026-03-01 08:52:59 -06:00
commit 21d27f8068
5 changed files with 13 additions and 10 deletions

View file

@ -2,21 +2,21 @@ package ytdlp
import (
"context"
"time"
"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) {
func Drop(ctx context.Context, url string, now time.Time) (models.Log, error) {
select {
case <-ctx.Done():
return models.Log{}, context.Cause(ctx)
default:
}
log, err := GetLog(ctx, url)
log, err := GetLog(ctx, url, now)
if err != nil {
return log, err
}

View file

@ -30,7 +30,7 @@ func Fetch(ctx context.Context, url string) (*ytd.ExtractedInfo, error) {
return infos[0], nil
}
func GetLog(ctx context.Context, url string) (models.Log, error) {
func GetLog(ctx context.Context, url string, now time.Time) (models.Log, error) {
select {
case <-ctx.Done():
return models.Log{}, context.Cause(ctx)
@ -42,8 +42,8 @@ func GetLog(ctx context.Context, url string) (models.Log, error) {
if err != nil {
return models.Log{}, err
}
now := time.Now()
ent.Date = now
// TODO Get published date
metas := &ent.Fields
*metas = metas.Set("id", getID(now, info))