Skip to content

Commit

Permalink
Add durl to stream map
Browse files Browse the repository at this point in the history
  • Loading branch information
oak64 committed Apr 21, 2022
1 parent 00c0e8f commit 4b3987d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
24 changes: 24 additions & 0 deletions extractors/bilibili/bilibili.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,30 @@ func bilibiliDownload(options bilibiliOptions, extractOption extractors.Options)
}
}

for _, durl := range dashData.DURLs {
var ext string
switch dashData.DURLFormat {
case "flv", "flv480":
ext = "flv"
case "mp4", "hdmp4":
ext = "mp4"
}

parts := make([]*extractors.Part, 0, 1)
parts = append(parts, &extractors.Part{
URL: durl.URL,
Size: durl.Size,
Ext: ext,
})

id := strconv.Itoa(dashData.CurQuality)
streams[id] = &extractors.Stream{
Parts: parts,
Size: durl.Size,
Quality: qualityString[dashData.CurQuality],
}
}

// get the title
doc, err := parser.GetDoc(html)
if err != nil {
Expand Down
7 changes: 7 additions & 0 deletions extractors/bilibili/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ type dashInfo struct {
Description []string `json:"accept_description"`
Quality []int `json:"accept_quality"`
Streams dashStreams `json:"dash"`
DURLFormat string `json:"format"`
DURLs []dURL `json:"durl"`
}

type dURL struct {
URL string `json:"url"`
Size int64 `json:"size"`
}

type dash struct {
Expand Down

0 comments on commit 4b3987d

Please sign in to comment.