Skip to content

Commit

Permalink
fix(source) bilibili: in some case the cookie is not required
Browse files Browse the repository at this point in the history
  • Loading branch information
foamzou committed May 13, 2023
1 parent b5b044f commit 09c5558
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion LATEST_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.9
0.2.10
9 changes: 5 additions & 4 deletions processor/bilibili/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ const APIFinger = "https://api.bilibili.com/x/frontend/finger/spi"
const SearchPageUrl = "https://search.bilibili.com/all"

func (c *Core) SearchSong() ([]*meta.SearchSongItem, error) {
cookie, err := utils.GetCookie(consts.SourceNameBilibili, SearchPageUrl, map[string]string{
cookie, _ := utils.GetCookie(consts.SourceNameBilibili, SearchPageUrl, map[string]string{
"User-Agent": consts.UAMac,
"Referer": "https://search.bilibili.com/",
}, false)
if err != nil {
return nil, err
}
// In some case, the cookie is not required
//if err != nil {
// return nil, err
//}

fingerJsonStr, err := utils.HttpGet(consts.SourceNameBilibili, APIFinger, map[string]string{
"User-Agent": consts.UAMac,
Expand Down
1 change: 0 additions & 1 deletion processor/bilibili/search_entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ type SearchSongResponse struct {
RankScore int `json:"rank_score"`
Like int `json:"like"`
Upic string `json:"upic"`
Corner string `json:"corner"`
Cover string `json:"cover"`
Desc string `json:"desc"`
Url string `json:"url"`
Expand Down
10 changes: 10 additions & 0 deletions processor/bilibili/search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ func TestCore_SearchSong(t *testing.T) {
Source: consts.SourceNameBilibili,
},
},
{
name: "Test search video",
fields: fields{Opts: &args.Options{Search: args.Search{Keyword: "热带雨林", Type: "song"}}},
wantSongItem: &meta.SearchSongItem{
Name: "【S.H.E】热带雨林-720P修复版 周杰伦作曲",
Artist: "zyl2012",
Url: "bilibili",
Source: consts.SourceNameBilibili,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
)

const (
BuildCode = 14
BuildName = "0.2.9"
BuildCode = 15
BuildName = "0.2.10"
Repo = "https://github.com/foamzou/media-get"
)

Expand Down

0 comments on commit 09c5558

Please sign in to comment.