m3u8

package module
v0.0.0-...-ec5eab3 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2022 License: MIT Imports: 17 Imported by: 0

README

OliveM3u8

GoDoc

OliveM3u8 is a golang library which downloads m3u8 video streams.

API Guide

package main

import (
	"github.com/go-olive/m3u8"
)

func main() {
	p := m3u8.NewParser(&m3u8.Config{
		// m3u8 url
		Url: "https://video/index.m3u8",
		// video name
		Out: "video",
		// video directory
		Dir: "/",
	})
	p.Parse()
}

Credits

This project is inspired by m3u8-downloader

Documentation

Index

Constants

View Source
const (
	// HEAD_TIMEOUT 请求头超时时间
	HEAD_TIMEOUT = 10 * time.Second
	// PROGRESS_WIDTH 进度条长度
	PROGRESS_WIDTH = 20
	// TS_NAME_TEMPLATE ts视频片段命名规则
	TS_NAME_TEMPLATE = "%05d.ts"
)

Variables

View Source
var DefaultConfig = &Config{
	Url:    "",
	Num:    16,
	Host:   "apiv1",
	Out:    "movie",
	Cookie: "",
	Safe:   0,
	Dir:    "",
}

Functions

func AesDecrypt

func AesDecrypt(crypted, key []byte, ivs ...[]byte) ([]byte, error)

func AesEncrypt

func AesEncrypt(origData, key []byte, ivs ...[]byte) ([]byte, error)

func DrawProgressBar

func DrawProgressBar(prefix string, proportion float32, width int, suffix ...string)

进度条

func PKCS7Padding

func PKCS7Padding(ciphertext []byte, blockSize int) []byte

func PKCS7UnPadding

func PKCS7UnPadding(origData []byte) []byte

func Run

func Run(c *Config)

Types

type Config

type Config struct {
	// m3u8下载地址(http(s)://url/xx/xx/index.m3u8)
	Url string
	// 下载线程数
	Num int
	// 设置getHost的方式(apiv1: `http(s):// + url.Host + filepath.Dir(url.Path)`; apiv2: `http(s)://+ u.Host`
	Host string
	// 自定义文件名(默认为movie)
	Out string
	// 自定义请求 cookie
	Cookie string
	// 是否允许不安全的请求(默认为0)
	Safe int
	// 文件保存路径(默认为当前路径)
	Dir string
}

type Parser

type Parser struct {
	Config *Config
}

func NewParser

func NewParser(c *Config) *Parser

func (*Parser) Parse

func (p *Parser) Parse()

type TsInfo

type TsInfo struct {
	Name string
	Url  string
}

TsInfo 用于保存 ts 文件的下载地址和文件名

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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