Skip to content

Commit

Permalink
Add better logging when fetching video
Browse files Browse the repository at this point in the history
  • Loading branch information
xoltia committed Jan 4, 2024
1 parent 835ceda commit f3dc838
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions internal/activities/video_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,24 @@ func GetVideoInfo(ctx context.Context, url *nurl.URL, forceYtdlp bool) (v *Video
url.Host == "www.youtube.com" ||
url.Host == "m.youtube.com"

logger, ok := ctx.Value("logger").(*slog.Logger)

if !ok {
logger = slog.Default()
}

logger.Debug(
"Getting video info",
slog.String("url", url.String()),
slog.Bool("is_youtube_link", isYoutubeLink),
slog.Bool("force_ytdlp", forceYtdlp),
slog.String("host", url.Host),
)

if !forceYtdlp && isYoutubeLink {
v, err = getInfoFromYoutube(ctx, url)

if err != nil {
logger, ok := ctx.Value("logger").(*slog.Logger)

if !ok {
logger = slog.Default()
}

logger.Warn(
"Failed to get video info from youtube, falling back to yt-dlp",
slog.String("url", url.String()),
Expand Down

0 comments on commit f3dc838

Please sign in to comment.