Git Product home page Git Product logo

youtube-2's Introduction

Download Youtube Video in Golang

GitHub license Go Reference Build Status Coverage

This package is a Youtube video download package, for more detail refer 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

Installation

Install via go get

Please ensure you have installed Go 1.16 or later.

go get github.com/kkdai/youtube/v2

From source code

git clone https://github.com/kkdai/youtube.git
cd youtube
go run ./cmd/youtubedr

Mac

brew install youtubedr

in Termux

pkg install youtubedr

You can also find this package in

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

$ youtubedr download QAGDGja7kbs
$ youtubedr download https://www.youtube.com/watch?v=rFejpH_tAHM

Use this package in your golang program

Please check out the example_test.go for example code.

Example:

  • Get information of dotGo-2015-rob-pike video for downloading

    go get github.com/kkdai/youtube/v2/youtubedr

    Download video from dotGo 2015 - Rob Pike - Simplicity is Complicated

    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

    go get github.com/kkdai/youtube/v2/youtubedr

    Download video from dotGo 2015 - Rob Pike - Simplicity is Complicated

    youtubedr download https://www.youtube.com/watch?v=rFejpH_tAHM
    
  • Download video to specific folder and name

    go get github.com/kkdai/youtube/v2/youtubedr

    Download video from dotGo 2015 - Rob Pike - Simplicity is Complicated 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

    go get github.com/kkdai/youtube/v2/youtubedr

    Download video from dotGo 2015 - Rob Pike - Simplicity is Complicated 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

    go get github.com/kkdai/youtube/v2/youtubedr

    Download video from dotGo 2015 - Rob Pike - Simplicity is Complicated

    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

Project52

It is one of my project 52.

License

This package is licensed under MIT license. See LICENSE for details.

youtube-2's People

Contributors

appleboy avatar aracoool avatar cloudingcity avatar corny avatar elproxy avatar fr3fou avatar halfwit avatar ilmanzo avatar itscaro avatar jinweijie avatar john-black-3k avatar julian-chu avatar kamilkabir9 avatar kasseltrankos avatar kcubeterm avatar kkc avatar kkdai avatar mihonarium avatar mparvin avatar nitrix avatar nmisko avatar ogguz avatar supersandro2000 avatar sxwr avatar tobychui avatar trofen avatar tystuyfzand avatar vmatt avatar

Watchers

 avatar

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.