Skip to content
This repository has been archived by the owner on Aug 12, 2020. It is now read-only.

Commit

Permalink
Fix example in readme
Browse files Browse the repository at this point in the history
closes #108
  • Loading branch information
corny committed Jul 4, 2020
1 parent d1ead98 commit 17393b4
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,32 @@ Go library for downloading YouTube videos
package main

import (
"fmt"
"context"
"os"

"github.com/rylio/ytdl"
"github.com/rs/zerolog/log"
)

func main() {
client := ytdl.Client{
HTTPClient: http.DefaultClient,
Logger: log.Logger,
}
vid, err := client.GetVideoInfo("https://www.youtube.com/watch?v=WkVvG4QTO9M")
ctx := context.Background()
client := ytdl.DefaultClient

videoInfo, err := client.GetVideoInfo(ctx, "https://www.youtube.com/watch?v=WkVvG4QTO9M")
if err != nil {
panic(err)
}

file, err := os.Create(videoInfo.Title + ".mp4")
if err != nil {
fmt.Println("Failed to get video info")
return
panic(err)
}
file, _ := os.Create(vid.Title + ".mp4")
defer file.Close()
client.Download(vid, vid.Formats[0], file)
}

err = client.Download(ctx, videoInfo, videoInfo.Formats[0], file)
if err != nil {
panic(err)
}
}
```

## ytdl CLI
Expand Down

0 comments on commit 17393b4

Please sign in to comment.