Skip to content

Commit

Permalink
🐛 fixed #201
Browse files Browse the repository at this point in the history
  • Loading branch information
yann0917 committed Jan 22, 2024
1 parent 852153e commit 11098f6
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cmd/app/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,18 @@ func extractOdobDownloadData(aid int) []downloader.Datum {
if !article["has_play_auth"].(bool) {
isCanDL = false
}
detail, err := getService().AudioDetailAlias(aliasID)
if err != nil {
fmt.Println(err)
return nil
}
datum := &downloader.Datum{
ID: aid,
Enid: article["enid"].(string),
ClassID: int(article["class_id"].(float64)),
Title: article["title"].(string),
IsCanDL: isCanDL,
M3U8URL: article["audio_mp3_play_url"].(string),
M3U8URL: detail.Mp3PlayURL,
Streams: streams,
Type: "audio",
}
Expand Down
20 changes: 20 additions & 0 deletions services/media.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type Audio struct {
IndexImg string `json:"index_img"`
Reader string `json:"reader"`
ReaderName string `json:"reader_name"`
OdobGroupEnid string `json:"odob_group_enid"`
}

type Video struct {
Expand Down Expand Up @@ -79,6 +80,10 @@ type AudioList struct {
List []Audio `json:"list"`
}

type AudioDetail struct {
Detail Audio `json:"audio_detail"`
}

// AudioByAlias get article audio info
func (s *Service) AudioByAlias(ID string) (list *AudioList, err error) {
body, err := s.reqAudioByAlias(ID)
Expand All @@ -91,3 +96,18 @@ func (s *Service) AudioByAlias(ID string) (list *AudioList, err error) {
}
return
}

// AudioDetailAlias get odob audio info
func (s *Service) AudioDetailAlias(ID string) (detail *Audio, err error) {
adetail := AudioDetail{}
body, err := s.reqOdobAudioDetail(ID)
if err != nil {
return
}
defer body.Close()
if err = handleJSONParse(body, &adetail); err != nil {
return
}
detail = &adetail.Detail
return
}
11 changes: 11 additions & 0 deletions services/requester.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,17 @@ func (s *Service) reqOdobVIPInfo() (io.ReadCloser, error) {
return handleHTTPResponse(resp, err)
}

// reqOdobAudioDetail 请求每天听本书书 音频 info
func (s *Service) reqOdobAudioDetail(aliasID string) (io.ReadCloser, error) {
resp, err := s.client.R().
SetBody(map[string]interface{}{
"alias_id": aliasID,
}).
Post("pc/odob/pc/audio/detail/alias")

return handleHTTPResponse(resp, err)
}

// reqTopicAll 请求推荐话题列表
func (s *Service) reqTopicAll(page, limit int, all bool) (io.ReadCloser, error) {
r := s.client.R()
Expand Down

0 comments on commit 11098f6

Please sign in to comment.