From f3fd34626749128d8107c020307c0700c5e34677 Mon Sep 17 00:00:00 2001 From: fbngrmr Date: Mon, 1 Apr 2024 13:02:00 +0200 Subject: [PATCH] Fallback to playback url if downloading is not allowed --- cmd/download.go | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/cmd/download.go b/cmd/download.go index 90ffc06..1aa5ea8 100644 --- a/cmd/download.go +++ b/cmd/download.go @@ -74,6 +74,8 @@ func extractDownloadUrls(response *ItemsResponse) []File { for _, audios := range nodes.Audios { if audios.DownloadUrl != "" { files = append(files, File{url: audios.DownloadUrl, fileName: toFileName(audios.Title, nodes.ProgramSet.Title)}) + } else if audios.Url != "" { + files = append(files, File{url: audios.Url, fileName: toFileName(audios.Title, nodes.ProgramSet.Title)}) } } } @@ -119,8 +121,10 @@ type ItemsResponse struct { Title string } Audios []struct { - Title string - DownloadUrl string + Title string + DownloadUrl string + AllowDownload bool + Url string } } } @@ -142,7 +146,9 @@ func getProgramUrls(queryId string) ([]File, error) { } audios { title - downloadUrl + downloadUrl, + allowDownload, + url } } } @@ -210,6 +216,7 @@ func getEpisodeUrls(queryId string) ([]File, error) { Audios []struct { Title string DownloadUrl *string + Url string } } } @@ -222,7 +229,8 @@ func getEpisodeUrls(queryId string) ([]File, error) { audios { title downloadUrl - } + url + } } }` variables := map[string]interface{}{ @@ -242,6 +250,9 @@ func getEpisodeUrls(queryId string) ([]File, error) { if *audios.DownloadUrl != "" { file := File{url: *audios.DownloadUrl, fileName: toFileName(audios.Title, response.Result.ProgramSet.Title)} files = append(files, file) + } else { + file := File{url: *&audios.Url, fileName: toFileName(audios.Title, response.Result.ProgramSet.Title)} + files = append(files, file) } } }