mirror of
https://git.sr.ht/~joren/streamrip-go
synced 2026-06-17 15:05:39 +02:00
feat: add log hooks
This commit is contained in:
@@ -20,6 +20,7 @@ import (
|
||||
"golang.org/x/term"
|
||||
|
||||
"streamrip-go/internal/netutil"
|
||||
"streamrip-go/internal/verbose"
|
||||
|
||||
"golang.org/x/crypto/blowfish"
|
||||
)
|
||||
@@ -67,6 +68,7 @@ func (d *Downloader) FileVideo(ctx context.Context, sourceURL, outputPath string
|
||||
}
|
||||
|
||||
func (d *Downloader) FileDeezerEncrypted(ctx context.Context, sourceURL, outputPath, trackID string) error {
|
||||
logDownloadStart(sourceURL, outputPath)
|
||||
if err := os.MkdirAll(filepath.Dir(outputPath), 0o755); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -176,6 +178,7 @@ func (d *Downloader) FileDeezerEncrypted(ctx context.Context, sourceURL, outputP
|
||||
}
|
||||
|
||||
func (d *Downloader) file(ctx context.Context, sourceURL, outputPath string, allowProgress bool, includeVideo bool) error {
|
||||
logDownloadStart(sourceURL, outputPath)
|
||||
if err := os.MkdirAll(filepath.Dir(outputPath), 0o755); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -309,6 +312,16 @@ func (d *Downloader) Logf(format string, args ...any) {
|
||||
fmt.Print(msg)
|
||||
}
|
||||
|
||||
// logDownloadStart emits the source URL and destination filename when the
|
||||
// user passed -v or higher. The transport-level logger covers the same
|
||||
// requests at -vv, but this line gives a friendlier per-track summary.
|
||||
func logDownloadStart(sourceURL, outputPath string) {
|
||||
if !verbose.Enabled(verbose.V) {
|
||||
return
|
||||
}
|
||||
verbose.Printf(verbose.V, "download %s -> %s\n", sourceURL, filepath.Base(outputPath))
|
||||
}
|
||||
|
||||
func shortenName(name string, max int) string {
|
||||
if max <= 0 {
|
||||
return name
|
||||
|
||||
Reference in New Issue
Block a user