Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: wrong type of field in struct Dash #98

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

scarletborder
Copy link

修改video.go/Dash 结构体的以下字段

Minbuffertime int            `json:"minBufferTime"`   // 1.5?
MinBufferTime int            `json:"min_buffer_time"` // 1.5?

不再出现断言在 util.go:72

if err = json.Unmarshal(resp.Body(), &cr); err != nil {
		return out, errors.WithStack(err)
	}

时导致的
json: cannot unmarshal number 1.5 into Go struct field Dash.data.dash.minBufferTime of type int

@scarletborder
Copy link
Author

补充一下原先问题的复现代码

// client已经设置了cookies
res, err := client.GetVideoPageList(bilibili.VideoParam{
		Bvid: "1FEzoYvEDh",
	})

	if err != nil {
		fmt.Println(err)
		return
	}

	var final_cid int
	fmt.Println("==cid list==")
	for idx, val := range res {
		fmt.Printf("idx: %d\n", idx)
		fmt.Println(val.Cid)
		final_cid = val.Cid
	}

	_res, err := client.GetVideoStream(bilibili.GetVideoStreamParam{
		Bvid:  "1FEzoYvEDh",
		Fnval: 16,
		Cid:   final_cid,
	})

	if err != nil {
		fmt.Println(err)
		return
	}


	for idx, val := range _res.Dash.Audio {
		fmt.Printf("idx: %d\n", idx)
		fmt.Println(val.Baseurl)
		fmt.Println("backup")
		fmt.Println(val.Backupurl)
	}

Output:

==cid list==
idx: 0
27122141682
json: cannot unmarshal number 1.5 into Go struct field Dash.data.dash.minBufferTime of type int

修复后

Output

=cid list==
idx: 0
27122141682
idx: 0
https://xy112x29x112x205xy.mcdn.bilivideo.cn:8082/v1/resource/27122141682-1-30280.m4s?agrr=1&b...
backup
[https://xy118x184x254x112xy240ey5ay7820y1y1yy112xy.mcdn.bilivideo.cn:4483/upgcxcode/82/16/27122141682/27122141682-1-30280.m4s?e=ig8e...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant