50 Commits

Author SHA1 Message Date
cb39bec3a6 do not filter out m3u8
Some checks failed
Build on push and PRs / build (push) Failing after 5s
Automatic version updates / version_update (push) Failing after 7s
2025-02-09 17:53:12 +03:00
1815e33339 m3u8_native
Some checks failed
Build on push and PRs / build (push) Failing after 5s
Automatic version updates / version_update (push) Failing after 6s
2025-02-07 16:31:17 +03:00
646859b4c1 add foramt chose for subtitlse
Some checks failed
Build on push and PRs / build (push) Failing after 5s
Automatic version updates / version_update (push) Failing after 7s
2025-02-03 20:52:03 +03:00
55e7486f50 add foramt chose for subtitlse
Some checks failed
Build on push and PRs / build (push) Failing after 4s
2025-02-03 20:45:42 +03:00
506804ebb3 captions err
Some checks failed
Build on push and PRs / build (push) Failing after 4s
2025-02-03 20:18:53 +03:00
cafbe3c1a9 captions err
Some checks failed
Build on push and PRs / build (push) Failing after 4s
2025-02-03 20:15:24 +03:00
63a707e70a add err
Some checks failed
Build on push and PRs / build (push) Failing after 4s
2025-02-03 20:14:44 +03:00
c84fe2feb6 add caption
Some checks failed
Build on push and PRs / build (push) Failing after 6s
2025-02-03 19:58:09 +03:00
24cc3575e4 info args
Some checks failed
Build on push and PRs / build (push) Failing after 5s
Automatic version updates / version_update (push) Failing after 6s
2025-01-22 22:51:12 +03:00
1a1941ca29 rename fork
Some checks failed
Build on push and PRs / build (push) Failing after 5s
Automatic version updates / version_update (push) Failing after 7s
2025-01-14 22:09:14 +03:00
faa303a45c rename fork
Some checks failed
Build on push and PRs / build (push) Failing after 4s
2025-01-14 21:08:33 +03:00
b534e45a9c add extractor args
Some checks failed
Build on push and PRs / build (push) Failing after 14s
2025-01-14 21:06:06 +03:00
e8e101773e Merge pull request #221 from wader/bump-yt-dlp-2025.01.12
Update yt-dlp to 2025.01.12 from 2024.12.23
2025-01-13 18:02:23 +01:00
2ce13a3453 Update yt-dlp to 2025.01.12 from 2024.12.23
Release notes https://github.com/yt-dlp/yt-dlp/releases/tag/2025.01.12
2025-01-13 16:02:24 +00:00
33e26ae818 Merge pull request #219 from wader/bump-yt-dlp-2024.12.23
Update yt-dlp to 2024.12.23 from 2024.12.13
2024-12-24 17:04:41 +01:00
940ca8b439 Update yt-dlp to 2024.12.23 from 2024.12.13
Release notes https://github.com/yt-dlp/yt-dlp/releases/tag/2024.12.23
2024-12-24 16:02:12 +00:00
8ebc956d58 Merge pull request #218 from wader/bump-yt-dlp-2024.12.13
Update yt-dlp to 2024.12.13 from 2024.12.06
2024-12-13 17:35:00 +01:00
fe2e84d624 Update yt-dlp to 2024.12.13 from 2024.12.06
Release notes https://github.com/yt-dlp/yt-dlp/releases/tag/2024.12.13
2024-12-13 16:02:29 +00:00
4749af12f9 Merge pull request #217 from wader/bump-yt-dlp-2024.12.06
Update yt-dlp to 2024.12.06 from 2024.12.03
2024-12-11 13:28:18 +01:00
b80c451351 Update yt-dlp to 2024.12.06 from 2024.12.03
Release notes https://github.com/yt-dlp/yt-dlp/releases/tag/2024.12.06
2024-12-07 16:02:15 +00:00
63dcb4b7f5 Merge pull request #214 from wader/bump-golang-1.23.4
Update golang to 1.23.4 from 1.23.3
2024-12-04 17:57:58 +01:00
56b36e04e0 Merge pull request #215 from wader/bump-yt-dlp-2024.12.03
Update yt-dlp to 2024.12.03 from 2024.11.18
2024-12-04 17:57:52 +01:00
2623ce39cc Update yt-dlp to 2024.12.03 from 2024.11.18
Release notes https://github.com/yt-dlp/yt-dlp/releases/tag/2024.12.03
2024-12-04 16:02:38 +00:00
a8a0daa240 Update golang to 1.23.4 from 1.23.3
Release notes https://golang.org/doc/devel/release.html
2024-12-04 16:02:36 +00:00
5e1bb9940f Merge pull request #213 from wader/bump-yt-dlp-2024.11.18
Update yt-dlp to 2024.11.18 from 2024.11.04
2024-11-18 17:08:03 +01:00
736ec471fb Update yt-dlp to 2024.11.18 from 2024.11.04
Release notes https://github.com/yt-dlp/yt-dlp/releases/tag/2024.11.18
2024-11-18 16:02:24 +00:00
f902ca5cee Merge pull request #212 from wader/bump-golang-1.23.3
Update golang to 1.23.3 from 1.23.2
2024-11-07 17:49:26 +01:00
ce1d7dd3a4 Update golang to 1.23.3 from 1.23.2
Release notes https://golang.org/doc/devel/release.html
2024-11-07 16:02:18 +00:00
d51f319f36 Merge pull request #211 from wader/bump-yt-dlp-2024.11.04
Update yt-dlp to 2024.11.04 from 2024.10.22
2024-11-04 17:50:05 +01:00
f16338a0be Update yt-dlp to 2024.11.04 from 2024.10.22
Release notes https://github.com/yt-dlp/yt-dlp/releases/tag/2024.11.04
2024-11-04 16:02:45 +00:00
bb47becd77 Merge pull request #210 from wader/bump-yt-dlp-2024.10.22
Update yt-dlp to 2024.10.22 from 2024.10.07
2024-10-22 19:06:23 +02:00
137b17daf1 Update yt-dlp to 2024.10.22 from 2024.10.07
Release notes https://github.com/yt-dlp/yt-dlp/releases/tag/2024.10.22
2024-10-22 16:02:37 +00:00
1b8fc57051 Merge pull request #209 from wader/bump-yt-dlp-2024.10.07
Update yt-dlp to 2024.10.07 from 2024.09.27
2024-10-08 20:49:52 +02:00
7f2cc0f2b4 Update yt-dlp to 2024.10.07 from 2024.09.27
Release notes https://github.com/yt-dlp/yt-dlp/releases/tag/2024.10.07
2024-10-08 16:02:15 +00:00
eb679c5ee1 Merge pull request #206 from wader/bump-yt-dlp-2024.09.27
Update yt-dlp to 2024.09.27 from 2024.08.06
2024-10-07 23:05:50 +02:00
c71ec4178b Update yt-dlp to 2024.09.27 from 2024.08.06
Release notes https://github.com/yt-dlp/yt-dlp/releases/tag/2024.09.27
2024-10-07 22:58:10 +02:00
24655e2ef8 Merge pull request #207 from wader/bump-golang-1.23.2
Update golang to 1.23.2 from 1.22.6
2024-10-07 22:56:42 +02:00
74ed4258b3 Update golang to 1.23.2 from 1.22.6
Release notes https://golang.org/doc/devel/release.html
2024-10-07 22:53:53 +02:00
3d96f632e1 Merge pull request #208 from wader/repair-most-tests
Make most tests work again
2024-10-07 22:53:18 +02:00
eb9555dbed Make most tests work again 2024-10-07 22:43:05 +02:00
fed2a6ab45 Merge pull request #204 from NexonSU/master
impersonate support
2024-09-10 10:11:16 +02:00
945bbd6026 result.Options.Impersonate removal 2024-09-09 11:05:09 +03:00
d104f30286 impersonate arg 2024-09-08 22:29:37 +03:00
a623bde37b Merge pull request #195 from gamersindo1223/master
Added Download Audio Only
2024-08-18 12:19:19 +02:00
90467bcf8a Merge pull request #202 from ar2rworld/AddCookiesOption
Adding Cookies to Options
2024-08-17 19:07:30 +02:00
d47fecba92 Adding Cookies to Options 2024-08-16 22:55:25 -07:00
65804d5c0f Moved to DownloadOptions 2024-08-12 12:02:26 +00:00
95037e2caf Merge branch 'wader:master' into master 2024-08-12 18:36:45 +07:00
346cfb47a0 Update goutubedl.go 2024-08-12 18:15:44 +07:00
3abe5ae66a Added Download Audio Only 2024-07-11 16:13:41 +00:00
7 changed files with 105 additions and 21 deletions

