Git Product home page Git Product logo

ytdl's People

Contributors

ademhodzic avatar andreychik32 avatar arian-amador avatar brucewangno1 avatar corny avatar deoxxa avatar frizinak avatar hades32 avatar hako avatar jamestjw avatar jeffreymkabot avatar joaopms avatar kishaningithub avatar mattn avatar mikemadden42 avatar necroforger avatar otium avatar robinknaapen avatar rylio avatar skwair avatar sogocze avatar tcyrus avatar vahid-sohrabloo avatar wedojava avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ytdl's Issues

Error parsing signature tokens on 30% of videos.

using the ytdl binary like:
./ytdl -u
or using ytdl in code, has the same issue. On random videos i get this error

When using for example:
./ytdl https://www.youtube.com/watch?v=YqUyNvGsM9s
I get this:
FATA[0000] Unable to get download url: Error parsing signature tokens

Or when using in Go Code:
panic: Error parsing signature tokens

I have reproduced this on Windows 10, Void Linux and Arch Linux.

Videos that do work

https://www.youtube.com/watch?v=1gOQiFEwnZ8
https://www.youtube.com/watch?v=MXgnIP4rMoI
https://www.youtube.com/watch?v=peBgUMT26jM

Videos that don't work

https://www.youtube.com/watch?v=aQZDbBGBJsM
https://www.youtube.com/watch?v=cRS4mS4gKwg
https://www.youtube.com/watch?v=0fllyJTBsRU

I have been unable to find any pattern.

Support downloading portions of the video

My current use for youtube-dl is downloading videos from a specific point onwards, this isn't supported but done by using the URL provided with -g inside curl and appending the begin query parameter.

Example of using the begin param (it's in milliseconds):

curl $(youtube-dl -g fjImkK1xAZI)'&begin=38000' -o kobe-block.mp4

There is an issue that youtube starts playing from the nearest keyframe which could be before or after the given time. My workflow now is download the video starting 10 seconds prior, run that through ffprobe, find the closest preceding keyframe and start the download again from there.

I am not sure that google provides an end or equivalent parameter but it would be useful to have that functionality as well. Ideally I'd be ably to do something like this:

ytdl fjImkK1xAZI --start 38 --end 42 --output --format 18 kobe-block.mp4

The "--append, -a" flag does not work as expected

Doesn't the "--append, -a" flag intend to enable http partial request? For example, when there is a partial file downloaded locally and a new http download request is supposed to pick up where it left off. If so, it does not work as expected. The download process just starts all over again and appends to the partial file.

resume download

it should be possible to resume a previously started (but interrupted) download.

I thought the --append,-a option was it, but it just restarts from the beginning, appending to the previous short-file.

Method GetDownloadURL returns an error (empty host)

Get http:///yts/jsbin/player-en_GB-vflJIlAsj/base.js: http: no Host in request URL

Recently my bot (github.com/vadimyer/RealMusicBot) stopped working for almost all videos because of the error from GetDownloadURL.

As it seems it constructs a URL without a host.

can't download videos with id that starts with a dash

den@febf7f699c38:tmp$ ytdl https://www.youtube.com/watch?v=-KGfp2aTnHs
INFO[0000] Fetching video info...                       
panic: regexp: Compile(`yt.setConfig('PLAYER_CONFIG', (.*?)</script>`): error parsing regexp: missing closing ): `yt.setConfig('PLAYER_CONFIG', (.*?)</script>`

den@febf7f699c38:tmp$ ytdl -KGfp2aTnHs
Incorrect Usage.

den@febf7f699c38:tmp$ ytdl -- -KGfp2aTnHs
INFO[0000] Fetching video info...                       
panic: regexp: Compile(`yt.setConfig('PLAYER_CONFIG', (.*?)</script>`): error parsing regexp: missing closing ): `yt.setConfig('PLAYER_CONFIG', (.*?)</script>`

Please don't judge me for my choice of an example video! :D

Addition of -mp3 flag

If ffmpeg is available in the system the flag -mp3 will convert the downloaded video into mp3

Example

ytdl -mp3 'https://www.youtube.com/watch?v=9bZkp7q19f0'

If you are fine with this i am willing to do it and create a PR

Example code in README.md is incorrect

The last line in the example golang code is incorrect and does not work.
It should be something like the code below with the first argument being the file format

vid.Download(vid.Formats[0],file)

