hlsdl

package module
v0.0.0-...-87e242e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2020 License: GPL-3.0 Imports: 18 Imported by: 0

README

HLS downloader

This is a library and application to download an HLS video from a m3u8 file. All segments will be downloaded individually and then concatenated into a single TS file. The default file name is video.ts.

Features
  • Concurrent download segments with multiple HTTP connections
  • Decrypt HLS encoded segments
  • Display downloading progress bar
Limitations
  • Master playlists are not supported (playlists which point to other playlists)
  • Fragmented MP4 (fMP4) is not supported (only MPEG-TS)
  • Playlists with the EXT-X-MAP tag are not supported

Library usage

Get the library:

go get github.com/maxerenberg/hlsdl

Sample:

package main

import (
	"io"
	"os"

	"github.com/maxerenberg/hlsdl"
)

func main() {
	url := "https://bitdash-a.akamaihd.net/content/sintel/hls/video/1500kbit.m3u8"
	reader, err := hlsdl.Download(url)
	if err != nil {
		panic(err)
	}
	file, _ := os.Create("video.ts")
	io.Copy(file, reader)
	file.Close()
}

CLI Installation

go get -u -v github.com/maxerenberg/hlsdl/cmd/hlsdl

The command hlsdl will now be available in your $GOBIN directory.

To see all options, run hlsdl --help.

Example usage
$ hlsdl "https://bitdash-a.akamaihd.net/content/sintel/hls/video/1500kbit.m3u8"

You can also specify custom HTTP headers:

$ hlsdl -H "Accept-Language: en-US,en;q=0.5" \
	"https://bitdash-a.akamaihd.net/content/sintel/hls/video/1500kbit.m3u8"

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearCachedKeys

func ClearCachedKeys()

func DisableDebugMessages

func DisableDebugMessages()

func Download

func Download(m3u8url string) (res io.Reader, err error)

convenience function for downloading video with default parameters

func EnableDebugMessages

func EnableDebugMessages()

Types

type Client

type Client struct {
	// number of concurrent NumWorkers
	NumWorkers int
	// whether to enable a TUI progress bar
	EnableBar bool
	// additional HTTP Headers when making requests
	Headers map[string]string
	// contains filtered or unexported fields
}

func (*Client) Do

func (client *Client) Do(m3u8url string) (reader io.Reader, err error)

Do downloads an HLS video from a Request containing the URL of an M3U8 file. The data is returned in an io.Reader.

func (*Client) Stop

func (client *Client) Stop()

Stops all the workers

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL