kkdai / youtube Goto Github PK
View Code? Open in Web Editor NEWDownload Youtube Video in Golang
License: MIT License
Download Youtube Video in Golang
License: MIT License
when I try youtubedr nINQjT7Zr9w
, I see
2020/06/16 00:24:07 download to dir= /Users/kakashi/Movies/youtubedr
2020/06/16 00:24:07 Using http without proxy.
2020/06/16 00:24:07 Found video id: 'nINQjT7Zr9w'
2020/06/16 00:24:07 url: https://youtube.com/get_video_info?video_id=nINQjT7Zr9w&eurl=https://youtube.googleapis.com/v/nINQjT7Zr9w
panic: interface conversion: interface {} is nil, not map[string]interface {}
goroutine 1 [running]:
github.com/kkdai/youtube.getVideoTitleAuthor(0xc0000d18c8, 0xc0000d18c8, 0x1346a71, 0xf, 0xc0001c0428)
/Users/kakashi/Programs/Github/youtube/youtube.go:447 +0x2eb
github.com/kkdai/youtube.(*Youtube).parseVideoInfo(0xc0000d8000, 0x0, 0x0)
/Users/kakashi/Programs/Github/youtube/youtube.go:221 +0x2b5
github.com/kkdai/youtube.(*Youtube).DecodeURL(0xc0000d8000, 0x7ffeefbff939, 0xb, 0x1, 0x0)
/Users/kakashi/Programs/Github/youtube/youtube.go:73 +0x153
main.main()
/Users/kakashi/Programs/Github/youtube/youtubedr/main.go:56 +0x541
exit status 2
This is because it's the private video, I think we should handle this kind of error.
planned OS:
ref:
https://github.com/actions/upload-release-asset
https://github.com/wangyoucao577/go-release-action
youtubedr https://www.youtube.com/watch?v=54e6lBE3BoQ
2019/12/30 09:08:57 [https://www.youtube.com/watch?v=54e6lBE3BoQ]
2019/12/30 09:08:57 download to dir= /Users/huzhang2/Movies/youtubedr
2019/12/30 09:08:57 Found video id: '54e6lBE3BoQ'
2019/12/30 09:08:57 url: https://youtube.com/get_video_info?video_id=54e6lBE3BoQ
2019/12/30 09:08:58 Title: 190107 Trouble Maker - Trouble Maker | Dance cover by 莉爷 Author: FanTastiCut Library Stream found: quality 'hd720', format 'video/mp4; codecs="avc1.64001F, mp4a.40.2"'
2019/12/30 09:08:58 Title: 190107 Trouble Maker - Trouble Maker | Dance cover by 莉爷 Author: FanTastiCut Library Stream found: quality 'medium', format 'video/webm; codecs="vp8.0, vorbis"'
2019/12/30 09:08:58 Title: 190107 Trouble Maker - Trouble Maker | Dance cover by 莉爷 Author: FanTastiCut Library Stream found: quality 'medium', format 'video/mp4; codecs="avc1.42001E, mp4a.40.2"'
2019/12/30 09:08:58 Download url= https://r1---sn-i3belne6.googlevideo.com/videoplayback?expire=1577689738&ei=Kk4JXoibGOyKs8IP6JqHmAU&ip=2001%3A420%3A5899%3A1252%3A55d7%3Acadf%3Ae1ea%3Aaa87&id=o-ABFQfCJ-KXfJTZy6op7hVn8moDnyilJ8uflnbzEVtNjo&itag=22&source=youtube&requiressl=yes&mm=31%2C29&mn=sn-i3belne6%2Csn-i3b7kn7d&ms=au%2Crdu&mv=m&mvi=0&pl=39&initcwndbps=2277500&mime=video%2Fmp4&ratebypass=yes&dur=227.091&lmt=1546958970013208&mt=1577668064&fvip=1&fexp=23842630&c=WEB&txp=2211222&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cmime%2Cratebypass%2Cdur%2Clmt&lsparams=mm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AHylml4wRAIgf0tmXkOumnpdF1EmxL5y_ane5tgzTzxFuOtnrKeffQICICG-UusXI6iX0pPLNSD2qrZZqxX6KnZTEtpJEjQj-nLL
2019/12/30 09:08:58 Download to file= /Users/huzhang2/Movies/youtubedr/190107 Trouble Maker - Trouble Maker | Dance cover by 莉爷.mov
2019/12/30 09:08:58 reading answer: non 200[code=403] status code received: ''
2019/12/30 09:08:58 Download url= https://r1---sn-i3belne6.googlevideo.com/videoplayback?expire=1577689738&ei=Kk4JXoibGOyKs8IP6JqHmAU&ip=2001%3A420%3A5899%3A1252%3A55d7%3Acadf%3Ae1ea%3Aaa87&id=o-ABFQfCJ-KXfJTZy6op7hVn8moDnyilJ8uflnbzEVtNjo&itag=43&source=youtube&requiressl=yes&mm=31%2C29&mn=sn-i3belne6%2Csn-i3b7kn7d&ms=au%2Crdu&mv=m&mvi=0&pl=39&initcwndbps=2277500&mime=video%2Fwebm&gir=yes&clen=20520392&ratebypass=yes&dur=0.000&lmt=1546959331386623&mt=1577668064&fvip=1&fexp=23842630&c=WEB&txp=2201222&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cmime%2Cgir%2Cclen%2Cratebypass%2Cdur%2Clmt&lsparams=mm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AHylml4wRAIgf0tmXkOumnpdF1EmxL5y_ane5tgzTzxFuOtnrKeffQICICG-UusXI6iX0pPLNSD2qrZZqxX6KnZTEtpJEjQj-nLL
2019/12/30 09:08:58 Download to file= /Users/huzhang2/Movies/youtubedr/190107 Trouble Maker - Trouble Maker | Dance cover by 莉爷.mov
2019/12/30 09:08:59 reading answer: non 200[code=403] status code received: ''
2019/12/30 09:08:59 Download url= https://r1---sn-i3belne6.googlevideo.com/videoplayback?expire=1577689738&ei=Kk4JXoibGOyKs8IP6JqHmAU&ip=2001%3A420%3A5899%3A1252%3A55d7%3Acadf%3Ae1ea%3Aaa87&id=o-ABFQfCJ-KXfJTZy6op7hVn8moDnyilJ8uflnbzEVtNjo&itag=18&source=youtube&requiressl=yes&mm=31%2C29&mn=sn-i3belne6%2Csn-i3b7kn7d&ms=au%2Crdu&mv=m&mvi=0&pl=39&initcwndbps=2277500&mime=video%2Fmp4&gir=yes&clen=14547071&ratebypass=yes&dur=227.091&lmt=1546958919927019&mt=1577668064&fvip=1&fexp=23842630&c=WEB&txp=2211222&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cmime%2Cgir%2Cclen%2Cratebypass%2Cdur%2Clmt&lsparams=mm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AHylml4wRAIgf0tmXkOumnpdF1EmxL5y_ane5tgzTzxFuOtnrKeffQICICG-UusXI6iX0pPLNSD2qrZZqxX6KnZTEtpJEjQj-nLL
2019/12/30 09:08:59 Download to file= /Users/huzhang2/Movies/youtubedr/190107 Trouble Maker - Trouble Maker | Dance cover by 莉爷.mov
2019/12/30 09:08:59 reading answer: non 200[code=403] status code received: ''
err: non 200 status code received
youtubedr https://www.youtube.com/watch?v=E2_1y_9zGQs
2019/12/30 09:13:11 [https://www.youtube.com/watch?v=E2_1y_9zGQs]
2019/12/30 09:13:11 download to dir= /Users/huzhang2/Movies/youtubedr
2019/12/30 09:13:11 Found video id: 'E2_1y_9zGQs'
2019/12/30 09:13:11 url: https://youtube.com/get_video_info?video_id=E2_1y_9zGQs
err: parse video info failed, err=no stream map found in the server's answer
I got this error when trying this ID 9ja-K2FslBU
==> should be call only 1 time and reusing html data if possible ?
Complete newbie question!!!
After the installation where is the youtubedr binary located?
I am running Ubuntu 20.04.
I installed go today along with youtubedr. I tried both install methods and no errors but I cannot find youtubedr. I search my home directory and cannot seem to find it. I thought it would be in ~/go/bin/ but no luck. I can see the source in ~/go/src/github/kkdai/youtube
I am not sure what I did wrong?
Thank you
Hi, I've found that when download a music video it will get the error: error parsing signature tokens
but there's no error when it's not a muisc video.
Is the google api changed or something?
I'm using v2.0.1
btw.
Refer to #17
youtubedr https://www.youtube.com/watch?v=FHpvI8oGsuQ
Video content is MKV, need to refer https://github.com/ytdl-org/youtube-dl to add MKV download feature.
This might be easier for some users to use this tool
Youbue provides 2 different formats (Formats, AdaptiveFormats). I thought we should make user be able to download AdaptiveFormats videos.
Required :
currently, we can get the video info when we download video. But I think it would be convenient that users can check video information before downloading it. Like we can understand what type of itag value or quality is valid.
The Usage section in the readme has currentFile, _ := filepath.Abs(os.Args[0])
, which points to the main executable.
I think it should be currentFile, _ := filepath.Abs(os.Args[1])
. If I am misunderstanding, then disregard.
Hello, I am trying to download a video through your library and I'm getting the following:
[niko:~/Downloads] 2s $ youtubedr https://www.youtube.com/watch?v=FHpvI8oGsuQ
2019/05/27 21:28:09 [https://www.youtube.com/watch?v=FHpvI8oGsuQ]
2019/05/27 21:28:09 download to dir= /home/niko/Downloads
2019/05/27 21:28:09 Found video id: 'FHpvI8oGsuQ'
2019/05/27 21:28:09 url: http://youtube.com/get_video_info?video_id=FHpvI8oGsuQ
panic: runtime error: index out of range
goroutine 1 [running]:
github.com/kkdai/youtube.(*Youtube).StartDownload(0xc42001c4e0, 0xc4200d2960, 0x14, 0x7949c0, 0xc42018ebf0)
/home/niko/go/src/github.com/kkdai/youtube/youtube.go:59 +0x3b6
main.main()
/home/niko/go/src/github.com/kkdai/youtube/youtubedr/main.go:20 +0x29a
Any clues?
Hi, I'm developing a program in which I need to download a playlist of videos; so far I've found a YouTube API link to list all videos in a playlist, and it contains all the videos' Ids. For now, I've taken these ids, and then I can download the videos individually.
Do you have any plans to add this? I can perhaps work on it if you'd like, as it's not too large. Luckily, the API link contains lots of information for each video, so you wouldn't have to call decodeUrl
, which at the moment I do.
https://youtube.com/list_ajax?style=json&action_get_list=1&list={playlist-id}&hl=en
is the API url, I stole it from https://github.com/Tyrrrz/YoutubeExplode/blob/master/YoutubeExplode/ReverseEngineering/Responses/PlaylistResponse.cs
The API's return objects are in the form
{
"author": string,
"views": int,
"title": string,
"description": string,
"video": {
"user_id": string,
"encrypted_id": string,
"keywords": string,
"title": string,
... ...
}[]
}
Hi!
I've a request. I'm building a youtube client written on go, and i want to use a part of your code in my application. Obviously if you accept, i going to giving you the credits, and link this project.
What do you think?
PD: Sorry for my english
go run main.go -q 18 https://www.youtube.com/watch?v=54e6lBE3BoQ
expect behavior : use video title as default name like :
go run main.go https://www.youtube.com/watch?v=54e6lBE3BoQ
installed the latest version (2.0.2) in termux but the -i option is not working, it always downloads the best quality audio/video as if the option is not given.
In some machine, i need to disable ssl verification in http client, could you make it an option please.
1080p
How can I only get the audio without the video?
if we don't specify video ID as following, you will see an improper error message.
$ go run youtubedr/main.go
2020/06/15 23:09:16 []
2020/06/15 23:09:16 download to dir= /Users/kakashi/Movies/youtubedr
2020/06/15 23:09:16 Using http without proxy.
2020/06/15 23:09:16 Found video id: ''
err: findVideoID error=the video id must be at least 10 characters long
instead, we should print default usage to let users know how to use this tool
We should make sure that every pr ‘s .go file has been formatted by go fmt.
That's stupid, so let's use github action to handle this matter.
like #28 , this case is for option -o
go run main.go -o "*c/!:\test1".mov https://www.youtube.com/watch?v=54e6lBE3BoQ
we recently add itag support but we didn't modify readme accordingly.
like issue #45.
need somebody to update readme and add some examples
the program is failing in youtube.go at line 248, because the struct for player_response is wrong(maybe youtube has changed the response). the struct has a field called Cipher but in youtube response is called signatureCipher and has no URL field
now youtube have more code and functions than before. To improve readability and maintainability, we would like to reorganize project layout, some plans are under discussion:
Thanks for any suggestion in advance.
when I tried go run youtubedr/main.go -aG8nf1Mm9c
, I got flag provided but not defined: -aG8nf1Mm9c
The signature pattern has change.
2019/08/04 01:05:02 Download to file= /Users/evan/Movies/yotubedr/dl.mp4
2019/08/04 01:05:08 reading answer: non 200[code=403] status code received: ''
err: non 200 status code received
Refer following change in python youtube-dl to fix this block:
It would be convenient for users to understand the progress of downloading.
maybe we can integrate https://github.com/cheggaaa/pb into this project.
Just asking . It would be really amazing if it supports few more sites like Facebook, twitter insta etc.
type Stream struct {
ItagNo int `json:"itag"`
URL string `json:"url"`
MimeType string `json:"mimeType"`
Quality string `json:"quality"`
Cipher string `json:"signatureCipher"`
}
Please add codecs
, bitrate
, range
, init
of AdaptiveFormats
to the Stream
struct please ...
download 720p 1080p
When I tried go run youtubedr/main.go -q hd1080 Ap0huJwyT7g
, it will show the following messages
check ffmpeg is installed....
2020/07/11 21:42:48 Download url=
2020/07/11 21:42:48 Downloading video file...
2020/07/11 21:42:48 Http.Get
error: Get : unsupported protocol scheme ""
target:
err: Get : unsupported protocol scheme ""
this message is not able to make users know there is no 1080 video
Hello 😄
Sadly, some videos didn't have url_encoded_fmt_stream_map
or got 403 code
, so didn't work.
ex.1) 3bNITQR4Uso
<... skip ...>
url_encoded_fmt_stream_map =>
fflags => bulleit_block_player_pause_until_ad_start%3Dtrue% ...
<... skip ...>
(i made a small tool for test it with D and just split it like :("=", "\n")
. nvm...)
ex.2) -k5iFLYXmWU
2018/12/11 00:46:06 reading answer: non 200[code=403] status code received: '<nil>'
(with youtubedr.exe)
Like youtube-dl and ytdl, youtubedr should also have itag option , in which we can download different format like webm and m4a also for audio.
running CI needs ffmpeg, we could cache ffmpeg in github action to speed up workflow
I can only download very few videos, because most of the time I get this error.
This is one of the videos https://www.youtube.com/watch?v=n3kPvBCYT3E
$ youtubedr https://www.youtube.com/watch?v=rFejpH_tAHM
2020/04/01 16:38:58 [https://www.youtube.com/watch?v=rFejpH_tAHM]
2020/04/01 16:38:58 download to dir= /home/egorov/Movies/yotubedr
2020/04/01 16:38:58 Found video id: 'rFejpH_tAHM'
2020/04/01 16:38:58 url: http://youtube.com/get_video_info?video_id=rFejpH_tAHM
err: parse video info failed, err=no stream map found in the server's answer
$ go version
go version go1.14 linux/amd64
Trying to import v2 in a project, copying the provided example_test.go
file, yields the following error.
Even after updating the go.mod version like so
It still errors out with
require github.com/kkdai/youtube: version "v2.0.0" invalid: module contains a go.mod file, so major version must be compatible: should be v0 or v1, not v2
From what I understand the module
directive in the go.mod file should be updated with /v2
like so
module github.com/kkdai/youtube/v2
ex: ./youtubedr https://www.youtube.com/watch\?v\=n3kPvBCYT3E
2020/04/20 18:28:15 Download to file= /Users/USER/Movies/youtubedr/Silhouette / Eurobeat Remix.mov
As title
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.