GetVideoInfo needs url sanitizing/validation

Currently, anything can be passed to GetVideoInfo, and a *VideoInfo will be returned, regardless whether or not the passed string is a valid YouTube video link or not.
For example, if i pass if to GetVideoInfo, i will be given a *VideoInfo without an error being returned. I can call Download on this too and no error is returned from this either, even though its not a valid YouTube video

The returned *VideoInfo:

&{if   0001-01-01 00:00:00 +0000 UTC [] []  0s /yts/jsbin/player-vflHDhBq1/en_US/base.js}

failed

FATA[0001] Unable to open output file: open Instalasi & Hello World di Golang : Tutorial Golang Indonesia [Part1].mp4: invalid argument

There seems to be a problem with the name of the output.
Everything went smoothly when I used the ID from the video for the file name

worst audio not working

For a specific video, the list of formats returned does not include worst audio format (compared with youtube-dl which does include this).

./ytdl -f worst-audio https://www.youtube.com/watch?v=xwx4QzEAKKw

This results in the highest quality video being downloaded!

Tag Latest Version

Please tag the master branch with the latest version (probably v0.5.1) because the latest tag, v0.5.0, has a bug with getting videos by ID. The bug is fixed in master, but anyone using golang/dep for package dependency management will be forced to upgrade manually.

Crash on Facebook video

Yeah, it's not on YouTube, but is seems interesting anyway:

$ ytdl https://www.facebook.com/video.php?v=10153820411888896
INFO[0000] Fetching video info...                       
panic: regexp: Compile(`yt.setConfig('PLAYER_CONFIG', (.*?)</script>`): error parsing regexp: missing closing ): `yt.setConfig('PLAYER_CONFIG', (.*?)</script>`

goroutine 1 [running]:
regexp.MustCompile(0x8dcf80, 0x2c, 0xc8204e2000)
    /usr/local/go/src/regexp/regexp.go:221 +0x16f
github.com/otium/ytdl.getInfoFromHTML(0x7ffeafafd0ae, 0x11, 0xc8204e2000, 0x3fc7, 0x7e00, 0x0, 0x0, 0x0)
    /home/nl/go-code/src/github.com/otium/ytdl/info.go:173 +0x265e
github.com/otium/ytdl.GetInfoFromID(0x7ffeafafd0ae, 0x11, 0x0, 0x0, 0x0)
    /home/nl/go-code/src/github.com/otium/ytdl/info.go:91 +0x4c8
github.com/otium/ytdl.GetInfoFromURL(0xc8200a2700, 0x36, 0x0, 0x0)
    /home/nl/go-code/src/github.com/otium/ytdl/info.go:69 +0xfb
github.com/otium/ytdl.GetInfo(0x73c1c0, 0xc820102ad0, 0xc820102ad0, 0x0, 0x0)
    /home/nl/go-code/src/github.com/otium/ytdl/info.go:57 +0x16d
main.handler(0x7ffeafafd089, 0x36, 0x0, 0xc82000bde0, 0x13, 0x0, 0xc820014bc0, 0x4, 0x4, 0x0, ...)
    /home/nl/go-code/src/github.com/otium/ytdl/cmd/ytdl/main.go:147 +0x340
main.main.func1(0xc8200f79e0)
    /home/nl/go-code/src/github.com/otium/ytdl/cmd/ytdl/main.go:109 +0x592
github.com/codegangsta/cli.(*App).Run(0xc8200f78c0, 0xc82000a5a0, 0x2, 0x2, 0x0, 0x0)
    /home/nl/go-code/src/github.com/codegangsta/cli/app.go:180 +0x1051
main.main()
    /home/nl/go-code/src/github.com/otium/ytdl/cmd/ytdl/main.go:112 +0x10b4

[...]

best, worst format selectors

It would be nice if ytdl supported youtube-dl's shortcut format selectors: best, worst, bestvideo, bestaudio, worstvideo, worstaudio

Outdated example code in README

Hello!

I am trying to download best available audio for a youtube video. But not able to understand how to achieve that. The example in README is seriously outdated I guess. The import points to "github.com/otium/ytdl" whereas your username is rylio.Can you please provide a complete up to date example as to how to download videos?

Cheers!

Different language titles

If we have a server based in say, France, ytdl will get the French title.
A way to specify what language we want our response to be in would be nice.
I think https://www.youtube.com/get_video_info?video_id=${ID} gets the default title that the uploader uses, if nothing else.

