From 11098f641af6a8991e4e26c7fe6d4feb49207e12 Mon Sep 17 00:00:00 2001 From: Yabo <386139859@qq.com> Date: Mon, 22 Jan 2024 12:14:23 +0800 Subject: [PATCH] :bug: fixed #201 --- cmd/app/download.go | 7 ++++++- services/media.go | 20 ++++++++++++++++++++ services/requester.go | 11 +++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/cmd/app/download.go b/cmd/app/download.go index 9b718135..baa3de40 100644 --- a/cmd/app/download.go +++ b/cmd/app/download.go @@ -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", } diff --git a/services/media.go b/services/media.go index 8ff42dce..36c27960 100644 --- a/services/media.go +++ b/services/media.go @@ -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 { @@ -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) @@ -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 +} diff --git a/services/requester.go b/services/requester.go index 258357cc..a1b882e0 100644 --- a/services/requester.go +++ b/services/requester.go @@ -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()