Git Product home page Git Product logo

ytdl's Introduction

ytdl Build Status GoDoc

Go library for downloading YouTube videos

Documentation: https://godoc.org/github.com/rylio/ytdl

Example

import (
   "github.com/otium/ytdl"
   "os"
)

vid, err := ytdl.GetVideoInfo("https://www.youtube.com/watch?v=1rZ-JorHJEY")
file, _ = os.Create(vid.Title + ".mp4")
defer file.Close()
vid.Download(file)

ytdl CLI

To install: go get -u github.com/rylio/ytdl/...

Usage

ytdl [global options] [youtube url or video id]

Options

  • --help, -h - show help
  • --filter, -f - Filter out formats
    • Syntax: -f key:value1,value2,...,valueN
      • Shortcuts for best/worst(e.g. -f best)
        • best/worst - best/worst video and audio
        • best-video/worst-video - best/worst video
        • best-audio/worst-audio - best/worst audio
    • To exclude: -f !key:value1,...
    • Available keys (See format.go for available values):
      • ext - extension of video
      • res - resolution of video
      • videnc - video encoding
      • audenc - audio encoding
      • prof - youtube video profile
      • audbr - audio bitrate
    • Default filters
      • ext:mp4
      • !videnc:
      • !audenc:
      • best
  • --output, -o - Output to specific path
    • Supports templates, ex: {{.Title}}.{{.Ext}}
    • Defaults to {{.Title}}.{{.Ext}}
    • Supported template variables are Title, Ext, DatePublished, Resolution
    • Pass - to output to stdout, former stdout output is redirected to stderr
  • --info, -i - Just gets video info, outputs to stdout
  • --no-progress - Disables the progress bar
  • --silent, -s - Disables all output, except for fatal errors
  • --debug, -d - Output debug logs
  • --append, -a - append to output file, instead of truncating
  • --range, -r - specify a range of bytes, placed in http range header, ex: 0-100
  • --download-url, -u - just print download url to, don't do anything else
  • --version, -v - print out ytdl cli version
  • --start-offset - offset the beginning of the video by a duration of time(e.g. 20s or 1m)

Examples

Download content based on itag

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

Get all download formats (Requires jq to be installed)

./ytdl -j 'http://youtube.com/watch?v=9bZkp7q19f0' | jq ".formats"

Extract title of the video (Requires jq to be installed)

ytdl -j 'http://youtube.com/watch?v=9bZkp7q19f0' | jq ".title"

Print download url without downloading the content

ytdl -f itag:22 --download-url 'https://www.youtube.com/watch?v=9bZkp7q19f0'

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

ytdl is released under the MIT License, see LICENSE for more details.

ytdl's People

Contributors

rylio avatar kishaningithub avatar mikemadden42 avatar otium avatar vahid-sohrabloo avatar jeffreymkabot avatar joaopms avatar necroforger avatar tcyrus avatar hako avatar mattn avatar robinknaapen avatar yukpiz avatar

Watchers

James Cloos avatar  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.