GoTube – a very simple command line tool for downloading YouTube videos

栏目: IT技术 · 发布时间: 5年前

内容简介: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.You can fetch one of th

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.

From Source

If you don't have Go installed yet, download here . Clone this repository and go to the repository directory. Then run the following command:

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 Commands

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

With verbose option:

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

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

TODO

  • Option to download audio only
  • Download whole playlist
  • Progress bar?

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

逆向工程核心原理

逆向工程核心原理

[韩] 李承远 / 武传海 / 人民邮电出版社 / 2014-4-25 / 109.00元

本书十分详尽地介绍了代码逆向分析的核心原理。作者在Ahnlab 研究所工作多年,书中不仅包括其以此经验为基础亲自编写的大量代码,还包含了逆向工程研究人员必须了解的各种技术和技巧。彻底理解并切实掌握逆向工程这门技术,就能在众多IT 相关领域进行拓展运用,这本书就是通向逆向工程大门的捷径。 想成为逆向工程研究员的读者或正在从事逆向开发工作的开发人员一定会通过本书获得很大帮助。同时,想成为安全领域......一起来看看 《逆向工程核心原理》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换