Cannot use Video ID starting with a dash

Passing video ID starting with a dash (even like this: ytdl -o - "-2TrtmssNPA") leads to Incorrect Usage.
It seems like it is trying to parse it as a flag, but I'm not sure how to fix that.

0 bytes downloads

Hi,
I am using "go version go1.12.9 windows/amd64" with Windows 10.
Executing the code from the example results in 0 bytes file.
Did youtube change the api again or... ?

Info is confusing

Very useful project. Thanks.

The type Info with method func (*Info) Download makes confusing. Info makes me think it's just some information about something, eg os.FileInfo. Maybe Video is a better name that Info. Video.Downlad(...) is better to understand.

Andrew

Unable to build ytdl

I'm unable to build ytdl:

$ go version
go version go1.13.4 darwin/amd64

$ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.15.1
BuildVersion:	19B88
$ go get -u -ldflags "-s -w" github.com/otium/ytdl/...
# github.com/otium/ytdl/cmd/ytdl
go/src/github.com/otium/ytdl/cmd/ytdl/main.go:50:17: cannot use cli.StringFlag literal (type cli.StringFlag) as type cli.Flag in array or slice literal:
	cli.StringFlag does not implement cli.Flag (Apply method has pointer receiver)
go/src/github.com/otium/ytdl/cmd/ytdl/main.go:55:15: cannot use cli.BoolFlag literal (type cli.BoolFlag) as type cli.Flag in array or slice literal:
	cli.BoolFlag does not implement cli.Flag (Apply method has pointer receiver)
go/src/github.com/otium/ytdl/cmd/ytdl/main.go:59:15: cannot use cli.BoolFlag literal (type cli.BoolFlag) as type cli.Flag in array or slice literal:
	cli.BoolFlag does not implement cli.Flag (Apply method has pointer receiver)
go/src/github.com/otium/ytdl/cmd/ytdl/main.go:63:15: cannot use cli.BoolFlag literal (type cli.BoolFlag) as type cli.Flag in array or slice literal:
	cli.BoolFlag does not implement cli.Flag (Apply method has pointer receiver)
go/src/github.com/otium/ytdl/cmd/ytdl/main.go:67:15: cannot use cli.BoolFlag literal (type cli.BoolFlag) as type cli.Flag in array or slice literal:
	cli.BoolFlag does not implement cli.Flag (Apply method has pointer receiver)
go/src/github.com/otium/ytdl/cmd/ytdl/main.go:71:15: cannot use cli.BoolFlag literal (type cli.BoolFlag) as type cli.Flag in array or slice literal:
	cli.BoolFlag does not implement cli.Flag (Apply method has pointer receiver)
go/src/github.com/otium/ytdl/cmd/ytdl/main.go:75:22: cannot use cli.StringSliceFlag literal (type cli.StringSliceFlag) as type cli.Flag in array or slice literal:
	cli.StringSliceFlag does not implement cli.Flag (Apply method has pointer receiver)
go/src/github.com/otium/ytdl/cmd/ytdl/main.go:79:17: cannot use cli.StringFlag literal (type cli.StringFlag) as type cli.Flag in array or slice literal:
	cli.StringFlag does not implement cli.Flag (Apply method has pointer receiver)
go/src/github.com/otium/ytdl/cmd/ytdl/main.go:83:15: cannot use cli.BoolFlag literal (type cli.BoolFlag) as type cli.Flag in array or slice literal:
	cli.BoolFlag does not implement cli.Flag (Apply method has pointer receiver)
go/src/github.com/otium/ytdl/cmd/ytdl/main.go:87:15: cannot use cli.BoolFlag literal (type cli.BoolFlag) as type cli.Flag in array or slice literal:
	cli.BoolFlag does not implement cli.Flag (Apply method has pointer receiver)
go/src/github.com/otium/ytdl/cmd/ytdl/main.go:87:15: too many errors

About Socks5

Can we use proxy to download video?Or if you don't mind,i suggest to add the feature

install error

