Skip to content

Commit

Permalink
StreamInfo -> MasterPlaylist
Browse files Browse the repository at this point in the history
  • Loading branch information
oopsguy committed Jun 18, 2019
1 parent ab3c0ac commit bed49e5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ then download and merge all TS files.
## Features

- Download and parse m3u8(VOD)
- Support Master playlist
- Support encrypted TS
- Support merge TS
- Parse Master playlist
- Decrypt TS
- Merge TS

## Usage

Expand All @@ -38,7 +38,7 @@ Linux & MacOS
Windows PowerShell

```
.\m3u8 -u="http://example.com/index.m3u8" -o="D:\data\example"
.\m3u8.exe -u="http://example.com/index.m3u8" -o="D:\data\example"
```

**help**
Expand Down
3 changes: 1 addition & 2 deletions dl/dowloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const (
tsExt = ".ts"
tsFolderName = "ts"
mergeTSFilename = "merged.ts"
tsTempFileSuffix = "_temp"
tsTempFileSuffix = "_tmp"
progressWidth = 40
)

Expand Down Expand Up @@ -208,7 +208,6 @@ func (d *Downloader) merge() error {
}
fmt.Print("/r")
mergedCount := 0
// TODO: consider using batch merging, divide merging task into multiple sub tasks in goroutine.
for segIndex := 0; segIndex < len(d.result.M3u8.Segments); segIndex++ {
tsFilename := tsFilename(segIndex)
bytes, err := ioutil.ReadFile(filepath.Join(d.tsFolder, tsFilename))
Expand Down
4 changes: 2 additions & 2 deletions parse/m3u8.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const (
CryptMethodNONE CryptMethod = "NONE"
)

var linePattern = regexp.MustCompile(`([a-zA-Z-]+)=("[^"]+"|[^",]+)`)

type M3u8 struct {
Version int8 // EXT-X-VERSION:version
MediaSequence uint64 // Default 0, #EXT-X-MEDIA-SEQUENCE:sequence
Expand Down Expand Up @@ -228,8 +230,6 @@ func parseStreamInfo(line string) (*MasterPlaylist, error) {
return mp, nil
}

var linePattern = regexp.MustCompile(`([a-zA-Z-]+)=("[^"]+"|[^",]+)`)

func parseLineParameters(line string) map[string]string {
r := linePattern.FindAllStringSubmatch(line, -1)
params := make(map[string]string)
Expand Down
4 changes: 2 additions & 2 deletions parse/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ func FromURL(link string) (*Result, error) {
if err != nil {
return nil, err
}
if m3u8.StreamInfo != nil {
sf := m3u8.StreamInfo[0]
if len(m3u8.MasterPlaylist) != 0 {
sf := m3u8.MasterPlaylist[0]
return FromURL(tool.ResolveURL(u, sf.URI))
}
if len(m3u8.Segments) == 0 {
Expand Down

0 comments on commit bed49e5

Please sign in to comment.