Giter VIP home page Giter VIP logo

gotube's Introduction

GoTube

Overview

This repository contains a single-file implementation of YouTube video downloader written in Go. It does not require any third-party packages, only built-in packages from the standard library. The code is compact and easily-readable.

Installation

You can fetch one of the executable binaries (preferably latest one) from Releases. The binaries only support Windows (32 and 64 bit) and Linux (32 and 64 bit) this time.

You can also install GoTube directly from command line. Simply just type a command below in your terminal:

go get github.com/Marethyu12/gotube

Building From Source

Run the following commands:

git clone https://github.com/Marethyu12/gotube.git
cd gotube
go build gotube.go

How It Works?

When GoTube receives a YouTube video URL as an input, it will extract a video id portion of the URL. Then it sends a HTTP GET request to a server through URL https://www.youtube.com/get_video_info with the video id as a query string. The GET request will return an encoded data containing YouTube video data which will be decoded by GoTube. It will then extract the video's title, file format and its download URL from the data. After getting all necessary data, GoTube makes a video file with specified title and file format in User's OS and sends another HTTP GET request to the download URL. The data received through the GET request will be copied to the created video file.

Steps:

  1. GoTube begins by extracting a video id from a YouTube URL (ex. if the URL is https://www.youtube.com/watch?v=9aUlHLaVmkc, GoTube will extract 9aUlHLaVmkc part).
  2. GoTube sends an HTTP GET request to a server through https://www.youtube.com/get_video_info with the video id as a query string (ex. using id from the previous example, https://www.youtube.com/get_video_info?video_id=9aUlHLaVmkc).
  3. GoTube retrieves the video's title, file format and its download URL from an encoded data received through the GET request.
  4. GoTube creates a video file in User's OS and make another GET request through the download URL.
  5. GoTube copies contents of data received through the GET request to the created video file.

Example Usage

Basic:

gotube -vidurl=https://www.youtube.com/watch?v=vUOHGL4Iv34 -outdir=<download directory>

With verbose option:

gotube -vidurl=https://www.youtube.com/watch?v=wJMkvlTAzHc -outdir=<download directory> -v

Option to download audio (requires ffmpeg, get one here if you don't have one installed):

gotube -vidurl=https://www.youtube.com/watch?v=Hh_HyNfyOKs -outdir=<download directory> -a

Replace <download directory> your download directory (ex. C:\users\marethyu\documents\poo)

TODO

  • Download multiple videos asynchronously
  • Download whole playlist

Contributing

I appreciate any kind of contributions. It can include code changes, new features and recommendations.

License

It's licensed under BSD-3-Clause.

gotube's People

Watchers

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