/* Copyright © 2026 Dan Jones This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ package cli import ( "fmt" "my-log-wynter/ytdlp" mycli "codeberg.org/danjones000/my-log/cli" "codeberg.org/danjones000/my-log/config" "codeberg.org/danjones000/my-log/formatters" "github.com/spf13/cobra" ) // YtDropCmd represents the drop command var YtDropCmd = &cobra.Command{ Use: "drop:yt url", Short: "Add a new YouTube video to the watched log", // Long: ``, Args: cobra.ExactArgs(1), SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { if outJson { config.Overrides["output.stdout.config.format"] = "json" } url := args[0] log, err := ytdlp.Drop(cmd.Context(), url, d.Time()) if err != nil { return err } form, err := formatters.Preferred() if err != nil { return err } out, err := form.Log(log) if err != nil { return err } if len(out) > 0 && out[len(out)-1] != 10 { out = append(out, 10) } fmt.Fprintf(cmd.OutOrStdout(), "%s", out) return nil }, } func init() { (&d).Set("now") mycli.RootCmd.AddCommand(YtDropCmd) YtDropCmd.Flags().VarP(&d, "date", "d", "Date for log entry") YtDropCmd.Flags().BoolVarP(&outJson, "output_json", "o", false, "Output result as JSON") }