Skip to content

Commit

Permalink
extractors/bilibili: print quality information
Browse files Browse the repository at this point in the history
  • Loading branch information
iawia002 committed Mar 7, 2018
1 parent 533be8e commit 167427d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ var FakeHeaders = map[string]string{
"Accept-Charset": "UTF-8,*;q=0.5",
"Accept-Encoding": "gzip,deflate,sdch",
"Accept-Language": "en-US,en;q=0.8",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:51.0) Gecko/20100101 Firefox/51.0",
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146 Safari/537.36",
}
18 changes: 11 additions & 7 deletions downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,21 @@ type VideoData struct {
// [URLData: {URL, Size, Ext}, ...]
// Some video files have multiple fragments
// and support for downloading multiple image files at once
URLs []URLData
Size int64
Type string
URLs []URLData
Size int64
Type string
Quality string
}

func (data VideoData) printInfo() {
fmt.Println()
fmt.Println(" Site: ", data.Site)
fmt.Println("Title: ", data.Title)
fmt.Println(" Type: ", data.Type)
fmt.Printf(" Size: %.2f MiB (%d Bytes)\n", float64(data.Size)/(1024*1024), data.Size)
fmt.Println(" Site: ", data.Site)
fmt.Println(" Title: ", data.Title)
fmt.Println(" Type: ", data.Type)
if data.Quality != "" {
fmt.Println("Quality: ", data.Quality)
}
fmt.Printf(" Size: %.2f MiB (%d Bytes)\n", float64(data.Size)/(1024*1024), data.Size)
fmt.Println()
}

Expand Down
20 changes: 15 additions & 5 deletions extractors/bilibili.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ type bangumiData struct {
EpList []bangumiEpData `json:"epList"`
}

var quality = map[int]string{
116: "高清 1080P60",
74: "高清 720P60",
80: "高清 1080P",
64: "高清 720P",
32: "清晰 480P",
15: "流畅 360P",
}

func getSign(params string) string {
sign := md5.New()
sign.Write([]byte(params + secKey))
Expand Down Expand Up @@ -186,11 +195,12 @@ func download(url string, bangumi bool) downloader.VideoData {

urls, size := genURL(dataDict.DURL)
data := downloader.VideoData{
Site: "哔哩哔哩 bilibili.com",
Title: utils.FileName(title),
URLs: urls,
Type: "video",
Size: size,
Site: "哔哩哔哩 bilibili.com",
Title: utils.FileName(title),
URLs: urls,
Type: "video",
Size: size,
Quality: quality[dataDict.Quality],
}
data.Download(url)
return data
Expand Down

0 comments on commit 167427d

Please sign in to comment.