View File

@ -1,9 +1,9 @@
# bump: golang /GOLANG_VERSION=([\d.]+)/ docker:golang|^1
# bump: golang link "Release notes" https://golang.org/doc/devel/release.html
ARG GOLANG_VERSION=1.22.6
ARG GOLANG_VERSION=1.23.4
# 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=2024.08.06
ARG YT_DLP=2025.01.12
FROM golang:$GOLANG_VERSION AS base
ARG YT_DLP

View File

@ -4,7 +4,7 @@ Go wrapper for
[youtube-dl](https://github.com/ytdl-org/youtube-dl) and
[yt-dlp](https://github.com/yt-dlp/yt-dlp).
Currently only tested and developed using yt-dlp.
API documentation can be found at [godoc.org](https://pkg.go.dev/github.com/wader/goutubedl?tab=doc).
API documentation can be found at [godoc.org](https://pkg.go.dev/gitea.kaz62.ru/dilap54/goutubedl?tab=doc).
See [yt-dlp documentation](https://github.com/yt-dlp/yt-dlp) for how to
install and what is recommended to install in addition to yt-dl.
@ -27,7 +27,7 @@ import (
"log"
"os"
"github.com/wader/goutubedl"
"gitea.kaz62.ru/dilap54/goutubedl"
)
func main() {

View File

@ -6,7 +6,7 @@ import (
"log"
"os"
"github.com/wader/goutubedl"
"gitea.kaz62.ru/dilap54/goutubedl"
)
func main() {

View File

@ -9,7 +9,7 @@ import (
"os"
"os/exec"
"github.com/wader/goutubedl"
"gitea.kaz62.ru/dilap54/goutubedl"
)
var dumpFlag = flag.Bool("J", false, "Dump JSON")

2
go.mod
View File

@ -1,4 +1,4 @@
module github.com/wader/goutubedl
module gitea.kaz62.ru/dilap54/goutubedl
go 1.12

View File

@ -132,8 +132,9 @@ type Info struct {
ThumbnailBytes []byte `json:"-"`
Thumbnails []Thumbnail `json:"thumbnails"`
Formats []Format `json:"formats"`
Subtitles map[string][]Subtitle `json:"subtitles"`
Formats []Format `json:"formats"`
Subtitles map[string][]Subtitle `json:"subtitles"`
AutomaticCaptions map[string][]*Caption `json:"automatic_captions"`
// Playlist entries if _type is playlist
Entries []Info `json:"entries"`
@ -183,6 +184,14 @@ type Subtitle struct {
Bytes []byte `json:"-"`
}
type Caption struct {
Ext string `json:"ext"`
Protocol string `json:"protocol"`
URL string `json:"url"`
Name string `json:"name"`
Bytes []byte `json:"-"`
}
func (f Format) String() string {
return fmt.Sprintf("%s:%s:%s abr:%f vbr:%f tbr:%f",
f.FormatID,
@ -217,21 +226,29 @@ var TypeFromString = map[string]Type{
// Options for New()
type Options struct {
Type Type
PlaylistStart uint // --playlist-start
PlaylistEnd uint // --playlist-end
Downloader string // --downloader
DownloadThumbnail bool
DownloadSubtitles bool
DownloadSections string // --download-sections
Type Type
PlaylistStart uint // --playlist-start
PlaylistEnd uint // --playlist-end
Downloader string // --downloader
DownloadThumbnail bool
DownloadSubtitles bool
DownloadSubtitlesLang []string
DownloadSubtitlesFormat string
DownloadSections string // --download-sections
Impersonate string // --impersonate
ProxyUrl string // --proxy URL http://host:port or socks5://host:port
UseIPV4 bool // -4 Make all connections via IPv4
Cookies string // --cookies FILE
CookiesFromBrowser string // --cookies-from-browser BROWSER[:FOLDER]
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)
MergeOutputFormat string // --merge-output-format
SortingFormat string // --format-sort
ExtractorArgs string // --extractor-args
InfoArgs []string
DownloadArgs []string
// Set to true if you don't want to use the result.Info structure after the goutubedl.New() call,
// so the given URL will be downloaded in a single pass in the DownloadResult.Download() call.
@ -330,10 +347,26 @@ func infoFromURL(
cmd.Args = append(cmd.Args, "--downloader", options.Downloader)
}
if options.Impersonate != "" {
cmd.Args = append(cmd.Args, "--impersonate", options.Impersonate)
}
if options.Cookies != "" {
cmd.Args = append(cmd.Args, "--cookies", options.Cookies)
}
if options.CookiesFromBrowser != "" {
cmd.Args = append(cmd.Args, "--cookies-from-browser", options.CookiesFromBrowser)
}
if options.ExtractorArgs != "" {
cmd.Args = append(cmd.Args,
"--extractor-args", options.ExtractorArgs,
)
}
cmd.Args = append(cmd.Args, options.InfoArgs...)
switch options.Type {
case TypePlaylist, TypeChannel:
cmd.Args = append(cmd.Args, "--yes-playlist")
@ -454,6 +487,31 @@ func infoFromURL(
}
}
for _, lang := range options.DownloadSubtitlesLang {
if _, ok := info.AutomaticCaptions[lang]; !ok {
continue
}
for _, caption := range info.AutomaticCaptions[lang] {
if options.DownloadSubtitlesFormat != "" && caption.Ext != options.DownloadSubtitlesFormat {
continue
}
resp, respErr := get(caption.URL)
if respErr == nil {
buf, err := io.ReadAll(resp.Body)
if err != nil {
options.DebugLog.Print("err", "download captions "+caption.URL, err)
}
resp.Body.Close()
caption.Bytes = buf
} else {
options.DebugLog.Print("err", "download captions "+caption.URL, respErr)
}
}
}
if options.DownloadSubtitles {
for _, subtitles := range info.Subtitles {
for i, subtitle := range subtitles {
@ -522,6 +580,8 @@ func (result Result) Download(ctx context.Context, filter string) (*DownloadResu
}
type DownloadOptions struct {
AudioFormats string // --audio-formats Download audio using formats (best, aac, alac, flac, m4a, mp3, opus, vorbis, wav)
DownloadAudioOnly bool // -x Download audio only from video
// Download format matched by filter (usually a format id or quality designator).
// If filter is empty, then youtube-dl will use its default format selector.
Filter string
@ -623,6 +683,14 @@ func (result Result) DownloadWithOptions(
cmd.Args = append(cmd.Args, "--playlist-items", fmt.Sprint(options.PlaylistIndex))
}
if options.DownloadAudioOnly {
cmd.Args = append(cmd.Args, "-x")
}
if options.AudioFormats != "" {
cmd.Args = append(cmd.Args, "--audio-format", options.AudioFormats)
}
if result.Options.ProxyUrl != "" {
cmd.Args = append(cmd.Args, "--proxy", result.Options.ProxyUrl)
}
@ -651,6 +719,14 @@ func (result Result) DownloadWithOptions(
)
}
if result.Options.ExtractorArgs != "" {
cmd.Args = append(cmd.Args,
"--extractor-args", result.Options.ExtractorArgs,
)
}
cmd.Args = append(cmd.Args, result.Options.DownloadArgs...)
cmd.Dir = tempPath
var stdoutW io.WriteCloser
var stderrW io.WriteCloser

View File

@ -16,13 +16,13 @@ import (
"strings"
"testing"
"gitea.kaz62.ru/dilap54/goutubedl"
"github.com/fortytw2/leaktest"
"github.com/wader/goutubedl"
"github.com/wader/osleaktest"
)
const (
testVideoRawURL = "https://www.youtube.com/watch?v=C0DPdy98e4c"
testVideoRawURL = "https://vimeo.com/454525548"
playlistRawURL = "https://soundcloud.com/mattheis/sets/kindred-phenomena"
channelRawURL = "https://www.youtube.com/channel/UCHDm-DKoMyJxKVgwGmuTaQA"
subtitlesTestVideoRawURL = "https://www.youtube.com/watch?v=QRS8MkLhQmM"
@ -139,7 +139,7 @@ func TestParseInfo(t *testing.T) {
}{
{"https://soundcloud.com/avalonemerson/avalon-emerson-live-at-printworks-london-march-2017", "Avalon Emerson Live at Printworks London 2017"},
{"https://www.infoq.com/presentations/Simple-Made-Easy", "Simple Made Easy - InfoQ"},
{"https://www.youtube.com/watch?v=uVYWQJ5BB_w", "A Radiolab Producer on the Making of a Podcast"},
{"https://vimeo.com/454525548", "Sample Video - 3 minutemp4.mp4"},
} {
t.Run(c.url, func(t *testing.T) {
defer leakChecks(t)()
@ -221,6 +221,8 @@ func TestPlaylist(t *testing.T) {
}
func TestChannel(t *testing.T) {
t.Skip("skip youtube for now")
defer leakChecks(t)()
ydlResult, ydlResultErr := goutubedl.New(
@ -267,6 +269,8 @@ func TestUnsupportedURL(t *testing.T) {
}
func TestPlaylistWithPrivateVideo(t *testing.T) {
t.Skip("skip youtube for now")
defer leaktest.Check(t)()
playlistRawURL := "https://www.youtube.com/playlist?list=PLX0g748fkegS54oiDN4AXKl7BR7mLIydP"
@ -287,6 +291,8 @@ func TestPlaylistWithPrivateVideo(t *testing.T) {
}
func TestSubtitles(t *testing.T) {
t.Skip("skip youtube for now")
defer leakChecks(t)()
ydlResult, ydlResultErr := goutubedl.New(
@ -332,7 +338,7 @@ func TestDownloadSections(t *testing.T) {
ydlResult, ydlResultErr := goutubedl.New(
context.Background(),
"https://www.youtube.com/watch?v=OyuL5biOQ94",
"https://vimeo.com/454525548",
goutubedl.Options{
DownloadSections: fmt.Sprintf("*0:0-0:%d", duration),
})
@ -343,7 +349,7 @@ func TestDownloadSections(t *testing.T) {
if ydlResultErr != nil {
t.Errorf("failed to download: %s", ydlResultErr)
}
dr, err := ydlResult.Download(context.Background(), "best")
dr, err := ydlResult.Download(context.Background(), "")
if err != nil {
t.Fatal(err)
}
@ -554,6 +560,8 @@ func TestDownloadPlaylistEntry(t *testing.T) {
}
func TestFormatDownloadError(t *testing.T) {
t.Skip("test URL broken")
defer leaktest.Check(t)()
ydl, ydlErr := goutubedl.New(