Skip to content

Commit

Permalink
extractors/bilibili: update the type of Aid
Browse files Browse the repository at this point in the history
  • Loading branch information
iawia002 committed Nov 8, 2019
1 parent be99311 commit f2ce53f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
26 changes: 13 additions & 13 deletions extractors/bilibili/bilibili.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ const referer = "https://www.bilibili.com"

var utoken string

func genAPI(aid, cid string, bangumi bool, quality string, seasonType string) (string, error) {
func genAPI(aid, cid int, bangumi bool, quality string, seasonType string) (string, error) {
var (
err error
baseAPIURL string
params string
)
if config.Cookie != "" && utoken == "" {
utoken, err = request.Get(
fmt.Sprintf("%said=%s&cid=%s", bilibiliTokenAPI, aid, cid),
fmt.Sprintf("%said=%d&cid=%d", bilibiliTokenAPI, aid, cid),
referer,
nil,
)
Expand All @@ -62,13 +62,13 @@ func genAPI(aid, cid string, bangumi bool, quality string, seasonType string) (s
// qn=0 flag makes the CDN address different every time
// quality=116(1080P 60) is the highest quality so far
params = fmt.Sprintf(
"appkey=%s&cid=%s&module=bangumi&otype=json&qn=%s&quality=%s&season_type=%s&type=",
"appkey=%s&cid=%d&module=bangumi&otype=json&qn=%s&quality=%s&season_type=%s&type=",
appKey, cid, quality, quality, seasonType,
)
baseAPIURL = bilibiliBangumiAPI
} else {
params = fmt.Sprintf(
"appkey=%s&cid=%s&otype=json&qn=%s&quality=%s&type=",
"appkey=%s&cid=%d&otype=json&qn=%s&quality=%s&type=",
appKey, cid, quality, quality,
)
baseAPIURL = bilibiliAPI
Expand Down Expand Up @@ -101,8 +101,8 @@ type bilibiliOptions struct {
url string
html string
bangumi bool
aid string
cid string
aid int
cid int
page int
subtitle string
}
Expand All @@ -119,8 +119,8 @@ func extractBangumi(url, html string) ([]downloader.Data, error) {
url: url,
html: html,
bangumi: true,
aid: strconv.Itoa(data.EpInfo.Aid),
cid: strconv.Itoa(data.EpInfo.Cid),
aid: data.EpInfo.Aid,
cid: data.EpInfo.Cid,
}
return []downloader.Data{bilibiliDownload(options)}, nil
}
Expand All @@ -143,8 +143,8 @@ func extractBangumi(url, html string) ([]downloader.Data, error) {
options := bilibiliOptions{
url: fmt.Sprintf("https://www.bilibili.com/bangumi/play/ep%d", id),
bangumi: true,
aid: strconv.Itoa(u.Aid),
cid: strconv.Itoa(u.Cid),
aid: u.Aid,
cid: u.Cid,
}
go func(index int, options bilibiliOptions, extractedData []downloader.Data) {
defer wgp.Done()
Expand Down Expand Up @@ -199,7 +199,7 @@ func extractNormalVideo(url, html string) ([]downloader.Data, error) {
url: url,
html: html,
aid: pageData.Aid,
cid: strconv.Itoa(page.Cid),
cid: page.Cid,
page: p,
}
// "part":"" or "part":"Untitled"
Expand All @@ -226,7 +226,7 @@ func extractNormalVideo(url, html string) ([]downloader.Data, error) {
url: url,
html: html,
aid: pageData.Aid,
cid: strconv.Itoa(u.Cid),
cid: u.Cid,
subtitle: u.Part,
page: u.Page,
}
Expand Down Expand Up @@ -332,7 +332,7 @@ func bilibiliDownload(options bilibiliOptions) downloader.Data {
}

err = downloader.Caption(
fmt.Sprintf("https://comment.bilibili.com/%s.xml", options.cid),
fmt.Sprintf("https://comment.bilibili.com/%d.xml", options.cid),
options.url, title, "xml",
)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion extractors/bilibili/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ type multiPageVideoData struct {
}

type multiPage struct {
Aid string `json:"aid"`
Aid int `json:"aid"`
VideoData multiPageVideoData `json:"videoData"`
}

Expand Down

0 comments on commit f2ce53f

Please sign in to comment.