90 Commits

Author SHA1 Message Date
05498e920a Merge pull request #145 from allanpk716/master
add proxy settings
2023-06-13 11:04:12 +02:00
1fcacaf3f0 add proxy settings
Signed-off-by: allan716 <525223688@qq.com>
2023-06-13 14:05:58 +08:00
2ec70c51c9 Merge pull request #142 from wader/bump-golang-1.20.5
Update golang to 1.20.5 from 1.20.4
2023-06-07 18:10:20 +02:00
bc05d02e93 Update golang to 1.20.5 from 1.20.4
Release notes https://golang.org/doc/devel/release.html
2023-06-07 16:02:23 +00:00
cef23e8d43 Merge pull request #141 from wader/bump-golang-1.20.4
Update golang to 1.20.4 from 1.20.3
2023-05-03 18:49:48 +02:00
9810de5ed3 Update golang to 1.20.4 from 1.20.3
Release notes https://golang.org/doc/devel/release.html
2023-05-03 16:02:21 +00:00
e54060320d Merge pull request #140 from wader/bump-golang-1.20.3
Update golang to 1.20.3 from 1.20.2
2023-04-05 18:24:15 +02:00
4e5309b84e Update golang to 1.20.3 from 1.20.2
Release notes https://golang.org/doc/devel/release.html
2023-04-05 16:02:27 +00:00
387cad2e2c Merge pull request #138 from wader/bump-golang-1.20.2
Update golang to 1.20.2 from 1.20.1
2023-03-08 17:08:35 +01:00
f719f0f559 Update golang to 1.20.2 from 1.20.1
Release notes https://golang.org/doc/devel/release.html
2023-03-08 16:02:19 +00:00
bc6bc7763f Merge pull request #137 from wader/bump-yt-dlp-2023.03.04
Update yt-dlp to 2023.03.04 from 2023.03.03
2023-03-05 17:27:23 +01:00
b7078f00a4 Update yt-dlp to 2023.03.04 from 2023.03.03
Release notes https://github.com/yt-dlp/yt-dlp/releases/tag/2023.03.04
2023-03-05 16:02:15 +00:00
8b27a8c181 Merge pull request #136 from wader/bump-yt-dlp-2023.03.03
Update yt-dlp to 2023.03.03 from 2023.02.17
2023-03-04 17:19:49 +01:00
2afa813da5 Update yt-dlp to 2023.03.03 from 2023.02.17
Release notes https://github.com/yt-dlp/yt-dlp/releases/tag/2023.03.03
2023-03-04 16:02:08 +00:00
c615f6284d Merge pull request #135 from wader/bump-yt-dlp-2023.02.17
Update yt-dlp to 2023.02.17 from 2023.01.06
2023-02-17 17:23:17 +01:00
8e933863a0 Update yt-dlp to 2023.02.17 from 2023.01.06
Release notes https://github.com/yt-dlp/yt-dlp/releases/tag/2023.02.17
2023-02-17 16:02:11 +00:00
3143935aea Merge pull request #134 from wader/bump-golang-1.20.1
Update golang to 1.20.1 from 1.20.0
2023-02-15 19:22:34 +01:00
f6e338d60d Update golang to 1.20.1 from 1.20.0
Release notes https://golang.org/doc/devel/release.html
2023-02-15 16:02:24 +00:00
81eacb4f26 Merge pull request #133 from wader/bump-golang-1.20.0
Update golang to 1.20.0 from 1.19.5
2023-02-02 17:06:43 +01:00
05ac24b57f Update golang to 1.20.0 from 1.19.5
Release notes https://golang.org/doc/devel/release.html
2023-02-02 16:02:13 +00:00
c7dcb3bb35 Merge pull request #132 from wader/bump-golang-1.19.5
Update golang to 1.19.5 from 1.19.4
2023-01-11 17:26:52 +01:00
0611ba2d04 Update golang to 1.19.5 from 1.19.4
Release notes https://golang.org/doc/devel/release.html
2023-01-11 16:05:33 +00:00
118e1f98d4 Merge pull request #131 from wader/bump-yt-dlp-2023.01.06
Update yt-dlp to 2023.01.06 from 2023.01.02
2023-01-07 19:45:14 +01:00
6ab6b5507e Update yt-dlp to 2023.01.06 from 2023.01.02
Release notes https://github.com/yt-dlp/yt-dlp/releases/tag/2023.01.06
2023-01-07 16:02:16 +00:00
d5ae5299c2 Merge pull request #130 from wader/bump-yt-dlp-2023.01.02
Update yt-dlp to 2023.01.02 from 2022.11.11
2023-01-02 17:35:34 +01:00
7d8a5847f7 Update yt-dlp to 2023.01.02 from 2022.11.11
Release notes https://github.com/yt-dlp/yt-dlp/releases/tag/2023.01.02
2023-01-02 16:02:09 +00:00
6c90f272c9 Merge pull request #129 from wader/bump-golang-1.19.4
Update golang to 1.19.4 from 1.19.3
2022-12-07 17:13:00 +01:00
4d8def520e Update golang to 1.19.4 from 1.19.3
Release notes https://golang.org/doc/devel/release.html
2022-12-07 16:02:25 +00:00
4018d904bc Merge pull request #128 from wader/bump-yt-dlp-2022.11.11
Update yt-dlp to 2022.11.11 from 2022.10.04
2022-11-11 17:14:43 +01:00
2e8fab6410 Update yt-dlp to 2022.11.11 from 2022.10.04
Release notes https://github.com/yt-dlp/yt-dlp/releases/tag/2022.11.11
2022-11-11 16:02:20 +00:00
6cd9352064 Merge pull request #127 from wader/bump-golang-1.19.3
Update golang to 1.19.3 from 1.19.2
2022-11-02 17:05:13 +01:00
d638b45933 Update golang to 1.19.3 from 1.19.2
Release notes https://golang.org/doc/devel/release.html
2022-11-02 16:02:37 +00:00
dda183b617 Merge pull request #126 from wader/bump-golang-1.19.2
Update golang to 1.19.2 from 1.19.1
2022-10-05 21:00:38 +02:00
ac355a03ba Update golang to 1.19.2 from 1.19.1
Release notes https://golang.org/doc/devel/release.html
2022-10-05 16:09:15 +00:00
915966538a Merge pull request #125 from wader/bump-yt-dlp-2022.10.04
Update yt-dlp to 2022.10.04 from 2022.09.01
2022-10-04 18:14:18 +02:00
b5e9d3425b Update yt-dlp to 2022.10.04 from 2022.09.01
Release notes https://github.com/yt-dlp/yt-dlp/releases/tag/2022.10.04
2022-10-04 16:04:24 +00:00
fe5accc6cb Merge pull request #124 from wader/bump-golang-1.19.1
Update golang from 1.19.0 to 1.19.1
2022-09-07 18:07:43 +02:00
81bf9e4b26 Update golang from 1.19.0 to 1.19.1
Release notes https://golang.org/doc/devel/release.html
2022-09-07 16:02:19 +00:00
d010f4f9dd Merge pull request #123 from wader/bump-yt-dlp-2022.09.01
Update yt-dlp from 2022.08.19 to 2022.09.01
2022-09-01 18:26:19 +02:00
5eb425b434 Update yt-dlp from 2022.08.19 to 2022.09.01
Release notes https://github.com/yt-dlp/yt-dlp/releases/tag/2022.09.01
2022-09-01 16:02:19 +00:00
7e5df82593 Merge pull request #122 from wader/bump-yt-dlp-2022.08.19
Update yt-dlp from 2022.08.14 to 2022.08.19
2022-08-19 18:50:49 +02:00
9c60d09b15 Update yt-dlp from 2022.08.14 to 2022.08.19
Release notes https://github.com/yt-dlp/yt-dlp/releases/tag/2022.08.19
2022-08-19 16:02:26 +00:00
33a523a981 Merge pull request #121 from wader/bump-yt-dlp-2022.08.14
Update yt-dlp from 2022.08.08 to 2022.08.14
2022-08-15 18:10:59 +02:00
0b500c1d35 Update yt-dlp from 2022.08.08 to 2022.08.14
Release notes https://github.com/yt-dlp/yt-dlp/releases/tag/2022.08.14
2022-08-15 16:02:21 +00:00
e15c64dce7 Merge pull request #120 from wader/bump-yt-dlp-2022.08.08
Update yt-dlp from 2022.07.18 to 2022.08.08
2022-08-09 18:12:28 +02:00
f779a73b4f Update yt-dlp from 2022.07.18 to 2022.08.08
Release notes https://github.com/yt-dlp/yt-dlp/releases/tag/2022.08.08
2022-08-09 16:02:17 +00:00
b4e0035d5c Merge pull request #119 from wader/bump-golang-1.19.0
Update golang from 1.18.5 to 1.19.0
2022-08-03 18:04:25 +02:00
2102824caf Update golang from 1.18.5 to 1.19.0
Release notes https://golang.org/doc/devel/release.html
2022-08-03 16:02:30 +00:00
6881f9bc43 Merge pull request #118 from wader/bump-golang-1.18.5
Update golang from 1.18.4 to 1.18.5
2022-08-02 18:06:45 +02:00
adb78c4c98 Update golang from 1.18.4 to 1.18.5
Release notes https://golang.org/doc/devel/release.html
2022-08-02 16:02:20 +00:00
0646c79a57 Make cli tool use yt-dlp and cleanup a bit 2022-07-30 11:39:18 +02:00
2caa37324b Fix failing TestTestUnsupportedURL test 2022-07-30 11:38:52 +02:00
70296032d9 Merge pull request #116 from wader/bump-yt-dlp-2022.07.18
Update yt-dlp from 2022.06.29 to 2022.07.18
2022-07-18 18:21:55 +02:00
463adcbb9b Update yt-dlp from 2022.06.29 to 2022.07.18
Release notes https://github.com/yt-dlp/yt-dlp/releases/tag/2022.07.18
2022-07-18 16:02:35 +00:00
e7cb257a02 Merge pull request #115 from wader/bump-golang-1.18.4
Update golang from 1.18.3 to 1.18.4
2022-07-13 18:08:15 +02:00
9e988d6921 Update golang from 1.18.3 to 1.18.4
Release notes https://golang.org/doc/devel/release.html
2022-07-13 16:02:41 +00:00
a29fe0a651 Merge pull request #114 from wader/bump-yt-dlp-2022.06.29
Update yt-dlp from 2022.06.22.1 to 2022.06.29
2022-06-29 18:20:42 +02:00
c41a0e6a19 Update yt-dlp from 2022.06.22.1 to 2022.06.29
Release notes https://github.com/yt-dlp/yt-dlp/releases/tag/2022.06.29
2022-06-29 16:12:37 +00:00
be05c3470e Merge pull request #113 from wader/bump-yt-dlp-2022.06.22.1
Update yt-dlp from 2022.05.18 to 2022.06.22.1
2022-06-22 18:15:29 +02:00
d4d34caf21 Update yt-dlp from 2022.05.18 to 2022.06.22.1
Release notes https://github.com/yt-dlp/yt-dlp/releases/tag/2022.06.22.1
2022-06-22 16:02:18 +00:00
9ca9c8233d Merge pull request #112 from wader/bump-golang-1.18.3
Update golang from 1.18.2 to 1.18.3
2022-06-02 18:50:38 +02:00
e1eb260ddc Update golang from 1.18.2 to 1.18.3
Release notes https://golang.org/doc/devel/release.html
2022-06-02 16:02:11 +00:00
62d33f8235 Merge pull request #111 from wader/bump-yt-dlp-2022.05.18
Update yt-dlp from 2022.04.08 to 2022.05.18
2022-05-18 19:03:35 +02:00
8fcad9535c Update yt-dlp from 2022.04.08 to 2022.05.18
Release notes https://github.com/yt-dlp/yt-dlp/releases/tag/2022.05.18
2022-05-18 16:02:27 +00:00
1c8c4dc203 Merge pull request #110 from wader/bump-golang-1.18.2
Update golang from 1.18.1 to 1.18.2
2022-05-11 18:20:45 +02:00
bfb0ef399c Update golang from 1.18.1 to 1.18.2
Release notes https://golang.org/doc/devel/release.html
2022-05-11 16:08:22 +00:00
1e9e17813e Merge pull request #109 from wader/bump-golang-1.18.1
Update golang from 1.18.0 to 1.18.1
2022-04-13 18:17:31 +02:00
45cb5c7588 Update golang from 1.18.0 to 1.18.1
Release notes https://golang.org/doc/devel/release.html
2022-04-13 16:06:37 +00:00
f40c477662 Merge pull request #108 from wader/bump-yt-dlp-2022.04.08
Update yt-dlp from 2022.03.08.1 to 2022.04.08
2022-04-08 18:52:48 +02:00
cf5e4ca48f Update yt-dlp from 2022.03.08.1 to 2022.04.08
Release notes https://github.com/yt-dlp/yt-dlp/releases/tag/2022.04.08
2022-04-08 16:07:29 +00:00
e33f41edf6 Merge pull request #107 from wader/bump-golang-1.18.0
Update golang from 1.17.8 to 1.18.0
2022-03-16 17:05:13 +01:00
190b16c29e Update golang from 1.17.8 to 1.18.0
Release notes https://golang.org/doc/devel/release.html
2022-03-16 16:02:22 +00:00
d6ebdf9ab3 Merge pull request #106 from wader/bump-yt-dlp-2022.03.08.1
Update yt-dlp from 2022.02.04 to 2022.03.08.1
2022-03-09 18:06:23 +01:00
f10fee0dba Update yt-dlp from 2022.02.04 to 2022.03.08.1
Release notes https://github.com/yt-dlp/yt-dlp/releases/tag/2022.03.08.1
2022-03-09 16:02:39 +00:00
7bb201993e Merge pull request #105 from wader/bump-golang-1.17.8
Update golang from 1.17.7 to 1.17.8
2022-03-04 17:38:07 +01:00
d78cf8dc83 Update golang from 1.17.7 to 1.17.8
Release notes https://golang.org/doc/devel/release.html
2022-03-04 16:06:37 +00:00
34ddeef62d Merge pull request #104 from wader/bump-golang-1.17.7
Update golang from 1.17.6 to 1.17.7
2022-02-11 18:32:51 +01:00
a59346f789 Update golang from 1.17.6 to 1.17.7
Release notes https://golang.org/doc/devel/release.html
2022-02-11 16:15:35 +00:00
3d9c1cacc7 Merge pull request #103 from wader/bump-yt-dlp-2022.02.04
Update yt-dlp from 2022.01.21 to 2022.02.04
2022-02-04 18:26:34 +01:00
48f5809cc8 Update yt-dlp from 2022.01.21 to 2022.02.04
Release notes https://github.com/yt-dlp/yt-dlp/releases/tag/2022.02.04
2022-02-04 16:14:05 +00:00
15d137b9f5 Merge pull request #102 from wader/bump-yt-dlp-2022.01.21
Update yt-dlp from 2021.12.27 to 2022.01.21
2022-01-21 17:19:11 +01:00
419f83a417 Update yt-dlp from 2021.12.27 to 2022.01.21
Release notes https://github.com/yt-dlp/yt-dlp/releases/tag/2022.01.21
2022-01-21 16:13:20 +00:00
a001f00d72 Merge pull request #101 from wader/bump-golang-1.17.6
Update golang from 1.17.5 to 1.17.6
2022-01-07 18:00:42 +01:00
9747d99d9e Update golang from 1.17.5 to 1.17.6
Release notes https://golang.org/doc/devel/release.html
2022-01-07 16:13:32 +00:00
56fa5b44b1 Merge pull request #100 from wader/bump-yt-dlp-2021.12.27
Update yt-dlp from 2021.12.25 to 2021.12.27
2021-12-27 17:18:20 +01:00
c2502b86b9 Update yt-dlp from 2021.12.25 to 2021.12.27
Release notes https://github.com/yt-dlp/yt-dlp/releases/tag/2021.12.27
2021-12-27 16:13:11 +00:00
c80caccf89 Merge pull request #99 from wader/bump-yt-dlp-2021.12.25
Update yt-dlp from 2021.12.01 to 2021.12.25
2021-12-25 17:19:44 +01:00
fccbf4869a Update yt-dlp from 2021.12.01 to 2021.12.25
Release notes https://github.com/yt-dlp/yt-dlp/releases/tag/2021.12.25
2021-12-25 16:12:27 +00:00
039073da1a Switch to yt-dlp for now 2021-12-21 16:50:15 +01:00
bfcb4c9c54 Use _test package to force use of public API 2021-12-21 16:49:52 +01:00
5 changed files with 63 additions and 36 deletions