../go/src/github.com/rylio/ytdl/cmd/ytdl/main.go:47:17: cannot use cli.StringFlag literal (type cli.StringFlag) as type cli.Flag in slice literal:
cli.StringFlag does not implement cli.Flag (Apply method has pointer receiver)
../go/src/github.com/rylio/ytdl/cmd/ytdl/main.go:52:15: cannot use cli.BoolFlag literal (type cli.BoolFlag) as type cli.Flag in slice literal:
cli.BoolFlag does not implement cli.Flag (Apply method has pointer receiver)
../go/src/github.com/rylio/ytdl/cmd/ytdl/main.go:56:15: cannot use cli.BoolFlag literal (type cli.BoolFlag) as type cli.Flag in slice literal:
cli.BoolFlag does not implement cli.Flag (Apply method has pointer receiver)
../go/src/github.com/rylio/ytdl/cmd/ytdl/main.go:60:15: cannot use cli.BoolFlag literal (type cli.BoolFlag) as type cli.Flag in slice literal:
cli.BoolFlag does not implement cli.Flag (Apply method has pointer receiver)
../go/src/github.com/rylio/ytdl/cmd/ytdl/main.go:64:15: cannot use cli.BoolFlag literal (type cli.BoolFlag) as type cli.Flag in slice literal:
cli.BoolFlag does not implement cli.Flag (Apply method has pointer receiver)
../go/src/github.com/rylio/ytdl/cmd/ytdl/main.go:68:22: cannot use cli.StringSliceFlag literal (type cli.StringSliceFlag) as type cli.Flag in slice literal:
cli.StringSliceFlag does not implement cli.Flag (Apply method has pointer receiver)
../go/src/github.com/rylio/ytdl/cmd/ytdl/main.go:72:17: cannot use cli.StringFlag literal (type cli.StringFlag) as type cli.Flag in slice literal:
cli.StringFlag does not implement cli.Flag (Apply method has pointer receiver)
../go/src/github.com/rylio/ytdl/cmd/ytdl/main.go:76:15: cannot use cli.BoolFlag literal (type cli.BoolFlag) as type cli.Flag in slice literal:
cli.BoolFlag does not implement cli.Flag (Apply method has pointer receiver)
../go/src/github.com/rylio/ytdl/cmd/ytdl/main.go:80:15: cannot use cli.BoolFlag literal (type cli.BoolFlag) as type cli.Flag in slice literal:
cli.BoolFlag does not implement cli.Flag (Apply method has pointer receiver)
../go/src/github.com/rylio/ytdl/cmd/ytdl/main.go:84:17: cannot use cli.StringFlag literal (type cli.StringFlag) as type cli.Flag in slice literal:
cli.StringFlag does not implement cli.Flag (Apply method has pointer receiver)
../go/src/github.com/rylio/ytdl/cmd/ytdl/main.go:84:17: too many errors

Add ID support to output files

