From 719cf4b3964463b7c2d7ae8e4dee0929de3949fb Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Jacquier <15922119+pierre-emmanuelJ@users.noreply.github.com> Date: Sat, 25 Jan 2020 14:35:38 +0000 Subject: [PATCH] Add uuid to file cache path Signed-off-by: Pierre-Emmanuel Jacquier <15922119+pierre-emmanuelJ@users.noreply.github.com> fixup! Add uuid to file cache path Signed-off-by: Pierre-Emmanuel Jacquier <15922119+pierre-emmanuelJ@users.noreply.github.com> --- go.mod | 3 +- go.sum | 3 + pkg/server/xtreamHandles.go | 5 +- vendor/github.com/grafov/m3u8/.drone.yml | 13 - vendor/github.com/grafov/m3u8/.gitignore | 22 - vendor/github.com/grafov/m3u8/.travis.yml | 19 - vendor/github.com/grafov/m3u8/AUTHORS | 24 - vendor/github.com/grafov/m3u8/Gomfile | 3 - vendor/github.com/grafov/m3u8/LICENSE | 29 - vendor/github.com/grafov/m3u8/M3U8.md | 96 -- vendor/github.com/grafov/m3u8/README.md | 148 --- vendor/github.com/grafov/m3u8/doc.go | 57 -- vendor/github.com/grafov/m3u8/go.mod | 3 - vendor/github.com/grafov/m3u8/nut.json | 18 - vendor/github.com/grafov/m3u8/reader.go | 846 ----------------- vendor/github.com/grafov/m3u8/structure.go | 332 ------- vendor/github.com/grafov/m3u8/writer.go | 895 ------------------ vendor/github.com/satori/go.uuid/.travis.yml | 23 + vendor/github.com/satori/go.uuid/LICENSE | 20 + vendor/github.com/satori/go.uuid/README.md | 65 ++ vendor/github.com/satori/go.uuid/codec.go | 206 ++++ vendor/github.com/satori/go.uuid/generator.go | 239 +++++ vendor/github.com/satori/go.uuid/sql.go | 78 ++ vendor/github.com/satori/go.uuid/uuid.go | 161 ++++ vendor/modules.txt | 4 +- 25 files changed, 801 insertions(+), 2511 deletions(-) delete mode 100644 vendor/github.com/grafov/m3u8/.drone.yml delete mode 100644 vendor/github.com/grafov/m3u8/.gitignore delete mode 100644 vendor/github.com/grafov/m3u8/.travis.yml delete mode 100644 vendor/github.com/grafov/m3u8/AUTHORS delete mode 100644 vendor/github.com/grafov/m3u8/Gomfile delete mode 100644 vendor/github.com/grafov/m3u8/LICENSE delete mode 100644 vendor/github.com/grafov/m3u8/M3U8.md delete mode 100644 vendor/github.com/grafov/m3u8/README.md delete mode 100644 vendor/github.com/grafov/m3u8/doc.go delete mode 100644 vendor/github.com/grafov/m3u8/go.mod delete mode 100644 vendor/github.com/grafov/m3u8/nut.json delete mode 100644 vendor/github.com/grafov/m3u8/reader.go delete mode 100644 vendor/github.com/grafov/m3u8/structure.go delete mode 100644 vendor/github.com/grafov/m3u8/writer.go create mode 100644 vendor/github.com/satori/go.uuid/.travis.yml create mode 100644 vendor/github.com/satori/go.uuid/LICENSE create mode 100644 vendor/github.com/satori/go.uuid/README.md create mode 100644 vendor/github.com/satori/go.uuid/codec.go create mode 100644 vendor/github.com/satori/go.uuid/generator.go create mode 100644 vendor/github.com/satori/go.uuid/sql.go create mode 100644 vendor/github.com/satori/go.uuid/uuid.go diff --git a/go.mod b/go.mod index a63fea7..9bb3ae8 100644 --- a/go.mod +++ b/go.mod @@ -3,11 +3,12 @@ module github.com/pierre-emmanuelJ/iptv-proxy require ( github.com/gin-contrib/cors v0.0.0-20190226021855-50921afdc5c1 github.com/gin-gonic/gin v1.3.0 - github.com/grafov/m3u8 v0.11.1 + github.com/grafov/m3u8 v0.11.1 // indirect github.com/inconshreveable/mousetrap v1.0.0 // indirect github.com/jamesnetherton/m3u v0.1.1-0.20180924175816-16741c7f081c github.com/mitchellh/go-homedir v1.1.0 github.com/onsi/gomega v1.7.1 // indirect + github.com/satori/go.uuid v1.2.0 github.com/spf13/cobra v0.0.3 github.com/spf13/viper v1.3.1 github.com/tellytv/go.xtream-codes v0.0.0-20190427212115-45e8162ba888 diff --git a/go.sum b/go.sum index 24a0935..f02f7a5 100644 --- a/go.sum +++ b/go.sum @@ -46,6 +46,8 @@ github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181 github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= +github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8= @@ -81,6 +83,7 @@ golang.org/x/sys v0.0.0-20181228144115-9a3f9b0469bb h1:pf3XwC90UUdNPYWZdFjhGBE7D golang.org/x/sys v0.0.0-20181228144115-9a3f9b0469bb/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= diff --git a/pkg/server/xtreamHandles.go b/pkg/server/xtreamHandles.go index 3ceb095..ec7b315 100644 --- a/pkg/server/xtreamHandles.go +++ b/pkg/server/xtreamHandles.go @@ -1,7 +1,6 @@ package server import ( - "encoding/base64" "errors" "fmt" "io/ioutil" @@ -17,6 +16,7 @@ import ( "github.com/gin-gonic/gin" "github.com/jamesnetherton/m3u" xtreamapi "github.com/pierre-emmanuelJ/iptv-proxy/pkg/xtream-proxy" + uuid "github.com/satori/go.uuid" ) type cacheMeta struct { @@ -42,8 +42,7 @@ func (c *Config) cacheXtreamM3u(m3uURL *url.URL) error { tmp := c.playlist c.playlist = &playlist - filename := base64.StdEncoding.EncodeToString([]byte(m3uURL.String())) - path := filepath.Join("/tmp", filename) + path := filepath.Join("/tmp", uuid.NewV4().String()+".iptv-proxy") f, err := os.Create(path) if err != nil { return err diff --git a/vendor/github.com/grafov/m3u8/.drone.yml b/vendor/github.com/grafov/m3u8/.drone.yml deleted file mode 100644 index 34fe10d..0000000 --- a/vendor/github.com/grafov/m3u8/.drone.yml +++ /dev/null @@ -1,13 +0,0 @@ -kind: pipeline -name: default - -workspace: - base: /go - path: src/github.com/grafov/m3u8 - -steps: -- name: test - image: golang - commands: - - go get - - go test diff --git a/vendor/github.com/grafov/m3u8/.gitignore b/vendor/github.com/grafov/m3u8/.gitignore deleted file mode 100644 index 7127dbb..0000000 --- a/vendor/github.com/grafov/m3u8/.gitignore +++ /dev/null @@ -1,22 +0,0 @@ -# Compiled Object files, Static and Dynamic libs (Shared Objects) -*.o -*.a -*.so -*~ - -# Folders -_obj -_test - -# Architecture specific extensions/prefixes -*.[568vq] -[568vq].out - -*.cgo1.go -*.cgo2.c -_cgo_defun.c -_cgo_gotypes.go -_cgo_export.* - -_testmain.go - diff --git a/vendor/github.com/grafov/m3u8/.travis.yml b/vendor/github.com/grafov/m3u8/.travis.yml deleted file mode 100644 index fa38729..0000000 --- a/vendor/github.com/grafov/m3u8/.travis.yml +++ /dev/null @@ -1,19 +0,0 @@ -language: go - -# Versions of go that are explicitly supported. -go: - - 1.6.3 - - 1.7.3 - - 1.8.x - - tip - -# Required for coverage. -before_install: - - go get golang.org/x/tools/cmd/cover - - go get github.com/mattn/goveralls - -script: - - go build -a -v ./... - - diff <(gofmt -d .) <("") - - go test -v -covermode=count -coverprofile=coverage.out - - $GOPATH/bin/goveralls -coverprofile=coverage.out -service=travis-ci diff --git a/vendor/github.com/grafov/m3u8/AUTHORS b/vendor/github.com/grafov/m3u8/AUTHORS deleted file mode 100644 index c873bb9..0000000 --- a/vendor/github.com/grafov/m3u8/AUTHORS +++ /dev/null @@ -1,24 +0,0 @@ -There are many persons contribute their code (including small patches) -to the project. They listed below in an alphabetical order: - -- Alexander I.Grafov -- Andrew Sinclair -- Andrey Chernov -- Bradley Falzon -- Denys Smirnov -- Fabrizio (Misto) Milo -- Hori Ryota -- Jamie Stackhouse -- Julian Cooper -- Kz26 -- Lei Gao -- Makombo -- Michael Bow -- Scott Kidder -- Vishal Kumar Tuniki -- Yevgen Flerko -- Zac Shenker -- Matthew Neil [mjneil](https://github.com/mjneil) - -If you want to be added to this list (or removed for any reason) -just open an issue about it. diff --git a/vendor/github.com/grafov/m3u8/Gomfile b/vendor/github.com/grafov/m3u8/Gomfile deleted file mode 100644 index 99fddf0..0000000 --- a/vendor/github.com/grafov/m3u8/Gomfile +++ /dev/null @@ -1,3 +0,0 @@ -group :development do - gom 'github.com/grafov/m3u8', :goos => [:linux] -end \ No newline at end of file diff --git a/vendor/github.com/grafov/m3u8/LICENSE b/vendor/github.com/grafov/m3u8/LICENSE deleted file mode 100644 index 98f5fdf..0000000 --- a/vendor/github.com/grafov/m3u8/LICENSE +++ /dev/null @@ -1,29 +0,0 @@ -Copyright (c) 2013-2016 Alexander I.Grafov -Copyright (c) 2013-2016 The Project Developers. - -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - Neither the name of the author nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/grafov/m3u8/M3U8.md b/vendor/github.com/grafov/m3u8/M3U8.md deleted file mode 100644 index bc02f0e..0000000 --- a/vendor/github.com/grafov/m3u8/M3U8.md +++ /dev/null @@ -1,96 +0,0 @@ - - - - -M3U8 tags cheatsheet -==================== - -The table above describes tags of M3U8, their occurence in playlists of different types and their support status -in the go-library. - -Legend for playlist types: - -* MAS is master playlist -* MED is media playlist - - - - -| Tag | Occured in | Proto ver | In Go lib since | -|---|---|---|---| -| EXT-X-ALLOW-CACHE | MED | 1 | 0.1 | -| EXT-X-BYTERANGE | MED | 4 | 0.1 | -| EXT-X-DISCONTINUITY | MED | 1 | 0.2 | -| EXT-X-DISCONTINUITY-SEQUENCE | MED | 6 | | -| EXT-X-ENDLIST | MED | 1 | 0.1 | -| EXT-X-I-FRAME-STREAM-INF | MAS | 4 | 0.3 | -| EXT-X-I-FRAMES-ONLY | MED | 4 | 0.3 | -| EXT-X-INDEPENDENT-SEGMENTS | MAS | 6 | | -| EXT-X-KEY | MED | 1 | 0.1 | -| EXT-X-MAP | MED | 5 | 0.3 | -| EXT-X-MEDIA | MAS | 4 | 0.1 | -| EXT-X-MEDIA-SEQUENCE | MED | 1 | 0.1 | -| EXT-X-PLAYLIST-TYPE | MED | 3 | 0.2 | -| EXT-X-PROGRAM-DATE-TIME | MED | 1 | 0.2 | -| EXT-X-SESSION-DATA | MAS | 7 | | -| EXT-X-START | MAS | 6 | | -| EXT-X-STREAM-INF | MAS | 1 | 0.1 | -| EXT-X-TARGETDURATION | MED | 1 | 0.1 | -| EXT-X-VERSION | MAS | 2 | 0.1 | -| EXTINF | MED | 1 | 0.1 | -| EXTM3U | MAS,MED | 1 | 0.1 | - - - - - -IETF drafts notes ------------------ - -[IETF](http://ietf.org) document currently in Draft status. Different versions of the document introduce changes of HLS protocol playlist formats. Latest version of the HLS protocol is version 7. - -http://tools.ietf.org/html/draft-pantos-http-live-streaming - -* Version 1 of the HLS protocol described in draft00-draft02. -* Version 2 of the HLS protocol described in draft03-draft04. -* Version 3 of the HLS protocol described in draft05-draft06. -* Version 4 of the HLS protocol described in draft07-draft08. -* Version 5 of the HLS protocol described in draft09-draft11. -* Version 6 of the HLS protocol described in draft12-draft13. -* Version 7 of the HLS protocol described in draft14-draft19. diff --git a/vendor/github.com/grafov/m3u8/README.md b/vendor/github.com/grafov/m3u8/README.md deleted file mode 100644 index a2c6634..0000000 --- a/vendor/github.com/grafov/m3u8/README.md +++ /dev/null @@ -1,148 +0,0 @@ - -M3U8 -==== - -This is the most complete opensource library for parsing and generating of M3U8 playlists -used in HTTP Live Streaming (Apple HLS) for internet video translations. - -M3U8 is simple text format and parsing library for it must be simple too. It does not offer -ways to play HLS or handle playlists over HTTP. So library features are: - -* Support HLS specs up to version 5 of the protocol. -* Parsing and generation of master-playlists and media-playlists. -* Autodetect input streams as master or media playlists. -* Offer structures for keeping playlists metadata. -* Encryption keys support for use with DRM systems like [Verimatrix](http://verimatrix.com) etc. -* Support for non standard [Google Widevine](http://www.widevine.com) tags. - -The library covered by BSD 3-clause license. See [LICENSE](LICENSE) for the full text. -Versions 0.8 and below was covered by GPL v3. License was changed from the version 0.9 and upper. - -See the list of the library authors at [AUTHORS](AUTHORS) file. - -Install -------- - - go get github.com/grafov/m3u8 - -or get releases from https://github.com/grafov/m3u8/releases - -Documentation [![Go Walker](http://gowalker.org/api/v1/badge)](http://gowalker.org/github.com/grafov/m3u8) -------------- - -Package online documentation (examples included) available at: - -* http://gowalker.org/github.com/grafov/m3u8 -* http://godoc.org/github.com/grafov/m3u8 - -Supported by the HLS protocol tags and their library support explained in [M3U8 cheatsheet](M3U8.md). - -Examples --------- - -Parse playlist: - -```go - f, err := os.Open("playlist.m3u8") - if err != nil { - panic(err) - } - p, listType, err := m3u8.DecodeFrom(bufio.NewReader(f), true) - if err != nil { - panic(err) - } - switch listType { - case m3u8.MEDIA: - mediapl := p.(*m3u8.MediaPlaylist) - fmt.Printf("%+v\n", mediapl) - case m3u8.MASTER: - masterpl := p.(*m3u8.MasterPlaylist) - fmt.Printf("%+v\n", masterpl) - } -``` - -Then you get filled with parsed data structures. For master playlists you get ``Master`` struct with slice consists of pointers to ``Variant`` structures (which represent playlists to each bitrate). -For media playlist parser returns ``MediaPlaylist`` structure with slice of ``Segments``. Each segment is of ``MediaSegment`` type. -See ``structure.go`` or full documentation (link below). - -You may use API methods to fill structures or create them manually to generate playlists. Example of media playlist generation: - -```go - p, e := m3u8.NewMediaPlaylist(3, 10) // with window of size 3 and capacity 10 - if e != nil { - panic(fmt.Sprintf("Creating of media playlist failed: %s", e)) - } - for i := 0; i < 5; i++ { - e = p.Append(fmt.Sprintf("test%d.ts", i), 6.0, "") - if e != nil { - panic(fmt.Sprintf("Add segment #%d to a media playlist failed: %s", i, e)) - } - } - fmt.Println(p.Encode().String()) -``` - -Custom Tags ------------ - -M3U8 supports parsing and writing of custom tags. You must implement both the `CustomTag` and `CustomDecoder` interface for each custom tag that may be encountered in the playlist. Look at the template files in `example/template/` for examples on parsing custom playlist and segment tags. - -Library structure ------------------ - -Library has compact code and bundled in three files: - -* `structure.go` — declares all structures related to playlists and their properties -* `reader.go` — playlist parser methods -* `writer.go` — playlist generator methods - -Each file has own test suite placed in `*_test.go` accordingly. - -Related links -------------- - -* http://en.wikipedia.org/wiki/M3U -* http://en.wikipedia.org/wiki/HTTP_Live_Streaming -* http://gonze.com/playlists/playlist-format-survey.html - -Library usage -------------- - -This library was successfully used in streaming software developed for company where I worked several -years ago. It was tested then in generating of VOD and Live streams and parsing of Widevine Live streams. -Also the library used in opensource software so you may look at these apps for usage examples: - -* [HLS downloader](https://github.com/kz26/gohls) -* [Another HLS downloader](https://github.com/Makombo/hlsdownloader) -* [HLS utils](https://github.com/archsh/hls-utils) -* [M3U8 reader](https://github.com/jeongmin/m3u8-reader) - -M3U8 parsing/generation in other languages ------------------------------------------- - -* https://github.com/globocom/m3u8 in Python -* https://github.com/zencoder/m3uzi in Ruby -* https://github.com/Jeanvf/M3U8Paser in Objective C -* https://github.com/tedconf/node-m3u8 in Javascript -* http://sourceforge.net/projects/m3u8parser/ in Java -* https://github.com/karlll/erlm3u8 in Erlang - -Project status [![Go Report Card](https://goreportcard.com/badge/grafov/m3u8)](https://goreportcard.com/report/grafov/m3u8) --------------- - -[![Build Status](https://travis-ci.org/grafov/m3u8.png?branch=master)](https://travis-ci.org/grafov/m3u8) [![Build Status](https://cloud.drone.io/api/badges/grafov/m3u8/status.svg)](https://cloud.drone.io/grafov/m3u8) [![Coverage Status](https://coveralls.io/repos/github/grafov/m3u8/badge.svg?branch=master)](https://coveralls.io/github/grafov/m3u8?branch=master) - -Project maintainers: - -* Lei Gao @leikao -* Bradley Falzon @bradleyfalzon -* Alexander Grafov @grafov - -State of code coverage: https://gocover.io/github.com/grafov/m3u8 - -Roadmap -------- - -To version 1.0: - -* Support all M3U8 tags up to latest version of specs. -* Code coverage by unit tests up to 90% diff --git a/vendor/github.com/grafov/m3u8/doc.go b/vendor/github.com/grafov/m3u8/doc.go deleted file mode 100644 index 775024e..0000000 --- a/vendor/github.com/grafov/m3u8/doc.go +++ /dev/null @@ -1,57 +0,0 @@ -/* Package M3U8 is parser & generator library for Apple HLS. - -This is a most complete opensource library for parsing and generating of M3U8 playlists used in HTTP Live Streaming (Apple HLS) for internet video translations. - -M3U8 is simple text format and parsing library for it must be simple too. It did not offer ways to play HLS or handle playlists over HTTP. Library features are: - - * Support HLS specs up to version 5 of the protocol. - * Parsing and generation of master-playlists and media-playlists. - * Autodetect input streams as master or media playlists. - * Offer structures for keeping playlists metadata. - * Encryption keys support for usage with DRM systems like Verimatrix (http://verimatrix.com) etc. - * Support for non standard Google Widevine (http://www.widevine.com) tags. - -Library coded accordingly with IETF draft http://tools.ietf.org/html/draft-pantos-http-live-streaming - -Examples of usage may be found in *_test.go files of a package. Also see below some simple examples. - -Create simple media playlist with sliding window of 3 segments and maximum of 50 segments. - - p, e := NewMediaPlaylist(3, 50) - if e != nil { - panic(fmt.Sprintf("Create media playlist failed: %s", e)) - } - for i := 0; i < 5; i++ { - e = p.Add(fmt.Sprintf("test%d.ts", i), 5.0) - if e != nil { - panic(fmt.Sprintf("Add segment #%d to a media playlist failed: %s", i, e)) - } - } - fmt.Println(p.Encode(true).String()) - -We add 5 testX.ts segments to playlist then encode it to M3U8 format and convert to string. - -Next example shows parsing of master playlist: - - f, err := os.Open("sample-playlists/master.m3u8") - if err != nil { - fmt.Println(err) - } - p := NewMasterPlaylist() - err = p.DecodeFrom(bufio.NewReader(f), false) - if err != nil { - fmt.Println(err) - } - - fmt.Printf("Playlist object: %+v\n", p) - -We are open playlist from the file and parse it as master playlist. - -*/ -package m3u8 - -// Copyright 2013-2017 The Project Developers. -// See the AUTHORS and LICENSE files at the top-level directory of this distribution -// and at https://github.com/grafov/m3u8/ - -// ॐ तारे तुत्तारे तुरे स्व diff --git a/vendor/github.com/grafov/m3u8/go.mod b/vendor/github.com/grafov/m3u8/go.mod deleted file mode 100644 index 0e2a414..0000000 --- a/vendor/github.com/grafov/m3u8/go.mod +++ /dev/null @@ -1,3 +0,0 @@ -module github.com/grafov/m3u8 - -go 1.12 diff --git a/vendor/github.com/grafov/m3u8/nut.json b/vendor/github.com/grafov/m3u8/nut.json deleted file mode 100644 index 2468932..0000000 --- a/vendor/github.com/grafov/m3u8/nut.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "Version": "0.1.0", - "Vendor": "grafov", - "Authors": [ - { - "FullName": "Alexander I.Grafov", - "Email": "grafov@gmail.com" - } - ], - "ExtraFiles": [ - "README.md", - "M3U8.md", - "LICENSE", - "TODO.org", - "sample-playlists" - ], - "Homepage": "http://github.com/grafov/m3u8" -} diff --git a/vendor/github.com/grafov/m3u8/reader.go b/vendor/github.com/grafov/m3u8/reader.go deleted file mode 100644 index 8613476..0000000 --- a/vendor/github.com/grafov/m3u8/reader.go +++ /dev/null @@ -1,846 +0,0 @@ -package m3u8 - -/* - Part of M3U8 parser & generator library. - This file defines functions related to playlist parsing. - - Copyright 2013-2017 The Project Developers. - See the AUTHORS and LICENSE files at the top-level directory of this distribution - and at https://github.com/grafov/m3u8/ - - ॐ तारे तुत्तारे तुरे स्व -*/ - -import ( - "bytes" - "errors" - "fmt" - "io" - "regexp" - "strconv" - "strings" - "time" -) - -var reKeyValue = regexp.MustCompile(`([a-zA-Z0-9_-]+)=("[^"]+"|[^",]+)`) - -// Allow globally apply and/or override Time Parser function. -// Available variants: -// * FullTimeParse - implements full featured ISO/IEC 8601:2004 -// * StrictTimeParse - implements only RFC3339 Nanoseconds format -var TimeParse func(value string) (time.Time, error) = FullTimeParse - -// Decode parses a master playlist passed from the buffer. If `strict` -// parameter is true then it returns first syntax error. -func (p *MasterPlaylist) Decode(data bytes.Buffer, strict bool) error { - return p.decode(&data, strict) -} - -// DecodeFrom parses a master playlist passed from the io.Reader -// stream. If `strict` parameter is true then it returns first syntax -// error. -func (p *MasterPlaylist) DecodeFrom(reader io.Reader, strict bool) error { - buf := new(bytes.Buffer) - _, err := buf.ReadFrom(reader) - if err != nil { - return err - } - return p.decode(buf, strict) -} - -// WithCustomDecoders adds custom tag decoders to the master playlist for decoding -func (p *MasterPlaylist) WithCustomDecoders(customDecoders []CustomDecoder) Playlist { - // Create the map if it doesn't already exist - if p.Custom == nil { - p.Custom = make(map[string]CustomTag) - } - - p.customDecoders = customDecoders - - return p -} - -// Parse master playlist. Internal function. -func (p *MasterPlaylist) decode(buf *bytes.Buffer, strict bool) error { - var eof bool - - state := new(decodingState) - - for !eof { - line, err := buf.ReadString('\n') - if err == io.EOF { - eof = true - } else if err != nil { - break - } - err = decodeLineOfMasterPlaylist(p, state, line, strict) - if strict && err != nil { - return err - } - } - if strict && !state.m3u { - return errors.New("#EXTM3U absent") - } - return nil -} - -// Decode parses a media playlist passed from the buffer. If `strict` -// parameter is true then return first syntax error. -func (p *MediaPlaylist) Decode(data bytes.Buffer, strict bool) error { - return p.decode(&data, strict) -} - -// DecodeFrom parses a media playlist passed from the io.Reader -// stream. If `strict` parameter is true then it returns first syntax -// error. -func (p *MediaPlaylist) DecodeFrom(reader io.Reader, strict bool) error { - buf := new(bytes.Buffer) - _, err := buf.ReadFrom(reader) - if err != nil { - return err - } - return p.decode(buf, strict) -} - -// WithCustomDecoders adds custom tag decoders to the media playlist for decoding -func (p *MediaPlaylist) WithCustomDecoders(customDecoders []CustomDecoder) Playlist { - // Create the map if it doesn't already exist - if p.Custom == nil { - p.Custom = make(map[string]CustomTag) - } - - p.customDecoders = customDecoders - - return p -} - -func (p *MediaPlaylist) decode(buf *bytes.Buffer, strict bool) error { - var eof bool - var line string - var err error - - state := new(decodingState) - wv := new(WV) - - for !eof { - if line, err = buf.ReadString('\n'); err == io.EOF { - eof = true - } else if err != nil { - break - } - - err = decodeLineOfMediaPlaylist(p, wv, state, line, strict) - if strict && err != nil { - return err - } - - } - if state.tagWV { - p.WV = wv - } - if strict && !state.m3u { - return errors.New("#EXTM3U absent") - } - return nil -} - -// Decode detects type of playlist and decodes it. It accepts bytes -// buffer as input. -func Decode(data bytes.Buffer, strict bool) (Playlist, ListType, error) { - return decode(&data, strict, nil) -} - -// DecodeFrom detects type of playlist and decodes it. It accepts data -// conformed with io.Reader. -func DecodeFrom(reader io.Reader, strict bool) (Playlist, ListType, error) { - buf := new(bytes.Buffer) - _, err := buf.ReadFrom(reader) - if err != nil { - return nil, 0, err - } - return decode(buf, strict, nil) -} - -// DecodeWith detects the type of playlist and decodes it. It accepts either bytes.Buffer -// or io.Reader as input. Any custom decoders provided will be used during decoding. -func DecodeWith(input interface{}, strict bool, customDecoders []CustomDecoder) (Playlist, ListType, error) { - switch v := input.(type) { - case bytes.Buffer: - return decode(&v, strict, customDecoders) - case io.Reader: - buf := new(bytes.Buffer) - _, err := buf.ReadFrom(v) - if err != nil { - return nil, 0, err - } - return decode(buf, strict, customDecoders) - default: - return nil, 0, errors.New("input must be bytes.Buffer or io.Reader type") - } -} - -// Detect playlist type and decode it. May be used as decoder for both -// master and media playlists. -func decode(buf *bytes.Buffer, strict bool, customDecoders []CustomDecoder) (Playlist, ListType, error) { - var eof bool - var line string - var master *MasterPlaylist - var media *MediaPlaylist - var listType ListType - var err error - - state := new(decodingState) - wv := new(WV) - - master = NewMasterPlaylist() - media, err = NewMediaPlaylist(8, 1024) // Winsize for VoD will become 0, capacity auto extends - if err != nil { - return nil, 0, fmt.Errorf("Create media playlist failed: %s", err) - } - - // If we have custom tags to parse - if customDecoders != nil { - media = media.WithCustomDecoders(customDecoders).(*MediaPlaylist) - master = master.WithCustomDecoders(customDecoders).(*MasterPlaylist) - state.custom = make(map[string]CustomTag) - } - - for !eof { - if line, err = buf.ReadString('\n'); err == io.EOF { - eof = true - } else if err != nil { - break - } - - // fixes the issues https://github.com/grafov/m3u8/issues/25 - // TODO: the same should be done in decode functions of both Master- and MediaPlaylists - // so some DRYing would be needed. - if len(line) < 1 || line == "\r" { - continue - } - - err = decodeLineOfMasterPlaylist(master, state, line, strict) - if strict && err != nil { - return master, state.listType, err - } - - err = decodeLineOfMediaPlaylist(media, wv, state, line, strict) - if strict && err != nil { - return media, state.listType, err - } - - } - if state.listType == MEDIA && state.tagWV { - media.WV = wv - } - - if strict && !state.m3u { - return nil, listType, errors.New("#EXTM3U absent") - } - - switch state.listType { - case MASTER: - return master, MASTER, nil - case MEDIA: - if media.Closed || media.MediaType == EVENT { - // VoD and Event's should show the entire playlist - media.SetWinSize(0) - } - return media, MEDIA, nil - } - return nil, state.listType, errors.New("Can't detect playlist type") -} - -// DecodeAttributeList turns an attribute list into a key, value map. You should trim -// any characters not part of the attribute list, such as the tag and ':'. -func DecodeAttributeList(line string) map[string]string { - return decodeParamsLine(line) -} - -func decodeParamsLine(line string) map[string]string { - out := make(map[string]string) - for _, kv := range reKeyValue.FindAllStringSubmatch(line, -1) { - k, v := kv[1], kv[2] - out[k] = strings.Trim(v, ` "`) - } - return out -} - -// Parse one line of master playlist. -func decodeLineOfMasterPlaylist(p *MasterPlaylist, state *decodingState, line string, strict bool) error { - var err error - - line = strings.TrimSpace(line) - - // check for custom tags first to allow custom parsing of existing tags - if p.Custom != nil { - for _, v := range p.customDecoders { - if strings.HasPrefix(line, v.TagName()) { - t, err := v.Decode(line) - - if strict && err != nil { - return err - } - - p.Custom[t.TagName()] = t - } - } - } - - switch { - case line == "#EXTM3U": // start tag first - state.m3u = true - case strings.HasPrefix(line, "#EXT-X-VERSION:"): // version tag - state.listType = MASTER - _, err = fmt.Sscanf(line, "#EXT-X-VERSION:%d", &p.ver) - if strict && err != nil { - return err - } - case line == "#EXT-X-INDEPENDENT-SEGMENTS": - p.SetIndependentSegments(true) - case strings.HasPrefix(line, "#EXT-X-MEDIA:"): - var alt Alternative - state.listType = MASTER - for k, v := range decodeParamsLine(line[13:]) { - switch k { - case "TYPE": - alt.Type = v - case "GROUP-ID": - alt.GroupId = v - case "LANGUAGE": - alt.Language = v - case "NAME": - alt.Name = v - case "DEFAULT": - if strings.ToUpper(v) == "YES" { - alt.Default = true - } else if strings.ToUpper(v) == "NO" { - alt.Default = false - } else if strict { - return errors.New("value must be YES or NO") - } - case "AUTOSELECT": - alt.Autoselect = v - case "FORCED": - alt.Forced = v - case "CHARACTERISTICS": - alt.Characteristics = v - case "SUBTITLES": - alt.Subtitles = v - case "URI": - alt.URI = v - } - } - state.alternatives = append(state.alternatives, &alt) - case !state.tagStreamInf && strings.HasPrefix(line, "#EXT-X-STREAM-INF:"): - state.tagStreamInf = true - state.listType = MASTER - state.variant = new(Variant) - if len(state.alternatives) > 0 { - state.variant.Alternatives = state.alternatives - state.alternatives = nil - } - p.Variants = append(p.Variants, state.variant) - for k, v := range decodeParamsLine(line[18:]) { - switch k { - case "PROGRAM-ID": - var val int - val, err = strconv.Atoi(v) - if strict && err != nil { - return err - } - state.variant.ProgramId = uint32(val) - case "BANDWIDTH": - var val int - val, err = strconv.Atoi(v) - if strict && err != nil { - return err - } - state.variant.Bandwidth = uint32(val) - case "CODECS": - state.variant.Codecs = v - case "RESOLUTION": - state.variant.Resolution = v - case "AUDIO": - state.variant.Audio = v - case "VIDEO": - state.variant.Video = v - case "SUBTITLES": - state.variant.Subtitles = v - case "CLOSED-CAPTIONS": - state.variant.Captions = v - case "NAME": - state.variant.Name = v - case "AVERAGE-BANDWIDTH": - var val int - val, err = strconv.Atoi(v) - if strict && err != nil { - return err - } - state.variant.AverageBandwidth = uint32(val) - case "FRAME-RATE": - if state.variant.FrameRate, err = strconv.ParseFloat(v, 64); strict && err != nil { - return err - } - case "VIDEO-RANGE": - state.variant.VideoRange = v - case "HDCP-LEVEL": - state.variant.HDCPLevel = v - } - } - case state.tagStreamInf && !strings.HasPrefix(line, "#"): - state.tagStreamInf = false - state.variant.URI = line - case strings.HasPrefix(line, "#EXT-X-I-FRAME-STREAM-INF:"): - state.listType = MASTER - state.variant = new(Variant) - state.variant.Iframe = true - if len(state.alternatives) > 0 { - state.variant.Alternatives = state.alternatives - state.alternatives = nil - } - p.Variants = append(p.Variants, state.variant) - for k, v := range decodeParamsLine(line[26:]) { - switch k { - case "URI": - state.variant.URI = v - case "PROGRAM-ID": - var val int - val, err = strconv.Atoi(v) - if strict && err != nil { - return err - } - state.variant.ProgramId = uint32(val) - case "BANDWIDTH": - var val int - val, err = strconv.Atoi(v) - if strict && err != nil { - return err - } - state.variant.Bandwidth = uint32(val) - case "CODECS": - state.variant.Codecs = v - case "RESOLUTION": - state.variant.Resolution = v - case "AUDIO": - state.variant.Audio = v - case "VIDEO": - state.variant.Video = v - case "AVERAGE-BANDWIDTH": - var val int - val, err = strconv.Atoi(v) - if strict && err != nil { - return err - } - state.variant.AverageBandwidth = uint32(val) - case "VIDEO-RANGE": - state.variant.VideoRange = v - case "HDCP-LEVEL": - state.variant.HDCPLevel = v - } - } - case strings.HasPrefix(line, "#"): - // comments are ignored - } - return err -} - -// Parse one line of media playlist. -func decodeLineOfMediaPlaylist(p *MediaPlaylist, wv *WV, state *decodingState, line string, strict bool) error { - var err error - - line = strings.TrimSpace(line) - - // check for custom tags first to allow custom parsing of existing tags - if p.Custom != nil { - for _, v := range p.customDecoders { - if strings.HasPrefix(line, v.TagName()) { - t, err := v.Decode(line) - - if strict && err != nil { - return err - } - - if v.SegmentTag() { - state.tagCustom = true - state.custom[v.TagName()] = t - } else { - p.Custom[v.TagName()] = t - } - } - } - } - - switch { - case !state.tagInf && strings.HasPrefix(line, "#EXTINF:"): - state.tagInf = true - state.listType = MEDIA - sepIndex := strings.Index(line, ",") - if sepIndex == -1 { - if strict { - return fmt.Errorf("could not parse: %q", line) - } - sepIndex = len(line) - } - duration := line[8:sepIndex] - if len(duration) > 0 { - if state.duration, err = strconv.ParseFloat(duration, 64); strict && err != nil { - return fmt.Errorf("Duration parsing error: %s", err) - } - } - if len(line) > sepIndex { - state.title = line[sepIndex+1:] - } - case !strings.HasPrefix(line, "#"): - if state.tagInf { - err := p.Append(line, state.duration, state.title) - if err == ErrPlaylistFull { - // Extend playlist by doubling size, reset internal state, try again. - // If the second Append fails, the if err block will handle it. - // Retrying instead of being recursive was chosen as the state maybe - // modified non-idempotently. - p.Segments = append(p.Segments, make([]*MediaSegment, p.Count())...) - p.capacity = uint(len(p.Segments)) - p.tail = p.count - err = p.Append(line, state.duration, state.title) - } - // Check err for first or subsequent Append() - if err != nil { - return err - } - state.tagInf = false - } - if state.tagRange { - if err = p.SetRange(state.limit, state.offset); strict && err != nil { - return err - } - state.tagRange = false - } - if state.tagSCTE35 { - state.tagSCTE35 = false - if err = p.SetSCTE35(state.scte); strict && err != nil { - return err - } - } - if state.tagDiscontinuity { - state.tagDiscontinuity = false - if err = p.SetDiscontinuity(); strict && err != nil { - return err - } - } - if state.tagProgramDateTime && p.Count() > 0 { - state.tagProgramDateTime = false - if err = p.SetProgramDateTime(state.programDateTime); strict && err != nil { - return err - } - } - // If EXT-X-KEY appeared before reference to segment (EXTINF) then it linked to this segment - if state.tagKey { - p.Segments[p.last()].Key = &Key{state.xkey.Method, state.xkey.URI, state.xkey.IV, state.xkey.Keyformat, state.xkey.Keyformatversions} - // First EXT-X-KEY may appeared in the header of the playlist and linked to first segment - // but for convenient playlist generation it also linked as default playlist key - if p.Key == nil { - p.Key = state.xkey - } - state.tagKey = false - } - // If EXT-X-MAP appeared before reference to segment (EXTINF) then it linked to this segment - if state.tagMap { - p.Segments[p.last()].Map = &Map{state.xmap.URI, state.xmap.Limit, state.xmap.Offset} - // First EXT-X-MAP may appeared in the header of the playlist and linked to first segment - // but for convenient playlist generation it also linked as default playlist map - if p.Map == nil { - p.Map = state.xmap - } - state.tagMap = false - } - - // if segment custom tag appeared before EXTINF then it links to this segment - if state.tagCustom { - p.Segments[p.last()].Custom = state.custom - state.custom = make(map[string]CustomTag) - state.tagCustom = false - } - // start tag first - case line == "#EXTM3U": - state.m3u = true - case line == "#EXT-X-ENDLIST": - state.listType = MEDIA - p.Closed = true - case strings.HasPrefix(line, "#EXT-X-VERSION:"): - state.listType = MEDIA - if _, err = fmt.Sscanf(line, "#EXT-X-VERSION:%d", &p.ver); strict && err != nil { - return err - } - case strings.HasPrefix(line, "#EXT-X-TARGETDURATION:"): - state.listType = MEDIA - if _, err = fmt.Sscanf(line, "#EXT-X-TARGETDURATION:%f", &p.TargetDuration); strict && err != nil { - return err - } - case strings.HasPrefix(line, "#EXT-X-MEDIA-SEQUENCE:"): - state.listType = MEDIA - if _, err = fmt.Sscanf(line, "#EXT-X-MEDIA-SEQUENCE:%d", &p.SeqNo); strict && err != nil { - return err - } - case strings.HasPrefix(line, "#EXT-X-PLAYLIST-TYPE:"): - state.listType = MEDIA - var playlistType string - _, err = fmt.Sscanf(line, "#EXT-X-PLAYLIST-TYPE:%s", &playlistType) - if err != nil { - if strict { - return err - } - } else { - switch playlistType { - case "EVENT": - p.MediaType = EVENT - case "VOD": - p.MediaType = VOD - } - } - case strings.HasPrefix(line, "#EXT-X-DISCONTINUITY-SEQUENCE:"): - state.listType = MEDIA - if _, err = fmt.Sscanf(line, "#EXT-X-DISCONTINUITY-SEQUENCE:%d", &p.DiscontinuitySeq); strict && err != nil { - return err - } - case strings.HasPrefix(line, "#EXT-X-START:"): - state.listType = MEDIA - for k, v := range decodeParamsLine(line[13:]) { - switch k { - case "TIME-OFFSET": - st, err := strconv.ParseFloat(v, 64) - if err != nil { - return fmt.Errorf("Invalid TIME-OFFSET: %s: %v", v, err) - } - p.StartTime = st - case "PRECISE": - p.StartTimePrecise = v == "YES" - } - } - case strings.HasPrefix(line, "#EXT-X-KEY:"): - state.listType = MEDIA - state.xkey = new(Key) - for k, v := range decodeParamsLine(line[11:]) { - switch k { - case "METHOD": - state.xkey.Method = v - case "URI": - state.xkey.URI = v - case "IV": - state.xkey.IV = v - case "KEYFORMAT": - state.xkey.Keyformat = v - case "KEYFORMATVERSIONS": - state.xkey.Keyformatversions = v - } - } - state.tagKey = true - case strings.HasPrefix(line, "#EXT-X-MAP:"): - state.listType = MEDIA - state.xmap = new(Map) - for k, v := range decodeParamsLine(line[11:]) { - switch k { - case "URI": - state.xmap.URI = v - case "BYTERANGE": - if _, err = fmt.Sscanf(v, "%d@%d", &state.xmap.Limit, &state.xmap.Offset); strict && err != nil { - return fmt.Errorf("Byterange sub-range length value parsing error: %s", err) - } - } - } - state.tagMap = true - case !state.tagProgramDateTime && strings.HasPrefix(line, "#EXT-X-PROGRAM-DATE-TIME:"): - state.tagProgramDateTime = true - state.listType = MEDIA - if state.programDateTime, err = TimeParse(line[25:]); strict && err != nil { - return err - } - case !state.tagRange && strings.HasPrefix(line, "#EXT-X-BYTERANGE:"): - state.tagRange = true - state.listType = MEDIA - state.offset = 0 - params := strings.SplitN(line[17:], "@", 2) - if state.limit, err = strconv.ParseInt(params[0], 10, 64); strict && err != nil { - return fmt.Errorf("Byterange sub-range length value parsing error: %s", err) - } - if len(params) > 1 { - if state.offset, err = strconv.ParseInt(params[1], 10, 64); strict && err != nil { - return fmt.Errorf("Byterange sub-range offset value parsing error: %s", err) - } - } - case !state.tagSCTE35 && strings.HasPrefix(line, "#EXT-SCTE35:"): - state.tagSCTE35 = true - state.listType = MEDIA - state.scte = new(SCTE) - state.scte.Syntax = SCTE35_67_2014 - for attribute, value := range decodeParamsLine(line[12:]) { - switch attribute { - case "CUE": - state.scte.Cue = value - case "ID": - state.scte.ID = value - case "TIME": - state.scte.Time, _ = strconv.ParseFloat(value, 64) - } - } - case !state.tagSCTE35 && strings.HasPrefix(line, "#EXT-OATCLS-SCTE35:"): - // EXT-OATCLS-SCTE35 contains the SCTE35 tag, EXT-X-CUE-OUT contains duration - state.tagSCTE35 = true - state.scte = new(SCTE) - state.scte.Syntax = SCTE35_OATCLS - state.scte.Cue = line[19:] - case state.tagSCTE35 && state.scte.Syntax == SCTE35_OATCLS && strings.HasPrefix(line, "#EXT-X-CUE-OUT:"): - // EXT-OATCLS-SCTE35 contains the SCTE35 tag, EXT-X-CUE-OUT contains duration - state.scte.Time, _ = strconv.ParseFloat(line[15:], 64) - state.scte.CueType = SCTE35Cue_Start - case !state.tagSCTE35 && strings.HasPrefix(line, "#EXT-X-CUE-OUT-CONT:"): - state.tagSCTE35 = true - state.scte = new(SCTE) - state.scte.Syntax = SCTE35_OATCLS - state.scte.CueType = SCTE35Cue_Mid - for attribute, value := range decodeParamsLine(line[20:]) { - switch attribute { - case "SCTE35": - state.scte.Cue = value - case "Duration": - state.scte.Time, _ = strconv.ParseFloat(value, 64) - case "ElapsedTime": - state.scte.Elapsed, _ = strconv.ParseFloat(value, 64) - } - } - case !state.tagSCTE35 && line == "#EXT-X-CUE-IN": - state.tagSCTE35 = true - state.scte = new(SCTE) - state.scte.Syntax = SCTE35_OATCLS - state.scte.CueType = SCTE35Cue_End - case !state.tagDiscontinuity && strings.HasPrefix(line, "#EXT-X-DISCONTINUITY"): - state.tagDiscontinuity = true - state.listType = MEDIA - case strings.HasPrefix(line, "#EXT-X-I-FRAMES-ONLY"): - state.listType = MEDIA - p.Iframe = true - case strings.HasPrefix(line, "#WV-AUDIO-CHANNELS"): - state.listType = MEDIA - if _, err = fmt.Sscanf(line, "#WV-AUDIO-CHANNELS %d", &wv.AudioChannels); strict && err != nil { - return err - } - if err == nil { - state.tagWV = true - } - case strings.HasPrefix(line, "#WV-AUDIO-FORMAT"): - state.listType = MEDIA - if _, err = fmt.Sscanf(line, "#WV-AUDIO-FORMAT %d", &wv.AudioFormat); strict && err != nil { - return err - } - if err == nil { - state.tagWV = true - } - case strings.HasPrefix(line, "#WV-AUDIO-PROFILE-IDC"): - state.listType = MEDIA - if _, err = fmt.Sscanf(line, "#WV-AUDIO-PROFILE-IDC %d", &wv.AudioProfileIDC); strict && err != nil { - return err - } - if err == nil { - state.tagWV = true - } - case strings.HasPrefix(line, "#WV-AUDIO-SAMPLE-SIZE"): - state.listType = MEDIA - if _, err = fmt.Sscanf(line, "#WV-AUDIO-SAMPLE-SIZE %d", &wv.AudioSampleSize); strict && err != nil { - return err - } - if err == nil { - state.tagWV = true - } - case strings.HasPrefix(line, "#WV-AUDIO-SAMPLING-FREQUENCY"): - state.listType = MEDIA - if _, err = fmt.Sscanf(line, "#WV-AUDIO-SAMPLING-FREQUENCY %d", &wv.AudioSamplingFrequency); strict && err != nil { - return err - } - if err == nil { - state.tagWV = true - } - case strings.HasPrefix(line, "#WV-CYPHER-VERSION"): - state.listType = MEDIA - wv.CypherVersion = line[19:] - state.tagWV = true - case strings.HasPrefix(line, "#WV-ECM"): - state.listType = MEDIA - if _, err = fmt.Sscanf(line, "#WV-ECM %s", &wv.ECM); strict && err != nil { - return err - } - if err == nil { - state.tagWV = true - } - case strings.HasPrefix(line, "#WV-VIDEO-FORMAT"): - state.listType = MEDIA - if _, err = fmt.Sscanf(line, "#WV-VIDEO-FORMAT %d", &wv.VideoFormat); strict && err != nil { - return err - } - if err == nil { - state.tagWV = true - } - case strings.HasPrefix(line, "#WV-VIDEO-FRAME-RATE"): - state.listType = MEDIA - if _, err = fmt.Sscanf(line, "#WV-VIDEO-FRAME-RATE %d", &wv.VideoFrameRate); strict && err != nil { - return err - } - if err == nil { - state.tagWV = true - } - case strings.HasPrefix(line, "#WV-VIDEO-LEVEL-IDC"): - state.listType = MEDIA - if _, err = fmt.Sscanf(line, "#WV-VIDEO-LEVEL-IDC %d", &wv.VideoLevelIDC); strict && err != nil { - return err - } - if err == nil { - state.tagWV = true - } - case strings.HasPrefix(line, "#WV-VIDEO-PROFILE-IDC"): - state.listType = MEDIA - if _, err = fmt.Sscanf(line, "#WV-VIDEO-PROFILE-IDC %d", &wv.VideoProfileIDC); strict && err != nil { - return err - } - if err == nil { - state.tagWV = true - } - case strings.HasPrefix(line, "#WV-VIDEO-RESOLUTION"): - state.listType = MEDIA - wv.VideoResolution = line[21:] - state.tagWV = true - case strings.HasPrefix(line, "#WV-VIDEO-SAR"): - state.listType = MEDIA - if _, err = fmt.Sscanf(line, "#WV-VIDEO-SAR %s", &wv.VideoSAR); strict && err != nil { - return err - } - if err == nil { - state.tagWV = true - } - case strings.HasPrefix(line, "#"): - // comments are ignored - } - return err -} - -// StrictTimeParse implements RFC3339 with Nanoseconds accuracy. -func StrictTimeParse(value string) (time.Time, error) { - return time.Parse(DATETIME, value) -} - -// FullTimeParse implements ISO/IEC 8601:2004. -func FullTimeParse(value string) (time.Time, error) { - layouts := []string{ - "2006-01-02T15:04:05.999999999Z0700", - "2006-01-02T15:04:05.999999999Z07:00", - "2006-01-02T15:04:05.999999999Z07", - } - var ( - err error - t time.Time - ) - for _, layout := range layouts { - if t, err = time.Parse(layout, value); err == nil { - return t, nil - } - } - return t, err -} diff --git a/vendor/github.com/grafov/m3u8/structure.go b/vendor/github.com/grafov/m3u8/structure.go deleted file mode 100644 index ea0d5c8..0000000 --- a/vendor/github.com/grafov/m3u8/structure.go +++ /dev/null @@ -1,332 +0,0 @@ -package m3u8 - -/* - Part of M3U8 parser & generator library. - This file defines data structures related to package. - - Copyright 2013-2017 The Project Developers. - See the AUTHORS and LICENSE files at the top-level directory of this distribution - and at https://github.com/grafov/m3u8/ - - ॐ तारे तुत्तारे तुरे स्व -*/ - -import ( - "bytes" - "io" - "time" -) - -const ( - /* - Compatibility rules described in section 7: - Clients and servers MUST implement protocol version 2 or higher to use: - o The IV attribute of the EXT-X-KEY tag. - Clients and servers MUST implement protocol version 3 or higher to use: - o Floating-point EXTINF duration values. - Clients and servers MUST implement protocol version 4 or higher to use: - o The EXT-X-BYTERANGE tag. - o The EXT-X-I-FRAME-STREAM-INF tag. - o The EXT-X-I-FRAMES-ONLY tag. - o The EXT-X-MEDIA tag. - o The AUDIO and VIDEO attributes of the EXT-X-STREAM-INF tag. - */ - minver = uint8(3) - DATETIME = time.RFC3339Nano // Format for EXT-X-PROGRAM-DATE-TIME defined in section 3.4.5 -) - -type ListType uint - -const ( - // use 0 for not defined type - MASTER ListType = iota + 1 - MEDIA -) - -// for EXT-X-PLAYLIST-TYPE tag -type MediaType uint - -const ( - // use 0 for not defined type - EVENT MediaType = iota + 1 - VOD -) - -// SCTE35Syntax defines the format of the SCTE-35 cue points which do not use -// the draft-pantos-http-live-streaming-19 EXT-X-DATERANGE tag and instead -// have their own custom tags -type SCTE35Syntax uint - -const ( - // SCTE35_67_2014 will be the default due to backwards compatibility reasons. - SCTE35_67_2014 SCTE35Syntax = iota // SCTE35_67_2014 defined in http://www.scte.org/documents/pdf/standards/SCTE%2067%202014.pdf - SCTE35_OATCLS // SCTE35_OATCLS is a non-standard but common format -) - -// SCTE35CueType defines the type of cue point, used by readers and writers to -// write a different syntax -type SCTE35CueType uint - -const ( - SCTE35Cue_Start SCTE35CueType = iota // SCTE35Cue_Start indicates an out cue point - SCTE35Cue_Mid // SCTE35Cue_Mid indicates a segment between start and end cue points - SCTE35Cue_End // SCTE35Cue_End indicates an in cue point -) - -/* - This structure represents a single bitrate playlist aka media playlist. - It related to both a simple media playlists and a sliding window media playlists. - URI lines in the Playlist point to media segments. - - Simple Media Playlist file sample: - - #EXTM3U - #EXT-X-VERSION:3 - #EXT-X-TARGETDURATION:5220 - #EXTINF:5219.2, - http://media.example.com/entire.ts - #EXT-X-ENDLIST - - Sample of Sliding Window Media Playlist, using HTTPS: - - #EXTM3U - #EXT-X-VERSION:3 - #EXT-X-TARGETDURATION:8 - #EXT-X-MEDIA-SEQUENCE:2680 - - #EXTINF:7.975, - https://priv.example.com/fileSequence2680.ts - #EXTINF:7.941, - https://priv.example.com/fileSequence2681.ts - #EXTINF:7.975, - https://priv.example.com/fileSequence2682.ts -*/ -type MediaPlaylist struct { - TargetDuration float64 - SeqNo uint64 // EXT-X-MEDIA-SEQUENCE - Segments []*MediaSegment - Args string // optional arguments placed after URIs (URI?Args) - Iframe bool // EXT-X-I-FRAMES-ONLY - Closed bool // is this VOD (closed) or Live (sliding) playlist? - MediaType MediaType - DiscontinuitySeq uint64 // EXT-X-DISCONTINUITY-SEQUENCE - StartTime float64 - StartTimePrecise bool - durationAsInt bool // output durations as integers of floats? - keyformat int - winsize uint // max number of segments displayed in an encoded playlist; need set to zero for VOD playlists - capacity uint // total capacity of slice used for the playlist - head uint // head of FIFO, we add segments to head - tail uint // tail of FIFO, we remove segments from tail - count uint // number of segments added to the playlist - buf bytes.Buffer - ver uint8 - Key *Key // EXT-X-KEY is optional encryption key displayed before any segments (default key for the playlist) - Map *Map // EXT-X-MAP is optional tag specifies how to obtain the Media Initialization Section (default map for the playlist) - WV *WV // Widevine related tags outside of M3U8 specs - Custom map[string]CustomTag - customDecoders []CustomDecoder -} - -/* - This structure represents a master playlist which combines media playlists for multiple bitrates. - URI lines in the playlist identify media playlists. - Sample of Master Playlist file: - - #EXTM3U - #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1280000 - http://example.com/low.m3u8 - #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=2560000 - http://example.com/mid.m3u8 - #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=7680000 - http://example.com/hi.m3u8 - #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=65000,CODECS="mp4a.40.5" - http://example.com/audio-only.m3u8 -*/ -type MasterPlaylist struct { - Variants []*Variant - Args string // optional arguments placed after URI (URI?Args) - CypherVersion string // non-standard tag for Widevine (see also WV struct) - buf bytes.Buffer - ver uint8 - independentSegments bool - Custom map[string]CustomTag - customDecoders []CustomDecoder -} - -// This structure represents variants for master playlist. -// Variants included in a master playlist and point to media playlists. -type Variant struct { - URI string - Chunklist *MediaPlaylist - VariantParams -} - -// This structure represents additional parameters for a variant -// used in EXT-X-STREAM-INF and EXT-X-I-FRAME-STREAM-INF -type VariantParams struct { - ProgramId uint32 - Bandwidth uint32 - AverageBandwidth uint32 // EXT-X-STREAM-INF only - Codecs string - Resolution string - Audio string // EXT-X-STREAM-INF only - Video string - Subtitles string // EXT-X-STREAM-INF only - Captions string // EXT-X-STREAM-INF only - Name string // EXT-X-STREAM-INF only (non standard Wowza/JWPlayer extension to name the variant/quality in UA) - Iframe bool // EXT-X-I-FRAME-STREAM-INF - VideoRange string - HDCPLevel string - FrameRate float64 // EXT-X-STREAM-INF - Alternatives []*Alternative // EXT-X-MEDIA -} - -// This structure represents EXT-X-MEDIA tag in variants. -type Alternative struct { - GroupId string - URI string - Type string - Language string - Name string - Default bool - Autoselect string - Forced string - Characteristics string - Subtitles string -} - -// This structure represents a media segment included in a media playlist. -// Media segment may be encrypted. -// Widevine supports own tags for encryption metadata. -type MediaSegment struct { - SeqId uint64 - Title string // optional second parameter for EXTINF tag - URI string - Duration float64 // first parameter for EXTINF tag; duration must be integers if protocol version is less than 3 but we are always keep them float - Limit int64 // EXT-X-BYTERANGE is length in bytes for the file under URI - Offset int64 // EXT-X-BYTERANGE [@o] is offset from the start of the file under URI - Key *Key // EXT-X-KEY displayed before the segment and means changing of encryption key (in theory each segment may have own key) - Map *Map // EXT-X-MAP displayed before the segment - Discontinuity bool // EXT-X-DISCONTINUITY indicates an encoding discontinuity between the media segment that follows it and the one that preceded it (i.e. file format, number and type of tracks, encoding parameters, encoding sequence, timestamp sequence) - SCTE *SCTE // SCTE-35 used for Ad signaling in HLS - ProgramDateTime time.Time // EXT-X-PROGRAM-DATE-TIME tag associates the first sample of a media segment with an absolute date and/or time - Custom map[string]CustomTag -} - -// SCTE holds custom, non EXT-X-DATERANGE, SCTE-35 tags -type SCTE struct { - Syntax SCTE35Syntax // Syntax defines the format of the SCTE-35 cue tag - CueType SCTE35CueType // CueType defines whether the cue is a start, mid, end (if applicable) - Cue string - ID string - Time float64 - Elapsed float64 -} - -// This structure represents information about stream encryption. -// -// Realizes EXT-X-KEY tag. -type Key struct { - Method string - URI string - IV string - Keyformat string - Keyformatversions string -} - -// This structure represents specifies how to obtain the Media -// Initialization Section required to parse the applicable -// Media Segments. - -// It applies to every Media Segment that appears after it in the -// Playlist until the next EXT-X-MAP tag or until the end of the -// playlist. -// -// Realizes EXT-MAP tag. -type Map struct { - URI string - Limit int64 // is length in bytes for the file under URI - Offset int64 // [@o] is offset from the start of the file under URI -} - -// This structure represents metadata for Google Widevine playlists. -// This format not described in IETF draft but provied by Widevine Live Packager as -// additional tags with #WV-prefix. -type WV struct { - AudioChannels uint - AudioFormat uint - AudioProfileIDC uint - AudioSampleSize uint - AudioSamplingFrequency uint - CypherVersion string - ECM string - VideoFormat uint - VideoFrameRate uint - VideoLevelIDC uint - VideoProfileIDC uint - VideoResolution string - VideoSAR string -} - -// Interface applied to various playlist types. -type Playlist interface { - Encode() *bytes.Buffer - Decode(bytes.Buffer, bool) error - DecodeFrom(reader io.Reader, strict bool) error - WithCustomDecoders([]CustomDecoder) Playlist - String() string -} - -// Interface for decoding custom and unsupported tags -type CustomDecoder interface { - // TagName should return the full indentifier including the leading '#' as well as the - // trailing ':' if the tag also contains a value or attribute list - TagName() string - // Decode parses a line from the playlist and returns the CustomTag representation - Decode(line string) (CustomTag, error) - // SegmentTag should return true if this CustomDecoder should apply per segment. - // Should returns false if it a MediaPlaylist header tag. - // This value is ignored for MasterPlaylists. - SegmentTag() bool -} - -// Interface for encoding custom and unsupported tags -type CustomTag interface { - // TagName should return the full indentifier including the leading '#' as well as the - // trailing ':' if the tag also contains a value or attribute list - TagName() string - // Encode should return the complete tag string as a *bytes.Buffer. This will - // be used by Playlist.Decode to write the tag to the m3u8. - // Return nil to not write anything to the m3u8. - Encode() *bytes.Buffer - // String should return the encoded tag as a string. - String() string -} - -// Internal structure for decoding a line of input stream with a list type detection -type decodingState struct { - listType ListType - m3u bool - tagWV bool - tagStreamInf bool - tagInf bool - tagSCTE35 bool - tagRange bool - tagDiscontinuity bool - tagProgramDateTime bool - tagKey bool - tagMap bool - tagCustom bool - programDateTime time.Time - limit int64 - offset int64 - duration float64 - title string - variant *Variant - alternatives []*Alternative - xkey *Key - xmap *Map - scte *SCTE - custom map[string]CustomTag -} diff --git a/vendor/github.com/grafov/m3u8/writer.go b/vendor/github.com/grafov/m3u8/writer.go deleted file mode 100644 index ae73606..0000000 --- a/vendor/github.com/grafov/m3u8/writer.go +++ /dev/null @@ -1,895 +0,0 @@ -package m3u8 - -/* - Part of M3U8 parser & generator library. - This file defines functions related to playlist generation. - - Copyright 2013-2017 The Project Developers. - See the AUTHORS and LICENSE files at the top-level directory of this distribution - and at https://github.com/grafov/m3u8/ - - ॐ तारे तुत्तारे तुरे स्व -*/ - -import ( - "bytes" - "errors" - "fmt" - "math" - "strconv" - "strings" - "time" -) - -var ( - ErrPlaylistFull = errors.New("playlist is full") -) - -// Set version of the playlist accordingly with section 7 -func version(ver *uint8, newver uint8) { - if *ver < newver { - *ver = newver - } -} - -func strver(ver uint8) string { - return strconv.FormatUint(uint64(ver), 10) -} - -// Create new empty master playlist. -// Master playlist consists of variants. -func NewMasterPlaylist() *MasterPlaylist { - p := new(MasterPlaylist) - p.ver = minver - return p -} - -// Append variant to master playlist. -// This operation does reset playlist cache. -func (p *MasterPlaylist) Append(uri string, chunklist *MediaPlaylist, params VariantParams) { - v := new(Variant) - v.URI = uri - v.Chunklist = chunklist - v.VariantParams = params - p.Variants = append(p.Variants, v) - if len(v.Alternatives) > 0 { - // From section 7: - // The EXT-X-MEDIA tag and the AUDIO, VIDEO and SUBTITLES attributes of - // the EXT-X-STREAM-INF tag are backward compatible to protocol version - // 1, but playback on older clients may not be desirable. A server MAY - // consider indicating a EXT-X-VERSION of 4 or higher in the Master - // Playlist but is not required to do so. - version(&p.ver, 4) // so it is optional and in theory may be set to ver.1 - // but more tests required - } - p.buf.Reset() -} - -func (p *MasterPlaylist) ResetCache() { - p.buf.Reset() -} - -// Generate output in M3U8 format. -func (p *MasterPlaylist) Encode() *bytes.Buffer { - if p.buf.Len() > 0 { - return &p.buf - } - - p.buf.WriteString("#EXTM3U\n#EXT-X-VERSION:") - p.buf.WriteString(strver(p.ver)) - p.buf.WriteRune('\n') - - if p.IndependentSegments() { - p.buf.WriteString("#EXT-X-INDEPENDENT-SEGMENTS\n") - } - - // Write any custom master tags - if p.Custom != nil { - for _, v := range p.Custom { - if customBuf := v.Encode(); customBuf != nil { - p.buf.WriteString(customBuf.String()) - p.buf.WriteRune('\n') - } - } - } - - var altsWritten map[string]bool = make(map[string]bool) - - for _, pl := range p.Variants { - if pl.Alternatives != nil { - for _, alt := range pl.Alternatives { - // Make sure that we only write out an alternative once - altKey := fmt.Sprintf("%s-%s-%s-%s", alt.Type, alt.GroupId, alt.Name, alt.Language) - if altsWritten[altKey] { - continue - } - altsWritten[altKey] = true - - p.buf.WriteString("#EXT-X-MEDIA:") - if alt.Type != "" { - p.buf.WriteString("TYPE=") // Type should not be quoted - p.buf.WriteString(alt.Type) - } - if alt.GroupId != "" { - p.buf.WriteString(",GROUP-ID=\"") - p.buf.WriteString(alt.GroupId) - p.buf.WriteRune('"') - } - if alt.Name != "" { - p.buf.WriteString(",NAME=\"") - p.buf.WriteString(alt.Name) - p.buf.WriteRune('"') - } - p.buf.WriteString(",DEFAULT=") - if alt.Default { - p.buf.WriteString("YES") - } else { - p.buf.WriteString("NO") - } - if alt.Autoselect != "" { - p.buf.WriteString(",AUTOSELECT=") - p.buf.WriteString(alt.Autoselect) - } - if alt.Language != "" { - p.buf.WriteString(",LANGUAGE=\"") - p.buf.WriteString(alt.Language) - p.buf.WriteRune('"') - } - if alt.Forced != "" { - p.buf.WriteString(",FORCED=\"") - p.buf.WriteString(alt.Forced) - p.buf.WriteRune('"') - } - if alt.Characteristics != "" { - p.buf.WriteString(",CHARACTERISTICS=\"") - p.buf.WriteString(alt.Characteristics) - p.buf.WriteRune('"') - } - if alt.Subtitles != "" { - p.buf.WriteString(",SUBTITLES=\"") - p.buf.WriteString(alt.Subtitles) - p.buf.WriteRune('"') - } - if alt.URI != "" { - p.buf.WriteString(",URI=\"") - p.buf.WriteString(alt.URI) - p.buf.WriteRune('"') - } - p.buf.WriteRune('\n') - } - } - if pl.Iframe { - p.buf.WriteString("#EXT-X-I-FRAME-STREAM-INF:PROGRAM-ID=") - p.buf.WriteString(strconv.FormatUint(uint64(pl.ProgramId), 10)) - p.buf.WriteString(",BANDWIDTH=") - p.buf.WriteString(strconv.FormatUint(uint64(pl.Bandwidth), 10)) - if pl.AverageBandwidth != 0 { - p.buf.WriteString(",AVERAGE-BANDWIDTH=") - p.buf.WriteString(strconv.FormatUint(uint64(pl.AverageBandwidth), 10)) - } - if pl.Codecs != "" { - p.buf.WriteString(",CODECS=\"") - p.buf.WriteString(pl.Codecs) - p.buf.WriteRune('"') - } - if pl.Resolution != "" { - p.buf.WriteString(",RESOLUTION=") // Resolution should not be quoted - p.buf.WriteString(pl.Resolution) - } - if pl.Video != "" { - p.buf.WriteString(",VIDEO=\"") - p.buf.WriteString(pl.Video) - p.buf.WriteRune('"') - } - if pl.VideoRange != "" { - p.buf.WriteString(",VIDEO-RANGE=") - p.buf.WriteString(pl.VideoRange) - } - if pl.HDCPLevel != "" { - p.buf.WriteString(",HDCP-LEVEL=") - p.buf.WriteString(pl.HDCPLevel) - } - if pl.URI != "" { - p.buf.WriteString(",URI=\"") - p.buf.WriteString(pl.URI) - p.buf.WriteRune('"') - } - p.buf.WriteRune('\n') - } else { - p.buf.WriteString("#EXT-X-STREAM-INF:PROGRAM-ID=") - p.buf.WriteString(strconv.FormatUint(uint64(pl.ProgramId), 10)) - p.buf.WriteString(",BANDWIDTH=") - p.buf.WriteString(strconv.FormatUint(uint64(pl.Bandwidth), 10)) - if pl.AverageBandwidth != 0 { - p.buf.WriteString(",AVERAGE-BANDWIDTH=") - p.buf.WriteString(strconv.FormatUint(uint64(pl.AverageBandwidth), 10)) - } - if pl.Codecs != "" { - p.buf.WriteString(",CODECS=\"") - p.buf.WriteString(pl.Codecs) - p.buf.WriteRune('"') - } - if pl.Resolution != "" { - p.buf.WriteString(",RESOLUTION=") // Resolution should not be quoted - p.buf.WriteString(pl.Resolution) - } - if pl.Audio != "" { - p.buf.WriteString(",AUDIO=\"") - p.buf.WriteString(pl.Audio) - p.buf.WriteRune('"') - } - if pl.Video != "" { - p.buf.WriteString(",VIDEO=\"") - p.buf.WriteString(pl.Video) - p.buf.WriteRune('"') - } - if pl.Captions != "" { - p.buf.WriteString(",CLOSED-CAPTIONS=") - if pl.Captions == "NONE" { - p.buf.WriteString(pl.Captions) // CC should not be quoted when eq NONE - } else { - p.buf.WriteRune('"') - p.buf.WriteString(pl.Captions) - p.buf.WriteRune('"') - } - } - if pl.Subtitles != "" { - p.buf.WriteString(",SUBTITLES=\"") - p.buf.WriteString(pl.Subtitles) - p.buf.WriteRune('"') - } - if pl.Name != "" { - p.buf.WriteString(",NAME=\"") - p.buf.WriteString(pl.Name) - p.buf.WriteRune('"') - } - if pl.FrameRate != 0 { - p.buf.WriteString(",FRAME-RATE=") - p.buf.WriteString(strconv.FormatFloat(pl.FrameRate, 'f', 3, 64)) - } - if pl.VideoRange != "" { - p.buf.WriteString(",VIDEO-RANGE=") - p.buf.WriteString(pl.VideoRange) - } - if pl.HDCPLevel != "" { - p.buf.WriteString(",HDCP-LEVEL=") - p.buf.WriteString(pl.HDCPLevel) - } - - p.buf.WriteRune('\n') - p.buf.WriteString(pl.URI) - if p.Args != "" { - if strings.Contains(pl.URI, "?") { - p.buf.WriteRune('&') - } else { - p.buf.WriteRune('?') - } - p.buf.WriteString(p.Args) - } - p.buf.WriteRune('\n') - } - } - - return &p.buf -} - -// SetCustomTag sets the provided tag on the master playlist for its TagName -func (p *MasterPlaylist) SetCustomTag(tag CustomTag) { - if p.Custom == nil { - p.Custom = make(map[string]CustomTag) - } - - p.Custom[tag.TagName()] = tag -} - -// Version returns the current playlist version number -func (p *MasterPlaylist) Version() uint8 { - return p.ver -} - -// SetVersion sets the playlist version number, note the version maybe changed -// automatically by other Set methods. -func (p *MasterPlaylist) SetVersion(ver uint8) { - p.ver = ver -} - -// IndependentSegments returns true if all media samples in a segment can be -// decoded without information from other segments. -func (p *MasterPlaylist) IndependentSegments() bool { - return p.independentSegments -} - -// SetIndependentSegments sets whether all media samples in a segment can be -// decoded without information from other segments. -func (p *MasterPlaylist) SetIndependentSegments(b bool) { - p.independentSegments = b -} - -// For compatibility with Stringer interface -// For example fmt.Printf("%s", sampleMediaList) will encode -// playist and print its string representation. -func (p *MasterPlaylist) String() string { - return p.Encode().String() -} - -// Creates new media playlist structure. -// Winsize defines how much items will displayed on playlist generation. -// Capacity is total size of a playlist. -func NewMediaPlaylist(winsize uint, capacity uint) (*MediaPlaylist, error) { - p := new(MediaPlaylist) - p.ver = minver - p.capacity = capacity - if err := p.SetWinSize(winsize); err != nil { - return nil, err - } - p.Segments = make([]*MediaSegment, capacity) - return p, nil -} - -// last returns the previously written segment's index -func (p *MediaPlaylist) last() uint { - if p.tail == 0 { - return p.capacity - 1 - } - return p.tail - 1 -} - -// Remove current segment from the head of chunk slice form a media playlist. Useful for sliding playlists. -// This operation does reset playlist cache. -func (p *MediaPlaylist) Remove() (err error) { - if p.count == 0 { - return errors.New("playlist is empty") - } - p.head = (p.head + 1) % p.capacity - p.count-- - if !p.Closed { - p.SeqNo++ - } - p.buf.Reset() - return nil -} - -// Append general chunk to the tail of chunk slice for a media playlist. -// This operation does reset playlist cache. -func (p *MediaPlaylist) Append(uri string, duration float64, title string) error { - seg := new(MediaSegment) - seg.URI = uri - seg.Duration = duration - seg.Title = title - return p.AppendSegment(seg) -} - -// AppendSegment appends a MediaSegment to the tail of chunk slice for a media playlist. -// This operation does reset playlist cache. -func (p *MediaPlaylist) AppendSegment(seg *MediaSegment) error { - if p.head == p.tail && p.count > 0 { - return ErrPlaylistFull - } - seg.SeqId = p.SeqNo - if p.count > 0 { - seg.SeqId = p.Segments[(p.capacity+p.tail-1)%p.capacity].SeqId + 1 - } - p.Segments[p.tail] = seg - p.tail = (p.tail + 1) % p.capacity - p.count++ - if p.TargetDuration < seg.Duration { - p.TargetDuration = math.Ceil(seg.Duration) - } - p.buf.Reset() - return nil -} - -// Combines two operations: firstly it removes one chunk from the head of chunk slice and move pointer to -// next chunk. Secondly it appends one chunk to the tail of chunk slice. Useful for sliding playlists. -// This operation does reset cache. -func (p *MediaPlaylist) Slide(uri string, duration float64, title string) { - if !p.Closed && p.count >= p.winsize { - p.Remove() - } - p.Append(uri, duration, title) -} - -// Reset playlist cache. Next called Encode() will regenerate playlist from the chunk slice. -func (p *MediaPlaylist) ResetCache() { - p.buf.Reset() -} - -// Generate output in M3U8 format. Marshal `winsize` elements from bottom of the `segments` queue. -func (p *MediaPlaylist) Encode() *bytes.Buffer { - if p.buf.Len() > 0 { - return &p.buf - } - - p.buf.WriteString("#EXTM3U\n#EXT-X-VERSION:") - p.buf.WriteString(strver(p.ver)) - p.buf.WriteRune('\n') - - // Write any custom master tags - if p.Custom != nil { - for _, v := range p.Custom { - if customBuf := v.Encode(); customBuf != nil { - p.buf.WriteString(customBuf.String()) - p.buf.WriteRune('\n') - } - } - } - - // default key (workaround for Widevine) - if p.Key != nil { - p.buf.WriteString("#EXT-X-KEY:") - p.buf.WriteString("METHOD=") - p.buf.WriteString(p.Key.Method) - if p.Key.Method != "NONE" { - p.buf.WriteString(",URI=\"") - p.buf.WriteString(p.Key.URI) - p.buf.WriteRune('"') - if p.Key.IV != "" { - p.buf.WriteString(",IV=") - p.buf.WriteString(p.Key.IV) - } - if p.Key.Keyformat != "" { - p.buf.WriteString(",KEYFORMAT=\"") - p.buf.WriteString(p.Key.Keyformat) - p.buf.WriteRune('"') - } - if p.Key.Keyformatversions != "" { - p.buf.WriteString(",KEYFORMATVERSIONS=\"") - p.buf.WriteString(p.Key.Keyformatversions) - p.buf.WriteRune('"') - } - } - p.buf.WriteRune('\n') - } - if p.Map != nil { - p.buf.WriteString("#EXT-X-MAP:") - p.buf.WriteString("URI=\"") - p.buf.WriteString(p.Map.URI) - p.buf.WriteRune('"') - if p.Map.Limit > 0 { - p.buf.WriteString(",BYTERANGE=") - p.buf.WriteString(strconv.FormatInt(p.Map.Limit, 10)) - p.buf.WriteRune('@') - p.buf.WriteString(strconv.FormatInt(p.Map.Offset, 10)) - } - p.buf.WriteRune('\n') - } - if p.MediaType > 0 { - p.buf.WriteString("#EXT-X-PLAYLIST-TYPE:") - switch p.MediaType { - case EVENT: - p.buf.WriteString("EVENT\n") - p.buf.WriteString("#EXT-X-ALLOW-CACHE:NO\n") - case VOD: - p.buf.WriteString("VOD\n") - } - } - p.buf.WriteString("#EXT-X-MEDIA-SEQUENCE:") - p.buf.WriteString(strconv.FormatUint(p.SeqNo, 10)) - p.buf.WriteRune('\n') - p.buf.WriteString("#EXT-X-TARGETDURATION:") - p.buf.WriteString(strconv.FormatInt(int64(math.Ceil(p.TargetDuration)), 10)) // due section 3.4.2 of M3U8 specs EXT-X-TARGETDURATION must be integer - p.buf.WriteRune('\n') - if p.StartTime > 0.0 { - p.buf.WriteString("#EXT-X-START:TIME-OFFSET=") - p.buf.WriteString(strconv.FormatFloat(p.StartTime, 'f', -1, 64)) - if p.StartTimePrecise { - p.buf.WriteString(",PRECISE=YES") - } - p.buf.WriteRune('\n') - } - if p.DiscontinuitySeq != 0 { - p.buf.WriteString("#EXT-X-DISCONTINUITY-SEQUENCE:") - p.buf.WriteString(strconv.FormatUint(uint64(p.DiscontinuitySeq), 10)) - p.buf.WriteRune('\n') - } - if p.Iframe { - p.buf.WriteString("#EXT-X-I-FRAMES-ONLY\n") - } - // Widevine tags - if p.WV != nil { - if p.WV.AudioChannels != 0 { - p.buf.WriteString("#WV-AUDIO-CHANNELS ") - p.buf.WriteString(strconv.FormatUint(uint64(p.WV.AudioChannels), 10)) - p.buf.WriteRune('\n') - } - if p.WV.AudioFormat != 0 { - p.buf.WriteString("#WV-AUDIO-FORMAT ") - p.buf.WriteString(strconv.FormatUint(uint64(p.WV.AudioFormat), 10)) - p.buf.WriteRune('\n') - } - if p.WV.AudioProfileIDC != 0 { - p.buf.WriteString("#WV-AUDIO-PROFILE-IDC ") - p.buf.WriteString(strconv.FormatUint(uint64(p.WV.AudioProfileIDC), 10)) - p.buf.WriteRune('\n') - } - if p.WV.AudioSampleSize != 0 { - p.buf.WriteString("#WV-AUDIO-SAMPLE-SIZE ") - p.buf.WriteString(strconv.FormatUint(uint64(p.WV.AudioSampleSize), 10)) - p.buf.WriteRune('\n') - } - if p.WV.AudioSamplingFrequency != 0 { - p.buf.WriteString("#WV-AUDIO-SAMPLING-FREQUENCY ") - p.buf.WriteString(strconv.FormatUint(uint64(p.WV.AudioSamplingFrequency), 10)) - p.buf.WriteRune('\n') - } - if p.WV.CypherVersion != "" { - p.buf.WriteString("#WV-CYPHER-VERSION ") - p.buf.WriteString(p.WV.CypherVersion) - p.buf.WriteRune('\n') - } - if p.WV.ECM != "" { - p.buf.WriteString("#WV-ECM ") - p.buf.WriteString(p.WV.ECM) - p.buf.WriteRune('\n') - } - if p.WV.VideoFormat != 0 { - p.buf.WriteString("#WV-VIDEO-FORMAT ") - p.buf.WriteString(strconv.FormatUint(uint64(p.WV.VideoFormat), 10)) - p.buf.WriteRune('\n') - } - if p.WV.VideoFrameRate != 0 { - p.buf.WriteString("#WV-VIDEO-FRAME-RATE ") - p.buf.WriteString(strconv.FormatUint(uint64(p.WV.VideoFrameRate), 10)) - p.buf.WriteRune('\n') - } - if p.WV.VideoLevelIDC != 0 { - p.buf.WriteString("#WV-VIDEO-LEVEL-IDC") - p.buf.WriteString(strconv.FormatUint(uint64(p.WV.VideoLevelIDC), 10)) - p.buf.WriteRune('\n') - } - if p.WV.VideoProfileIDC != 0 { - p.buf.WriteString("#WV-VIDEO-PROFILE-IDC ") - p.buf.WriteString(strconv.FormatUint(uint64(p.WV.VideoProfileIDC), 10)) - p.buf.WriteRune('\n') - } - if p.WV.VideoResolution != "" { - p.buf.WriteString("#WV-VIDEO-RESOLUTION ") - p.buf.WriteString(p.WV.VideoResolution) - p.buf.WriteRune('\n') - } - if p.WV.VideoSAR != "" { - p.buf.WriteString("#WV-VIDEO-SAR ") - p.buf.WriteString(p.WV.VideoSAR) - p.buf.WriteRune('\n') - } - } - - var ( - seg *MediaSegment - durationCache = make(map[float64]string) - ) - - head := p.head - count := p.count - for i := uint(0); (i < p.winsize || p.winsize == 0) && count > 0; count-- { - seg = p.Segments[head] - head = (head + 1) % p.capacity - if seg == nil { // protection from badly filled chunklists - continue - } - if p.winsize > 0 { // skip for VOD playlists, where winsize = 0 - i++ - } - if seg.SCTE != nil { - switch seg.SCTE.Syntax { - case SCTE35_67_2014: - p.buf.WriteString("#EXT-SCTE35:") - p.buf.WriteString("CUE=\"") - p.buf.WriteString(seg.SCTE.Cue) - p.buf.WriteRune('"') - if seg.SCTE.ID != "" { - p.buf.WriteString(",ID=\"") - p.buf.WriteString(seg.SCTE.ID) - p.buf.WriteRune('"') - } - if seg.SCTE.Time != 0 { - p.buf.WriteString(",TIME=") - p.buf.WriteString(strconv.FormatFloat(seg.SCTE.Time, 'f', -1, 64)) - } - p.buf.WriteRune('\n') - case SCTE35_OATCLS: - switch seg.SCTE.CueType { - case SCTE35Cue_Start: - p.buf.WriteString("#EXT-OATCLS-SCTE35:") - p.buf.WriteString(seg.SCTE.Cue) - p.buf.WriteRune('\n') - p.buf.WriteString("#EXT-X-CUE-OUT:") - p.buf.WriteString(strconv.FormatFloat(seg.SCTE.Time, 'f', -1, 64)) - p.buf.WriteRune('\n') - case SCTE35Cue_Mid: - p.buf.WriteString("#EXT-X-CUE-OUT-CONT:") - p.buf.WriteString("ElapsedTime=") - p.buf.WriteString(strconv.FormatFloat(seg.SCTE.Elapsed, 'f', -1, 64)) - p.buf.WriteString(",Duration=") - p.buf.WriteString(strconv.FormatFloat(seg.SCTE.Time, 'f', -1, 64)) - p.buf.WriteString(",SCTE35=") - p.buf.WriteString(seg.SCTE.Cue) - p.buf.WriteRune('\n') - case SCTE35Cue_End: - p.buf.WriteString("#EXT-X-CUE-IN") - p.buf.WriteRune('\n') - } - } - } - // check for key change - if seg.Key != nil && p.Key != seg.Key { - p.buf.WriteString("#EXT-X-KEY:") - p.buf.WriteString("METHOD=") - p.buf.WriteString(seg.Key.Method) - if seg.Key.Method != "NONE" { - p.buf.WriteString(",URI=\"") - p.buf.WriteString(seg.Key.URI) - p.buf.WriteRune('"') - if seg.Key.IV != "" { - p.buf.WriteString(",IV=") - p.buf.WriteString(seg.Key.IV) - } - if seg.Key.Keyformat != "" { - p.buf.WriteString(",KEYFORMAT=\"") - p.buf.WriteString(seg.Key.Keyformat) - p.buf.WriteRune('"') - } - if seg.Key.Keyformatversions != "" { - p.buf.WriteString(",KEYFORMATVERSIONS=\"") - p.buf.WriteString(seg.Key.Keyformatversions) - p.buf.WriteRune('"') - } - } - p.buf.WriteRune('\n') - } - if seg.Discontinuity { - p.buf.WriteString("#EXT-X-DISCONTINUITY\n") - } - // ignore segment Map if default playlist Map is present - if p.Map == nil && seg.Map != nil { - p.buf.WriteString("#EXT-X-MAP:") - p.buf.WriteString("URI=\"") - p.buf.WriteString(seg.Map.URI) - p.buf.WriteRune('"') - if seg.Map.Limit > 0 { - p.buf.WriteString(",BYTERANGE=") - p.buf.WriteString(strconv.FormatInt(seg.Map.Limit, 10)) - p.buf.WriteRune('@') - p.buf.WriteString(strconv.FormatInt(seg.Map.Offset, 10)) - } - p.buf.WriteRune('\n') - } - if !seg.ProgramDateTime.IsZero() { - p.buf.WriteString("#EXT-X-PROGRAM-DATE-TIME:") - p.buf.WriteString(seg.ProgramDateTime.Format(DATETIME)) - p.buf.WriteRune('\n') - } - if seg.Limit > 0 { - p.buf.WriteString("#EXT-X-BYTERANGE:") - p.buf.WriteString(strconv.FormatInt(seg.Limit, 10)) - p.buf.WriteRune('@') - p.buf.WriteString(strconv.FormatInt(seg.Offset, 10)) - p.buf.WriteRune('\n') - } - - // Add Custom Segment Tags here - if seg.Custom != nil { - for _, v := range seg.Custom { - if customBuf := v.Encode(); customBuf != nil { - p.buf.WriteString(customBuf.String()) - p.buf.WriteRune('\n') - } - } - } - - p.buf.WriteString("#EXTINF:") - if str, ok := durationCache[seg.Duration]; ok { - p.buf.WriteString(str) - } else { - if p.durationAsInt { - // Old Android players has problems with non integer Duration. - durationCache[seg.Duration] = strconv.FormatInt(int64(math.Ceil(seg.Duration)), 10) - } else { - // Wowza Mediaserver and some others prefer floats. - durationCache[seg.Duration] = strconv.FormatFloat(seg.Duration, 'f', 3, 32) - } - p.buf.WriteString(durationCache[seg.Duration]) - } - p.buf.WriteRune(',') - p.buf.WriteString(seg.Title) - p.buf.WriteRune('\n') - p.buf.WriteString(seg.URI) - if p.Args != "" { - p.buf.WriteRune('?') - p.buf.WriteString(p.Args) - } - p.buf.WriteRune('\n') - } - if p.Closed { - p.buf.WriteString("#EXT-X-ENDLIST\n") - } - return &p.buf -} - -// For compatibility with Stringer interface -// For example fmt.Printf("%s", sampleMediaList) will encode -// playist and print its string representation. -func (p *MediaPlaylist) String() string { - return p.Encode().String() -} - -// TargetDuration will be int on Encode -func (p *MediaPlaylist) DurationAsInt(yes bool) { - if yes { - // duration must be integers if protocol version is less than 3 - version(&p.ver, 3) - } - p.durationAsInt = yes -} - -// Count tells us the number of items that are currently in the media playlist -func (p *MediaPlaylist) Count() uint { - return p.count -} - -// Close sliding playlist and make them fixed. -func (p *MediaPlaylist) Close() { - if p.buf.Len() > 0 { - p.buf.WriteString("#EXT-X-ENDLIST\n") - } - p.Closed = true -} - -// Set encryption key appeared once in header of the playlist (pointer to MediaPlaylist.Key). -// It useful when keys not changed during playback. -// Set tag for the whole list. -func (p *MediaPlaylist) SetDefaultKey(method, uri, iv, keyformat, keyformatversions string) error { - // A Media Playlist MUST indicate a EXT-X-VERSION of 5 or higher if it - // contains: - // - The KEYFORMAT and KEYFORMATVERSIONS attributes of the EXT-X-KEY tag. - if keyformat != "" || keyformatversions != "" { - version(&p.ver, 5) - } - p.Key = &Key{method, uri, iv, keyformat, keyformatversions} - - return nil -} - -// Set default Media Initialization Section values for playlist (pointer to MediaPlaylist.Map). -// Set EXT-X-MAP tag for the whole playlist. -func (p *MediaPlaylist) SetDefaultMap(uri string, limit, offset int64) { - version(&p.ver, 5) // due section 4 - p.Map = &Map{uri, limit, offset} -} - -// Mark medialist as consists of only I-frames (Intra frames). -// Set tag for the whole list. -func (p *MediaPlaylist) SetIframeOnly() { - version(&p.ver, 4) // due section 4.3.3 - p.Iframe = true -} - -// Set encryption key for the current segment of media playlist (pointer to Segment.Key) -func (p *MediaPlaylist) SetKey(method, uri, iv, keyformat, keyformatversions string) error { - if p.count == 0 { - return errors.New("playlist is empty") - } - - // A Media Playlist MUST indicate a EXT-X-VERSION of 5 or higher if it - // contains: - // - The KEYFORMAT and KEYFORMATVERSIONS attributes of the EXT-X-KEY tag. - if keyformat != "" || keyformatversions != "" { - version(&p.ver, 5) - } - - p.Segments[p.last()].Key = &Key{method, uri, iv, keyformat, keyformatversions} - return nil -} - -// Set map for the current segment of media playlist (pointer to Segment.Map) -func (p *MediaPlaylist) SetMap(uri string, limit, offset int64) error { - if p.count == 0 { - return errors.New("playlist is empty") - } - version(&p.ver, 5) // due section 4 - p.Segments[p.last()].Map = &Map{uri, limit, offset} - return nil -} - -// Set limit and offset for the current media segment (EXT-X-BYTERANGE support for protocol version 4). -func (p *MediaPlaylist) SetRange(limit, offset int64) error { - if p.count == 0 { - return errors.New("playlist is empty") - } - version(&p.ver, 4) // due section 3.4.1 - p.Segments[p.last()].Limit = limit - p.Segments[p.last()].Offset = offset - return nil -} - -// SetSCTE sets the SCTE cue format for the current media segment. -// -// Deprecated: Use SetSCTE35 instead. -func (p *MediaPlaylist) SetSCTE(cue string, id string, time float64) error { - return p.SetSCTE35(&SCTE{Syntax: SCTE35_67_2014, Cue: cue, ID: id, Time: time}) -} - -// SetSCTE35 sets the SCTE cue format for the current media segment -func (p *MediaPlaylist) SetSCTE35(scte35 *SCTE) error { - if p.count == 0 { - return errors.New("playlist is empty") - } - p.Segments[p.last()].SCTE = scte35 - return nil -} - -// Set discontinuity flag for the current media segment. -// EXT-X-DISCONTINUITY indicates an encoding discontinuity between the media segment -// that follows it and the one that preceded it (i.e. file format, number and type of tracks, -// encoding parameters, encoding sequence, timestamp sequence). -func (p *MediaPlaylist) SetDiscontinuity() error { - if p.count == 0 { - return errors.New("playlist is empty") - } - p.Segments[p.last()].Discontinuity = true - return nil -} - -// Set program date and time for the current media segment. -// EXT-X-PROGRAM-DATE-TIME tag associates the first sample of a -// media segment with an absolute date and/or time. It applies only -// to the current media segment. -// Date/time format is YYYY-MM-DDThh:mm:ssZ (ISO8601) and includes time zone. -func (p *MediaPlaylist) SetProgramDateTime(value time.Time) error { - if p.count == 0 { - return errors.New("playlist is empty") - } - p.Segments[p.last()].ProgramDateTime = value - return nil -} - -// SetCustomTag sets the provided tag on the media playlist for its TagName -func (p *MediaPlaylist) SetCustomTag(tag CustomTag) { - if p.Custom == nil { - p.Custom = make(map[string]CustomTag) - } - - p.Custom[tag.TagName()] = tag -} - -// SetCustomTag sets the provided tag on the current media segment for its TagName -func (p *MediaPlaylist) SetCustomSegmentTag(tag CustomTag) error { - if p.count == 0 { - return errors.New("playlist is empty") - } - - last := p.Segments[p.last()] - - if last.Custom == nil { - last.Custom = make(map[string]CustomTag) - } - - last.Custom[tag.TagName()] = tag - - return nil -} - -// Version returns the current playlist version number -func (p *MediaPlaylist) Version() uint8 { - return p.ver -} - -// SetVersion sets the playlist version number, note the version maybe changed -// automatically by other Set methods. -func (p *MediaPlaylist) SetVersion(ver uint8) { - p.ver = ver -} - -// WinSize returns the playlist's window size. -func (p *MediaPlaylist) WinSize() uint { - return p.winsize -} - -// SetWinSize overwrites the playlist's window size. -func (p *MediaPlaylist) SetWinSize(winsize uint) error { - if winsize > p.capacity { - return errors.New("capacity must be greater than winsize or equal") - } - p.winsize = winsize - return nil -} diff --git a/vendor/github.com/satori/go.uuid/.travis.yml b/vendor/github.com/satori/go.uuid/.travis.yml new file mode 100644 index 0000000..20dd53b --- /dev/null +++ b/vendor/github.com/satori/go.uuid/.travis.yml @@ -0,0 +1,23 @@ +language: go +sudo: false +go: + - 1.2 + - 1.3 + - 1.4 + - 1.5 + - 1.6 + - 1.7 + - 1.8 + - 1.9 + - tip +matrix: + allow_failures: + - go: tip + fast_finish: true +before_install: + - go get github.com/mattn/goveralls + - go get golang.org/x/tools/cmd/cover +script: + - $HOME/gopath/bin/goveralls -service=travis-ci +notifications: + email: false diff --git a/vendor/github.com/satori/go.uuid/LICENSE b/vendor/github.com/satori/go.uuid/LICENSE new file mode 100644 index 0000000..926d549 --- /dev/null +++ b/vendor/github.com/satori/go.uuid/LICENSE @@ -0,0 +1,20 @@ +Copyright (C) 2013-2018 by Maxim Bublis + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/github.com/satori/go.uuid/README.md b/vendor/github.com/satori/go.uuid/README.md new file mode 100644 index 0000000..7b1a722 --- /dev/null +++ b/vendor/github.com/satori/go.uuid/README.md @@ -0,0 +1,65 @@ +# UUID package for Go language + +[![Build Status](https://travis-ci.org/satori/go.uuid.png?branch=master)](https://travis-ci.org/satori/go.uuid) +[![Coverage Status](https://coveralls.io/repos/github/satori/go.uuid/badge.svg?branch=master)](https://coveralls.io/github/satori/go.uuid) +[![GoDoc](http://godoc.org/github.com/satori/go.uuid?status.png)](http://godoc.org/github.com/satori/go.uuid) + +This package provides pure Go implementation of Universally Unique Identifier (UUID). Supported both creation and parsing of UUIDs. + +With 100% test coverage and benchmarks out of box. + +Supported versions: +* Version 1, based on timestamp and MAC address (RFC 4122) +* Version 2, based on timestamp, MAC address and POSIX UID/GID (DCE 1.1) +* Version 3, based on MD5 hashing (RFC 4122) +* Version 4, based on random numbers (RFC 4122) +* Version 5, based on SHA-1 hashing (RFC 4122) + +## Installation + +Use the `go` command: + + $ go get github.com/satori/go.uuid + +## Requirements + +UUID package requires Go >= 1.2. + +## Example + +```go +package main + +import ( + "fmt" + "github.com/satori/go.uuid" +) + +func main() { + // Creating UUID Version 4 + u1 := uuid.NewV4() + fmt.Printf("UUIDv4: %s\n", u1) + + // Parsing UUID from string input + u2, err := uuid.FromString("6ba7b810-9dad-11d1-80b4-00c04fd430c8") + if err != nil { + fmt.Printf("Something gone wrong: %s", err) + } + fmt.Printf("Successfully parsed: %s", u2) +} +``` + +## Documentation + +[Documentation](http://godoc.org/github.com/satori/go.uuid) is hosted at GoDoc project. + +## Links +* [RFC 4122](http://tools.ietf.org/html/rfc4122) +* [DCE 1.1: Authentication and Security Services](http://pubs.opengroup.org/onlinepubs/9696989899/chap5.htm#tagcjh_08_02_01_01) + +## Copyright + +Copyright (C) 2013-2018 by Maxim Bublis . + +UUID package released under MIT License. +See [LICENSE](https://github.com/satori/go.uuid/blob/master/LICENSE) for details. diff --git a/vendor/github.com/satori/go.uuid/codec.go b/vendor/github.com/satori/go.uuid/codec.go new file mode 100644 index 0000000..656892c --- /dev/null +++ b/vendor/github.com/satori/go.uuid/codec.go @@ -0,0 +1,206 @@ +// Copyright (C) 2013-2018 by Maxim Bublis +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +package uuid + +import ( + "bytes" + "encoding/hex" + "fmt" +) + +// FromBytes returns UUID converted from raw byte slice input. +// It will return error if the slice isn't 16 bytes long. +func FromBytes(input []byte) (u UUID, err error) { + err = u.UnmarshalBinary(input) + return +} + +// FromBytesOrNil returns UUID converted from raw byte slice input. +// Same behavior as FromBytes, but returns a Nil UUID on error. +func FromBytesOrNil(input []byte) UUID { + uuid, err := FromBytes(input) + if err != nil { + return Nil + } + return uuid +} + +// FromString returns UUID parsed from string input. +// Input is expected in a form accepted by UnmarshalText. +func FromString(input string) (u UUID, err error) { + err = u.UnmarshalText([]byte(input)) + return +} + +// FromStringOrNil returns UUID parsed from string input. +// Same behavior as FromString, but returns a Nil UUID on error. +func FromStringOrNil(input string) UUID { + uuid, err := FromString(input) + if err != nil { + return Nil + } + return uuid +} + +// MarshalText implements the encoding.TextMarshaler interface. +// The encoding is the same as returned by String. +func (u UUID) MarshalText() (text []byte, err error) { + text = []byte(u.String()) + return +} + +// UnmarshalText implements the encoding.TextUnmarshaler interface. +// Following formats are supported: +// "6ba7b810-9dad-11d1-80b4-00c04fd430c8", +// "{6ba7b810-9dad-11d1-80b4-00c04fd430c8}", +// "urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8" +// "6ba7b8109dad11d180b400c04fd430c8" +// ABNF for supported UUID text representation follows: +// uuid := canonical | hashlike | braced | urn +// plain := canonical | hashlike +// canonical := 4hexoct '-' 2hexoct '-' 2hexoct '-' 6hexoct +// hashlike := 12hexoct +// braced := '{' plain '}' +// urn := URN ':' UUID-NID ':' plain +// URN := 'urn' +// UUID-NID := 'uuid' +// 12hexoct := 6hexoct 6hexoct +// 6hexoct := 4hexoct 2hexoct +// 4hexoct := 2hexoct 2hexoct +// 2hexoct := hexoct hexoct +// hexoct := hexdig hexdig +// hexdig := '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | +// 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | +// 'A' | 'B' | 'C' | 'D' | 'E' | 'F' +func (u *UUID) UnmarshalText(text []byte) (err error) { + switch len(text) { + case 32: + return u.decodeHashLike(text) + case 36: + return u.decodeCanonical(text) + case 38: + return u.decodeBraced(text) + case 41: + fallthrough + case 45: + return u.decodeURN(text) + default: + return fmt.Errorf("uuid: incorrect UUID length: %s", text) + } +} + +// decodeCanonical decodes UUID string in format +// "6ba7b810-9dad-11d1-80b4-00c04fd430c8". +func (u *UUID) decodeCanonical(t []byte) (err error) { + if t[8] != '-' || t[13] != '-' || t[18] != '-' || t[23] != '-' { + return fmt.Errorf("uuid: incorrect UUID format %s", t) + } + + src := t[:] + dst := u[:] + + for i, byteGroup := range byteGroups { + if i > 0 { + src = src[1:] // skip dash + } + _, err = hex.Decode(dst[:byteGroup/2], src[:byteGroup]) + if err != nil { + return + } + src = src[byteGroup:] + dst = dst[byteGroup/2:] + } + + return +} + +// decodeHashLike decodes UUID string in format +// "6ba7b8109dad11d180b400c04fd430c8". +func (u *UUID) decodeHashLike(t []byte) (err error) { + src := t[:] + dst := u[:] + + if _, err = hex.Decode(dst, src); err != nil { + return err + } + return +} + +// decodeBraced decodes UUID string in format +// "{6ba7b810-9dad-11d1-80b4-00c04fd430c8}" or in format +// "{6ba7b8109dad11d180b400c04fd430c8}". +func (u *UUID) decodeBraced(t []byte) (err error) { + l := len(t) + + if t[0] != '{' || t[l-1] != '}' { + return fmt.Errorf("uuid: incorrect UUID format %s", t) + } + + return u.decodePlain(t[1 : l-1]) +} + +// decodeURN decodes UUID string in format +// "urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8" or in format +// "urn:uuid:6ba7b8109dad11d180b400c04fd430c8". +func (u *UUID) decodeURN(t []byte) (err error) { + total := len(t) + + urn_uuid_prefix := t[:9] + + if !bytes.Equal(urn_uuid_prefix, urnPrefix) { + return fmt.Errorf("uuid: incorrect UUID format: %s", t) + } + + return u.decodePlain(t[9:total]) +} + +// decodePlain decodes UUID string in canonical format +// "6ba7b810-9dad-11d1-80b4-00c04fd430c8" or in hash-like format +// "6ba7b8109dad11d180b400c04fd430c8". +func (u *UUID) decodePlain(t []byte) (err error) { + switch len(t) { + case 32: + return u.decodeHashLike(t) + case 36: + return u.decodeCanonical(t) + default: + return fmt.Errorf("uuid: incorrrect UUID length: %s", t) + } +} + +// MarshalBinary implements the encoding.BinaryMarshaler interface. +func (u UUID) MarshalBinary() (data []byte, err error) { + data = u.Bytes() + return +} + +// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface. +// It will return error if the slice isn't 16 bytes long. +func (u *UUID) UnmarshalBinary(data []byte) (err error) { + if len(data) != Size { + err = fmt.Errorf("uuid: UUID must be exactly 16 bytes long, got %d bytes", len(data)) + return + } + copy(u[:], data) + + return +} diff --git a/vendor/github.com/satori/go.uuid/generator.go b/vendor/github.com/satori/go.uuid/generator.go new file mode 100644 index 0000000..3f2f1da --- /dev/null +++ b/vendor/github.com/satori/go.uuid/generator.go @@ -0,0 +1,239 @@ +// Copyright (C) 2013-2018 by Maxim Bublis +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +package uuid + +import ( + "crypto/md5" + "crypto/rand" + "crypto/sha1" + "encoding/binary" + "hash" + "net" + "os" + "sync" + "time" +) + +// Difference in 100-nanosecond intervals between +// UUID epoch (October 15, 1582) and Unix epoch (January 1, 1970). +const epochStart = 122192928000000000 + +var ( + global = newDefaultGenerator() + + epochFunc = unixTimeFunc + posixUID = uint32(os.Getuid()) + posixGID = uint32(os.Getgid()) +) + +// NewV1 returns UUID based on current timestamp and MAC address. +func NewV1() UUID { + return global.NewV1() +} + +// NewV2 returns DCE Security UUID based on POSIX UID/GID. +func NewV2(domain byte) UUID { + return global.NewV2(domain) +} + +// NewV3 returns UUID based on MD5 hash of namespace UUID and name. +func NewV3(ns UUID, name string) UUID { + return global.NewV3(ns, name) +} + +// NewV4 returns random generated UUID. +func NewV4() UUID { + return global.NewV4() +} + +// NewV5 returns UUID based on SHA-1 hash of namespace UUID and name. +func NewV5(ns UUID, name string) UUID { + return global.NewV5(ns, name) +} + +// Generator provides interface for generating UUIDs. +type Generator interface { + NewV1() UUID + NewV2(domain byte) UUID + NewV3(ns UUID, name string) UUID + NewV4() UUID + NewV5(ns UUID, name string) UUID +} + +// Default generator implementation. +type generator struct { + storageOnce sync.Once + storageMutex sync.Mutex + + lastTime uint64 + clockSequence uint16 + hardwareAddr [6]byte +} + +func newDefaultGenerator() Generator { + return &generator{} +} + +// NewV1 returns UUID based on current timestamp and MAC address. +func (g *generator) NewV1() UUID { + u := UUID{} + + timeNow, clockSeq, hardwareAddr := g.getStorage() + + binary.BigEndian.PutUint32(u[0:], uint32(timeNow)) + binary.BigEndian.PutUint16(u[4:], uint16(timeNow>>32)) + binary.BigEndian.PutUint16(u[6:], uint16(timeNow>>48)) + binary.BigEndian.PutUint16(u[8:], clockSeq) + + copy(u[10:], hardwareAddr) + + u.SetVersion(V1) + u.SetVariant(VariantRFC4122) + + return u +} + +// NewV2 returns DCE Security UUID based on POSIX UID/GID. +func (g *generator) NewV2(domain byte) UUID { + u := UUID{} + + timeNow, clockSeq, hardwareAddr := g.getStorage() + + switch domain { + case DomainPerson: + binary.BigEndian.PutUint32(u[0:], posixUID) + case DomainGroup: + binary.BigEndian.PutUint32(u[0:], posixGID) + } + + binary.BigEndian.PutUint16(u[4:], uint16(timeNow>>32)) + binary.BigEndian.PutUint16(u[6:], uint16(timeNow>>48)) + binary.BigEndian.PutUint16(u[8:], clockSeq) + u[9] = domain + + copy(u[10:], hardwareAddr) + + u.SetVersion(V2) + u.SetVariant(VariantRFC4122) + + return u +} + +// NewV3 returns UUID based on MD5 hash of namespace UUID and name. +func (g *generator) NewV3(ns UUID, name string) UUID { + u := newFromHash(md5.New(), ns, name) + u.SetVersion(V3) + u.SetVariant(VariantRFC4122) + + return u +} + +// NewV4 returns random generated UUID. +func (g *generator) NewV4() UUID { + u := UUID{} + g.safeRandom(u[:]) + u.SetVersion(V4) + u.SetVariant(VariantRFC4122) + + return u +} + +// NewV5 returns UUID based on SHA-1 hash of namespace UUID and name. +func (g *generator) NewV5(ns UUID, name string) UUID { + u := newFromHash(sha1.New(), ns, name) + u.SetVersion(V5) + u.SetVariant(VariantRFC4122) + + return u +} + +func (g *generator) initStorage() { + g.initClockSequence() + g.initHardwareAddr() +} + +func (g *generator) initClockSequence() { + buf := make([]byte, 2) + g.safeRandom(buf) + g.clockSequence = binary.BigEndian.Uint16(buf) +} + +func (g *generator) initHardwareAddr() { + interfaces, err := net.Interfaces() + if err == nil { + for _, iface := range interfaces { + if len(iface.HardwareAddr) >= 6 { + copy(g.hardwareAddr[:], iface.HardwareAddr) + return + } + } + } + + // Initialize hardwareAddr randomly in case + // of real network interfaces absence + g.safeRandom(g.hardwareAddr[:]) + + // Set multicast bit as recommended in RFC 4122 + g.hardwareAddr[0] |= 0x01 +} + +func (g *generator) safeRandom(dest []byte) { + if _, err := rand.Read(dest); err != nil { + panic(err) + } +} + +// Returns UUID v1/v2 storage state. +// Returns epoch timestamp, clock sequence, and hardware address. +func (g *generator) getStorage() (uint64, uint16, []byte) { + g.storageOnce.Do(g.initStorage) + + g.storageMutex.Lock() + defer g.storageMutex.Unlock() + + timeNow := epochFunc() + // Clock changed backwards since last UUID generation. + // Should increase clock sequence. + if timeNow <= g.lastTime { + g.clockSequence++ + } + g.lastTime = timeNow + + return timeNow, g.clockSequence, g.hardwareAddr[:] +} + +// Returns difference in 100-nanosecond intervals between +// UUID epoch (October 15, 1582) and current time. +// This is default epoch calculation function. +func unixTimeFunc() uint64 { + return epochStart + uint64(time.Now().UnixNano()/100) +} + +// Returns UUID based on hashing of namespace UUID and name. +func newFromHash(h hash.Hash, ns UUID, name string) UUID { + u := UUID{} + h.Write(ns[:]) + h.Write([]byte(name)) + copy(u[:], h.Sum(nil)) + + return u +} diff --git a/vendor/github.com/satori/go.uuid/sql.go b/vendor/github.com/satori/go.uuid/sql.go new file mode 100644 index 0000000..56759d3 --- /dev/null +++ b/vendor/github.com/satori/go.uuid/sql.go @@ -0,0 +1,78 @@ +// Copyright (C) 2013-2018 by Maxim Bublis +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +package uuid + +import ( + "database/sql/driver" + "fmt" +) + +// Value implements the driver.Valuer interface. +func (u UUID) Value() (driver.Value, error) { + return u.String(), nil +} + +// Scan implements the sql.Scanner interface. +// A 16-byte slice is handled by UnmarshalBinary, while +// a longer byte slice or a string is handled by UnmarshalText. +func (u *UUID) Scan(src interface{}) error { + switch src := src.(type) { + case []byte: + if len(src) == Size { + return u.UnmarshalBinary(src) + } + return u.UnmarshalText(src) + + case string: + return u.UnmarshalText([]byte(src)) + } + + return fmt.Errorf("uuid: cannot convert %T to UUID", src) +} + +// NullUUID can be used with the standard sql package to represent a +// UUID value that can be NULL in the database +type NullUUID struct { + UUID UUID + Valid bool +} + +// Value implements the driver.Valuer interface. +func (u NullUUID) Value() (driver.Value, error) { + if !u.Valid { + return nil, nil + } + // Delegate to UUID Value function + return u.UUID.Value() +} + +// Scan implements the sql.Scanner interface. +func (u *NullUUID) Scan(src interface{}) error { + if src == nil { + u.UUID, u.Valid = Nil, false + return nil + } + + // Delegate to UUID Scan function + u.Valid = true + return u.UUID.Scan(src) +} diff --git a/vendor/github.com/satori/go.uuid/uuid.go b/vendor/github.com/satori/go.uuid/uuid.go new file mode 100644 index 0000000..a2b8e2c --- /dev/null +++ b/vendor/github.com/satori/go.uuid/uuid.go @@ -0,0 +1,161 @@ +// Copyright (C) 2013-2018 by Maxim Bublis +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +// Package uuid provides implementation of Universally Unique Identifier (UUID). +// Supported versions are 1, 3, 4 and 5 (as specified in RFC 4122) and +// version 2 (as specified in DCE 1.1). +package uuid + +import ( + "bytes" + "encoding/hex" +) + +// Size of a UUID in bytes. +const Size = 16 + +// UUID representation compliant with specification +// described in RFC 4122. +type UUID [Size]byte + +// UUID versions +const ( + _ byte = iota + V1 + V2 + V3 + V4 + V5 +) + +// UUID layout variants. +const ( + VariantNCS byte = iota + VariantRFC4122 + VariantMicrosoft + VariantFuture +) + +// UUID DCE domains. +const ( + DomainPerson = iota + DomainGroup + DomainOrg +) + +// String parse helpers. +var ( + urnPrefix = []byte("urn:uuid:") + byteGroups = []int{8, 4, 4, 4, 12} +) + +// Nil is special form of UUID that is specified to have all +// 128 bits set to zero. +var Nil = UUID{} + +// Predefined namespace UUIDs. +var ( + NamespaceDNS = Must(FromString("6ba7b810-9dad-11d1-80b4-00c04fd430c8")) + NamespaceURL = Must(FromString("6ba7b811-9dad-11d1-80b4-00c04fd430c8")) + NamespaceOID = Must(FromString("6ba7b812-9dad-11d1-80b4-00c04fd430c8")) + NamespaceX500 = Must(FromString("6ba7b814-9dad-11d1-80b4-00c04fd430c8")) +) + +// Equal returns true if u1 and u2 equals, otherwise returns false. +func Equal(u1 UUID, u2 UUID) bool { + return bytes.Equal(u1[:], u2[:]) +} + +// Version returns algorithm version used to generate UUID. +func (u UUID) Version() byte { + return u[6] >> 4 +} + +// Variant returns UUID layout variant. +func (u UUID) Variant() byte { + switch { + case (u[8] >> 7) == 0x00: + return VariantNCS + case (u[8] >> 6) == 0x02: + return VariantRFC4122 + case (u[8] >> 5) == 0x06: + return VariantMicrosoft + case (u[8] >> 5) == 0x07: + fallthrough + default: + return VariantFuture + } +} + +// Bytes returns bytes slice representation of UUID. +func (u UUID) Bytes() []byte { + return u[:] +} + +// Returns canonical string representation of UUID: +// xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx. +func (u UUID) String() string { + buf := make([]byte, 36) + + hex.Encode(buf[0:8], u[0:4]) + buf[8] = '-' + hex.Encode(buf[9:13], u[4:6]) + buf[13] = '-' + hex.Encode(buf[14:18], u[6:8]) + buf[18] = '-' + hex.Encode(buf[19:23], u[8:10]) + buf[23] = '-' + hex.Encode(buf[24:], u[10:]) + + return string(buf) +} + +// SetVersion sets version bits. +func (u *UUID) SetVersion(v byte) { + u[6] = (u[6] & 0x0f) | (v << 4) +} + +// SetVariant sets variant bits. +func (u *UUID) SetVariant(v byte) { + switch v { + case VariantNCS: + u[8] = (u[8]&(0xff>>1) | (0x00 << 7)) + case VariantRFC4122: + u[8] = (u[8]&(0xff>>2) | (0x02 << 6)) + case VariantMicrosoft: + u[8] = (u[8]&(0xff>>3) | (0x06 << 5)) + case VariantFuture: + fallthrough + default: + u[8] = (u[8]&(0xff>>3) | (0x07 << 5)) + } +} + +// Must is a helper that wraps a call to a function returning (UUID, error) +// and panics if the error is non-nil. It is intended for use in variable +// initializations such as +// var packageUUID = uuid.Must(uuid.FromString("123e4567-e89b-12d3-a456-426655440000")); +func Must(u UUID, err error) UUID { + if err != nil { + panic(err) + } + return u +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 6840b80..92f13b3 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -11,8 +11,6 @@ github.com/gin-gonic/gin/json github.com/gin-gonic/gin/render # github.com/golang/protobuf v1.2.0 github.com/golang/protobuf/proto -# github.com/grafov/m3u8 v0.11.1 -github.com/grafov/m3u8 # github.com/hashicorp/hcl v1.0.0 github.com/hashicorp/hcl github.com/hashicorp/hcl/hcl/ast @@ -44,6 +42,8 @@ github.com/modern-go/concurrent github.com/modern-go/reflect2 # github.com/pelletier/go-toml v1.2.0 github.com/pelletier/go-toml +# github.com/satori/go.uuid v1.2.0 +github.com/satori/go.uuid # github.com/spf13/afero v1.1.2 github.com/spf13/afero github.com/spf13/afero/mem