View File

@ -1,18 +1,18 @@
# bump: golang /GOLANG_VERSION=([\d.]+)/ docker:golang|^1
# bump: golang link "Release notes" https://golang.org/doc/devel/release.html
ARG GOLANG_VERSION=1.17.5
# bump: youtube-dl /YDL_VERSION=([\d.]+)/ https://github.com/ytdl-org/youtube-dl.git|/^\d/|sort
# bump: youtube-dl link "Release notes" https://github.com/ytdl-org/youtube-dl/releases/tag/$LATEST
ARG YDL_VERSION=2021.06.06
ARG GOLANG_VERSION=1.20.5
# bump: yt-dlp /YT_DLP=([\d.-]+)/ https://github.com/yt-dlp/yt-dlp.git|/^\d/|sort
# bump: yt-dlp link "Release notes" https://github.com/yt-dlp/yt-dlp/releases/tag/$LATEST
ARG YT_DLP=2023.03.04
FROM golang:$GOLANG_VERSION AS base
ARG YDL_VERSION
ARG YT_DLP
RUN \
apt-get update -q && \
apt-get install -y -q python-is-python3 && \
curl -L -o /usr/local/bin/youtube-dl https://yt-dl.org/downloads/$YDL_VERSION/youtube-dl && \
chmod a+x /usr/local/bin/youtube-dl
curl -L https://github.com/yt-dlp/yt-dlp/releases/download/$YT_DLP/yt-dlp -o /usr/local/bin/yt-dlp && \
chmod a+x /usr/local/bin/yt-dlp
FROM base AS dev