diff --git a/cmd/ytdl/main.go b/cmd/ytdl/main.go
index 0ae1b8a..4655437 100644
--- a/cmd/ytdl/main.go
+++ b/cmd/ytdl/main.go
@@ -48,7 +48,7 @@ func main() {
 		cli.StringFlag{
 			Name:  "output, o",
 			Usage: "Write output to a file, passing - outputs to stdout",
-			Value: "{{.Title}}.{{.Ext}}",
+			Value: "{{.Title}} [{{.ID}}].{{.Ext}}",
 		},
 		cli.BoolFlag{
 			Name:  "info, i",
@@ -221,6 +221,7 @@ func handler(identifier string, options options) {
 	if out == nil {
 		var fileName string
 		fileName, err = createFileName(options.outputFile, outputFileName{
+			ID:            sanitizeFileNamePart(info.ID),
 			Title:         sanitizeFileNamePart(info.Title),
 			Ext:           sanitizeFileNamePart(format.Extension),
 			DatePublished: sanitizeFileNamePart(info.DatePublished.Format("2006-01-02")),
diff --git a/cmd/ytdl/utils.go b/cmd/ytdl/utils.go
index 396f7ed..8032103 100644
--- a/cmd/ytdl/utils.go
+++ b/cmd/ytdl/utils.go
@@ -62,6 +62,7 @@ func parseFilter(filterString string) (func(ytdl.FormatList) ytdl.FormatList, er
 }
 
 type outputFileName struct {
+	ID            string
 	Title         string
 	Author        string
 	Ext           string

Update example please

vid.Download expects 2 parameters instead of 1 as in README. I'm trying to download a video/audio but no matter how I constract the format field it doesn't download it:

vid.Download(ytdl.Format{
        Extension:     "mp4",
        Resolution:    "360p",
        VideoEncoding: "H.264",
        AudioEncoding: "aac",
        Itag:          18,
        AudioBitrate:  96,
    }, file)

What am I doing wrong?

Don't log when used as a library

The ytdl library appears to log to the global zerolog logger, which writes directly to stderr. I don't use zerolog (or any global logger), so the messages that appear interfere with my normal structured logging. For example:

irc_1     | 2019-12-28T01:16:21.238Z	DEBUG	birc/connecton.go:305	sent	{"subconnID": 1, "xid": "bo3app8k2nhpek5284f0", "m": "PRIVMSG #zikaeroh :[HB] YouTube link parsing is now enabled."}
bot_1     | 2019-12-28T01:16:21.243Z	DEBUG	bot/handle.go:66	handled message	{"xid": "bo3app8k2nhpek5284f0", "irc_command": "PRIVMSG", "took": "11.31543ms"}
bot_1     | 2019-12-28T01:16:21.439Z	DEBUG	bot/handle.go:66	handled message	{"xid": "bo3app8k2nhpek5284g0", "irc_command": "USERSTATE", "took": "502.141µs"}
bot_1     | {"level":"debug","time":"2019-12-28T01:16:36Z","message":"Fetching https://www.youtube.com/watch?v=WjNssEVlB6M"}
irc_1     | 2019-12-28T01:16:37.270Z	DEBUG	birc/connecton.go:305	sent	{"subconnID": 1, "xid": "bo3apt0k2nhpek5284h0", "m": "PRIVMSG #zikaeroh :[HB] Linked YouTube video: \"Jamie xx - Gosh (Official Music Video)\""}
bot_1     | 2019-12-28T01:16:37.276Z	DEBUG	bot/handle.go:66	handled message	{"xid": "bo3apt0k2nhpek5284h0", "irc_command": "PRIVMSG", "took": "998.170646ms"}

Can the use of a global logger be removed? Perhaps, convert this package to have a client struct with methods and some logger field that can be set for use in cmd/ytdl? net/http has global functions, which really just work on some http.Client global var. I'd think you could maintain backwards compatibility by doing something similar.

Go module compatibility

Currently go mod would download the latest release 0.5.1, which imports github.com/Sirupsen/logrus as a dependency, for which would make go build complaining a conflict. Have to modify go.mod to specify master branch to workaround this issue, please release a new tag to fix, thanks in advance.

Playlist Support

Are you going for the "Unix" type flow, where we would pass in multiple Video Id's. Or do you think Playlist support would be ideal in this? I'm willing to look into this over the weekend - unless you already have :), just wanted to know your thoughts on this.

Add option to determine why a YouTube fetch fails

If ytdl fails to fetch the video, such as it being blocked or age-restricted, being able to check why would be great for software that needs such functionality.
Something like info.errmsg from GetVideoInfo or something might work, or even have a []string for multiple possible error reasons/messages.

Error downloading video

$ ytdl https://www.youtube.com/watch?v=qD8hOJoOGtk
INFO[0000] Fetching video info...                       
FATA[0000] Unable to fetch video info: Error extracting json 

No debug log produced when adding the -d option:

$ ytdl -d https://www.youtube.com/watch?v=qD8hOJoOGtk
INFO[0000] Fetching video info...                       
FATA[0000] Unable to fetch video info: Error extracting json 

Update logrus github path

github.com/Sirupsen/logrus: github.com/Sirupsen/[email protected]: parsing go.mod: module declares its path as: github.com/sirupsen/logrus but was required as: github.com/Sirupsen/logrus

Can you update the import path?

Error parsing signature tokens

Hello, I am using you lib in a music bot and today appeared an error at getting the url:
"Error parsing signature tokens".
Also I test the ytdl client and have the same error:

Example: ./ytdl -u https://www.youtube.com/watch?v=8TTTcVHNvrc
"Unable to get download url: Error parsing signature tokens"

Did youtube change something?

Thanks.

Zero bytes

I'm getting files with appropriate titles but zero bytes.
No errors.
I tried go get -u to no avail.
Not sure what's not working.
Thanks

Add frames per second to Format struct

As per title. Currently there is no way to differentiate between Formats by frames-per-second.
YouTube supports 60fps video now, so it would be nice if the Format struct reflected that.

Bonus points for making the best format selector opt for higher-framerate, rather than only higher-resolution.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.