Skip to content

Commit

Permalink
fix(bilibili): fix b23.tv
Browse files Browse the repository at this point in the history
  • Loading branch information
foamzou committed Jul 30, 2022
1 parent 8f1d5b0 commit 1d74e47
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 19 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*.so
*.dylib
/.release
/*-mp3
main

# Test binary, built with `go test -c`
Expand Down
2 changes: 1 addition & 1 deletion meta/iprocessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package meta
type IProcessor interface {
FetchMetaAndResourceInfo() (mediaMeta *MediaMeta, err error)
SearchSong() (searchItems []*SearchSongItem, err error)
Domain() string
Domains() []string
GetSourceName() string
IsMusicPlatform() bool
}
11 changes: 9 additions & 2 deletions processor/bilibili/bilibili.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,22 @@ func (c *Core) IsMusicPlatform() bool {
return false
}

func (c *Core) Domain() string {
return "bilibili.com"
func (c *Core) Domains() []string {
return []string{"bilibili.com", "b23.tv"}
}

func (c *Core) GetSourceName() string {
return consts.SourceNameBilibili
}

func (c *Core) FetchMetaAndResourceInfo() (mediaMeta *meta.MediaMeta, err error) {
if strings.Contains(c.Opts.Url, "b23.tv") {
if redirectUrl, err := utils.GetLocation(c.Opts.Url, map[string]string{
"user-agent": consts.UAAndroid,
}); err == nil {
c.Opts.Url = redirectUrl
}
}
html, err := fetchHtml(c.Opts.Url)
if err != nil {
return
Expand Down
4 changes: 2 additions & 2 deletions processor/douyin/douyin.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ func (c *Core) IsMusicPlatform() bool {
return false
}

func (c *Core) Domain() string {
return "douyin.com"
func (c *Core) Domains() []string {
return []string{"douyin.com"}
}

func (c *Core) GetSourceName() string {
Expand Down
7 changes: 5 additions & 2 deletions processor/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ func (p *Processor) getProcessor() meta.IProcessor {
var ProcessorMap = p.getProcessorMap()

for _, processor := range ProcessorMap {
if strings.Contains(p.Opts.Url, processor.Domain()) {
return processor
domains := processor.Domains()
for _, domain := range domains {
if strings.Contains(p.Opts.Url, domain) {
return processor
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions processor/kugou/kugou.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ func (c *Core) IsMusicPlatform() bool {
return true
}

func (c *Core) Domain() string {
return "kugou.com"
func (c *Core) Domains() []string {
return []string{"kugou.com"}
}

func (c *Core) GetSourceName() string {
Expand Down
4 changes: 2 additions & 2 deletions processor/kuwo/kuwo.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ func (c *Core) IsMusicPlatform() bool {
return true
}

func (c *Core) Domain() string {
return "kuwo.cn"
func (c *Core) Domains() []string {
return []string{"kuwo.cn"}
}

func (c *Core) GetSourceName() string {
Expand Down
4 changes: 2 additions & 2 deletions processor/migu/migo.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ func (c *Core) GetSourceName() string {
return consts.SourceNameMigu
}

func (c *Core) Domain() string {
return "migu.cn"
func (c *Core) Domains() []string {
return []string{"migu.cn"}
}

func (c *Core) FetchMetaAndResourceInfo() (mediaMeta *meta.MediaMeta, err error) {
Expand Down
4 changes: 2 additions & 2 deletions processor/netease/netease.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ func (c *Core) IsMusicPlatform() bool {
return true
}

func (c *Core) Domain() string {
return "163.com"
func (c *Core) Domains() []string {
return []string{"163.com"}
}

func (c *Core) GetSourceName() string {
Expand Down
4 changes: 2 additions & 2 deletions processor/qqmusic/qqmusic.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ func (c *Core) IsMusicPlatform() bool {
return true
}

func (c *Core) Domain() string {
return "qq.com"
func (c *Core) Domains() []string {
return []string{"qq.com"}
}

func (c *Core) GetSourceName() string {
Expand Down
4 changes: 2 additions & 2 deletions processor/youtube/youtube.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ func (c *Core) IsMusicPlatform() bool {
return false
}

func (c *Core) Domain() string {
return "youtube.com"
func (c *Core) Domains() []string {
return []string{"youtube.com"}
}

func (c *Core) GetSourceName() string {
Expand Down

0 comments on commit 1d74e47

Please sign in to comment.