View File

@ -1,12 +1,15 @@
## goutubedl
Go wrapper for [youtube-dl](https://github.com/ytdl-org/youtube-dl). API documentation can be found at [godoc.org](https://pkg.go.dev/github.com/wader/goutubedl?tab=doc).
Go wrapper for [youtube-dl](https://github.com/ytdl-org/youtube-dl) and [yt-dlp](https://github.com/yt-dlp/yt-dlp), currently tested and
developed using yt-dlp.
API documentation can be found at [godoc.org](https://pkg.go.dev/github.com/wader/goutubedl?tab=doc).
See [youtube-dl documentation](https://github.com/ytdl-org/youtube-dl) for how to
See [yt-dlp documentation](https://github.com/yt-dlp/yt-dlp) for how to
install and what is recommended to install in addition to youtube-dl.
goutubedl default uses `PATH` to find youtube-dl but it can be configured with the `goutubedl.Path`
variable.
variable. Default is currently `youtube-dl` for backwards compability. If your using yt-dlp you
probably want to set it to `yt-dlp`.
Due to the nature and frequent updates of youtube-dl only the latest version
is tested. But it seems to work well with older versions also.

View File

@ -15,11 +15,17 @@ var dumpFlag = flag.Bool("J", false, "Dump JSON")
var typeFlag = flag.String("t", "any", "Type")
func main() {
goutubedl.Path = "yt-dlp"
log.SetFlags(0)
flag.Parse()
optType, _ := goutubedl.TypeFromString[*typeFlag]
result, err := goutubedl.New(context.Background(), flag.Arg(0), goutubedl.Options{Type: optType})
optType := goutubedl.TypeFromString[*typeFlag]
result, err := goutubedl.New(
context.Background(),
flag.Arg(0),
goutubedl.Options{Type: optType, DebugLog: log.Default()},
)
if err != nil {
log.Fatal(err)
}
@ -44,6 +50,8 @@ func main() {
log.Fatal(err)
}
defer f.Close()
io.Copy(f, dr)
if _, err := io.Copy(f, dr); err != nil {
log.Fatal(err)
}
dr.Close()
}

View File

@ -206,6 +206,7 @@ type Options struct {
PlaylistEnd uint // --playlist-end
DownloadThumbnail bool
DownloadSubtitles bool
ProxyUrl string // --proxy URL http://host:port or socks5://host:port
DebugLog Printer
StderrFn func(cmd *exec.Cmd) io.Writer // if not nil, function to get Writer for stderr
HTTPClient *http.Client // Client for download thumbnail and subtitles (nil use http.DefaultClient)
@ -258,6 +259,11 @@ func infoFromURL(ctx context.Context, rawURL string, options Options) (info Info
"--batch-file", "-",
"-J",
)
if options.ProxyUrl != "" {
cmd.Args = append(cmd.Args, "--proxy", options.ProxyUrl)
}
if options.Type == TypePlaylist {
cmd.Args = append(cmd.Args, "--yes-playlist")
@ -455,6 +461,10 @@ func (result Result) Download(ctx context.Context, filter string) (*DownloadResu
cmd.Args = append(cmd.Args, "-f", filter)
}
if result.Options.ProxyUrl != "" {
cmd.Args = append(cmd.Args, "--proxy", result.Options.ProxyUrl)
}
cmd.Dir = tempPath
var w io.WriteCloser
dr.reader, w = io.Pipe()

View File

@ -1,4 +1,4 @@
package goutubedl
package goutubedl_test
// TODO: currently the tests only run on linux as they use osleaktest which only
// has linux support
@ -14,9 +14,15 @@ import (
"testing"
"github.com/fortytw2/leaktest"
"github.com/wader/goutubedl"
"github.com/wader/osleaktest"
)
func init() {
// we're using yt-dlp at the moment
goutubedl.Path = "yt-dlp"
}
const testVideoRawURL = "https://www.youtube.com/watch?v=C0DPdy98e4c"
const playlistRawURL = "https://soundcloud.com/mattheis/sets/kindred-phenomena"
const subtitlesTestVideoRawURL = "https://www.youtube.com/watch?v=QRS8MkLhQmM"
@ -33,10 +39,10 @@ func leakChecks(t *testing.T) func() {
func TestBinaryNotPath(t *testing.T) {
defer leakChecks(t)()
defer func(orig string) { Path = orig }(Path)
Path = "/non-existing"
defer func(orig string) { goutubedl.Path = orig }(goutubedl.Path)
goutubedl.Path = "/non-existing"
_, versionErr := Version(context.Background())
_, versionErr := goutubedl.Version(context.Background())
if versionErr == nil || !strings.Contains(versionErr.Error(), "no such file or directory") {
t.Fatalf("err should be nil 'no such file or directory': %v", versionErr)
}
@ -46,7 +52,7 @@ func TestVersion(t *testing.T) {
defer leakChecks(t)()
versionRe := regexp.MustCompile(`^\d{4}\.\d{2}.\d{2}.*$`)
version, versionErr := Version(context.Background())
version, versionErr := goutubedl.Version(context.Background())
if versionErr != nil {
t.Fatalf("err: %s", versionErr)
@ -61,7 +67,7 @@ func TestDownload(t *testing.T) {
defer leakChecks(t)()
stderrBuf := &bytes.Buffer{}
r, err := New(context.Background(), testVideoRawURL, Options{
r, err := goutubedl.New(context.Background(), testVideoRawURL, goutubedl.Options{
StderrFn: func(cmd *exec.Cmd) io.Writer {
return stderrBuf
},
@ -84,8 +90,8 @@ func TestDownload(t *testing.T) {
t.Errorf("copy n not equal to download buffer: %d!=%d", n, downloadBuf.Len())
}
if n < 29000 {
t.Errorf("should have copied at least 29000 bytes: %d", n)
if n < 10000 {
t.Errorf("should have copied at least 10000 bytes: %d", n)
}
if !strings.Contains(stderrBuf.String(), "Destination") {
@ -106,7 +112,7 @@ func TestParseInfo(t *testing.T) {
defer leakChecks(t)()
ctx, cancelFn := context.WithCancel(context.Background())
ydlResult, err := New(ctx, c.url, Options{
ydlResult, err := goutubedl.New(ctx, c.url, goutubedl.Options{
DownloadThumbnail: true,
})
if err != nil {
@ -156,8 +162,8 @@ func TestParseInfo(t *testing.T) {
func TestPlaylist(t *testing.T) {
defer leakChecks(t)()
ydlResult, ydlResultErr := New(context.Background(), playlistRawURL, Options{
Type: TypePlaylist,
ydlResult, ydlResultErr := goutubedl.New(context.Background(), playlistRawURL, goutubedl.Options{
Type: goutubedl.TypePlaylist,
DownloadThumbnail: false,
})
@ -184,11 +190,11 @@ func TestPlaylist(t *testing.T) {
func TestTestUnsupportedURL(t *testing.T) {
defer leaktest.Check(t)()
_, ydlResultErr := New(context.Background(), "https://www.google.com", Options{})
_, ydlResultErr := goutubedl.New(context.Background(), "https://www.google.com", goutubedl.Options{})
if ydlResultErr == nil {
t.Errorf("expected unsupported url")
}
expectedErrPrefix := "Unsupported URL: https://www.google.com"
expectedErrPrefix := "Unsupported URL:"
if ydlResultErr != nil && !strings.HasPrefix(ydlResultErr.Error(), expectedErrPrefix) {
t.Errorf("expected error prefix %q got %q", expectedErrPrefix, ydlResultErr.Error())
@ -199,8 +205,8 @@ func TestPlaylistWithPrivateVideo(t *testing.T) {
defer leaktest.Check(t)()
playlistRawURL := "https://www.youtube.com/playlist?list=PLX0g748fkegS54oiDN4AXKl7BR7mLIydP"
ydlResult, ydlResultErr := New(context.Background(), playlistRawURL, Options{
Type: TypePlaylist,
ydlResult, ydlResultErr := goutubedl.New(context.Background(), playlistRawURL, goutubedl.Options{
Type: goutubedl.TypePlaylist,
DownloadThumbnail: false,
})
@ -218,10 +224,10 @@ func TestPlaylistWithPrivateVideo(t *testing.T) {
func TestSubtitles(t *testing.T) {
defer leakChecks(t)()
ydlResult, ydlResultErr := New(
ydlResult, ydlResultErr := goutubedl.New(
context.Background(),
subtitlesTestVideoRawURL,
Options{
goutubedl.Options{
DownloadSubtitles: true,
})
@ -250,11 +256,11 @@ func TestSubtitles(t *testing.T) {
func TestErrorNotAPlaylist(t *testing.T) {
defer leakChecks(t)()
_, ydlResultErr := New(context.Background(), testVideoRawURL, Options{
Type: TypePlaylist,
_, ydlResultErr := goutubedl.New(context.Background(), testVideoRawURL, goutubedl.Options{
Type: goutubedl.TypePlaylist,
DownloadThumbnail: false,
})
if ydlResultErr != ErrNotAPlaylist {
if ydlResultErr != goutubedl.ErrNotAPlaylist {
t.Errorf("expected is playlist error, got %s", ydlResultErr)
}
}
@ -262,11 +268,11 @@ func TestErrorNotAPlaylist(t *testing.T) {
func TestErrorNotASingleEntry(t *testing.T) {
defer leakChecks(t)()
_, ydlResultErr := New(context.Background(), playlistRawURL, Options{
Type: TypeSingle,
_, ydlResultErr := goutubedl.New(context.Background(), playlistRawURL, goutubedl.Options{
Type: goutubedl.TypeSingle,
DownloadThumbnail: false,
})
if ydlResultErr != ErrNotASingleEntry {
if ydlResultErr != goutubedl.ErrNotASingleEntry {
t.Errorf("expected is single entry error, got %s", ydlResultErr)
}
}