base on Download Youtube Video in Golang Download Youtube Video in Golang ================== [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/kkdai/youtube/master/LICENSE) [![Go Reference](https://pkg.go.dev/badge/github.com/kkdai/youtube.svg)](https://pkg.go.dev/github.com/kkdai/youtube/v2) [![Build Status](https://github.com/kkdai/youtube/workflows/go/badge.svg?branch=master)](https://github.com/kkdai/youtube/actions) [![Coverage](https://codecov.io/gh/kkdai/youtube/branch/master/graph/badge.svg)](https://codecov.io/gh/kkdai/youtube) [![](https://goreportcard.com/badge/github.com/kkdai/youtube)](https://goreportcard.com/badge/github.com/kkdai/youtube) This package is a Youtube video download package, for more detail refer [https://github.com/ytdl-org/youtube-dl](https://github.com/ytdl-org/youtube-dl) for more download options. This tool is meant to be used to download CC0 licenced content, we do not support nor recommend using it for illegal activities. ## Overview * [Install](#installation) * [Usage](#usage) * [Example: Download video from \[dotGo 2015 - Rob Pike - Simplicity is Complicated\]](#download-dotGo-2015-rob-pike-video) ## Installation ### Run Manually ```shell git clone https://github.com/kkdai/youtube.git && cd youtube go run ./cmd/youtubedr ``` ### Install via Go Please ensure you have installed Go 1.23 or later. ```shell go install github.com/kkdai/youtube/v2/cmd/youtubedr@latest ``` ### Mac ```shell brew install youtubedr ``` ### in Termux ```shell pkg install youtubedr ``` ### You can also find this package in - [archlinux](https://aur.archlinux.org/packages/youtubedr/) (thanks to [cjsthompson](https://github.com/cjsthompson)) - [Termux package](https://github.com/termux/termux-packages/tree/master/packages/youtubedr) (thanks to [kcubeterm](https://github.com/kcubeterm)) - [Homebrew](https://formulae.brew.sh/formula/youtubedr) (thanks to [kkc](https://github.com/kkc)) ## Usage ### Use the binary directly It's really simple to use, just get the video id from youtube url - ex: `https://www.youtube.com/watch?v=rFejpH_tAHM`, the video id is `rFejpH_tAHM` ```shell youtubedr download rFejpH_tAHM youtubedr download https://www.youtube.com/watch?v=rFejpH_tAHM ``` ### Use this package in your golang program Please check out the [example_test.go](example_test.go) for example code. ## Example: * ### Get information of dotGo-2015-rob-pike video for downloading Download video from [dotGo 2015 - Rob Pike - Simplicity is Complicated](https://www.youtube.com/watch?v=rFejpH_tAHM) ``` youtubedr info https://www.youtube.com/watch?v=rFejpH_tAHM Title: dotGo 2015 - Rob Pike - Simplicity is Complicated Author: dotconferences -----available streams----- itag: 18 , quality: medium , type: video/mp4; codecs="avc1.42001E, mp4a.40.2" itag: 22 , quality: hd720 , type: video/mp4; codecs="avc1.64001F, mp4a.40.2" itag: 137 , quality: hd1080 , type: video/mp4; codecs="avc1.640028" itag: 248 , quality: hd1080 , type: video/webm; codecs="vp9" ........ ``` * ### Download dotGo-2015-rob-pike-video Download video from [dotGo 2015 - Rob Pike - Simplicity is Complicated](https://www.youtube.com/watch?v=rFejpH_tAHM) ``` youtubedr download https://www.youtube.com/watch?v=rFejpH_tAHM ``` * ### Download video to specific folder and name Download video from [dotGo 2015 - Rob Pike - Simplicity is Complicated](https://www.youtube.com/watch?v=rFejpH_tAHM) to current directory and name the file to simplicity-is-complicated.mp4 ``` youtubedr download -d ./ -o simplicity-is-complicated.mp4 https://www.youtube.com/watch?v=rFejpH_tAHM ``` * ### Download video with specific quality Download video from [dotGo 2015 - Rob Pike - Simplicity is Complicated](https://www.youtube.com/watch?v=rFejpH_tAHM) with specific quality ``` youtubedr download -q medium https://www.youtube.com/watch?v=rFejpH_tAHM ``` #### Special case by quality hd1080: Installation of ffmpeg is necessary for hd1080 ``` ffmpeg //check ffmpeg is installed, if not please download ffmpeg and set to your PATH. youtubedr download -q hd1080 https://www.youtube.com/watch?v=rFejpH_tAHM ``` * ### Download video with specific itag Download video from [dotGo 2015 - Rob Pike - Simplicity is Complicated](https://www.youtube.com/watch?v=rFejpH_tAHM) ``` youtubedr download -q 18 https://www.youtube.com/watch?v=rFejpH_tAHM ``` ## How it works - Parse the video ID you input in URL - ex: `https://www.youtube.com/watch?v=rFejpH_tAHM`, the video id is `rFejpH_tAHM` - Get video information via video id. - Use URL: `http://youtube.com/get_video_info?video_id=` - Parse and decode video information. - Download URL in "url=" - title in "title=" - Download video from URL - Need the string combination of "url" ## Inspired - [https://github.com/ytdl-org/youtube-dl](https://github.com/ytdl-org/youtube-dl) - [https://github.com/lepidosteus/youtube-dl](https://github.com/lepidosteus/youtube-dl) - [拆解 Youtube 影片下載位置](http://hkgoldenmra.blogspot.tw/2013/05/youtube.html) - [iawia002/annie](https://github.com/iawia002/annie) - [How to get url from obfuscate video info: youtube video downloader with php](https://stackoverflow.com/questions/60607291/youtube-video-downloader-with-php) ## Project52 It is one of my [project 52](https://github.com/kkdai/project52). ## License This package is licensed under MIT license. See LICENSE for details. ", Assign "at most 3 tags" to the expected json: {"id":"11232","tags":[]} "only from the tags list I provide: [{"id":77,"name":"3d"},{"id":89,"name":"agent"},{"id":17,"name":"ai"},{"id":54,"name":"algorithm"},{"id":24,"name":"api"},{"id":44,"name":"authentication"},{"id":3,"name":"aws"},{"id":27,"name":"backend"},{"id":60,"name":"benchmark"},{"id":72,"name":"best-practices"},{"id":39,"name":"bitcoin"},{"id":37,"name":"blockchain"},{"id":1,"name":"blog"},{"id":45,"name":"bundler"},{"id":58,"name":"cache"},{"id":21,"name":"chat"},{"id":49,"name":"cicd"},{"id":4,"name":"cli"},{"id":64,"name":"cloud-native"},{"id":48,"name":"cms"},{"id":61,"name":"compiler"},{"id":68,"name":"containerization"},{"id":92,"name":"crm"},{"id":34,"name":"data"},{"id":47,"name":"database"},{"id":8,"name":"declarative-gui "},{"id":9,"name":"deploy-tool"},{"id":53,"name":"desktop-app"},{"id":6,"name":"dev-exp-lib"},{"id":59,"name":"dev-tool"},{"id":13,"name":"ecommerce"},{"id":26,"name":"editor"},{"id":66,"name":"emulator"},{"id":62,"name":"filesystem"},{"id":80,"name":"finance"},{"id":15,"name":"firmware"},{"id":73,"name":"for-fun"},{"id":2,"name":"framework"},{"id":11,"name":"frontend"},{"id":22,"name":"game"},{"id":81,"name":"game-engine "},{"id":23,"name":"graphql"},{"id":84,"name":"gui"},{"id":91,"name":"http"},{"id":5,"name":"http-client"},{"id":51,"name":"iac"},{"id":30,"name":"ide"},{"id":78,"name":"iot"},{"id":40,"name":"json"},{"id":83,"name":"julian"},{"id":38,"name":"k8s"},{"id":31,"name":"language"},{"id":10,"name":"learning-resource"},{"id":33,"name":"lib"},{"id":41,"name":"linter"},{"id":28,"name":"lms"},{"id":16,"name":"logging"},{"id":76,"name":"low-code"},{"id":90,"name":"message-queue"},{"id":42,"name":"mobile-app"},{"id":18,"name":"monitoring"},{"id":36,"name":"networking"},{"id":7,"name":"node-version"},{"id":55,"name":"nosql"},{"id":57,"name":"observability"},{"id":46,"name":"orm"},{"id":52,"name":"os"},{"id":14,"name":"parser"},{"id":74,"name":"react"},{"id":82,"name":"real-time"},{"id":56,"name":"robot"},{"id":65,"name":"runtime"},{"id":32,"name":"sdk"},{"id":71,"name":"search"},{"id":63,"name":"secrets"},{"id":25,"name":"security"},{"id":85,"name":"server"},{"id":86,"name":"serverless"},{"id":70,"name":"storage"},{"id":75,"name":"system-design"},{"id":79,"name":"terminal"},{"id":29,"name":"testing"},{"id":12,"name":"ui"},{"id":50,"name":"ux"},{"id":88,"name":"video"},{"id":20,"name":"web-app"},{"id":35,"name":"web-server"},{"id":43,"name":"webassembly"},{"id":69,"name":"workflow"},{"id":87,"name":"yaml"}]" returns me the "expected json"