Skip to content

Fall back on playback url if downloading is not allowed #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions cmd/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)})
}
}
}
Expand Down Expand Up @@ -119,8 +121,10 @@ type ItemsResponse struct {
Title string
}
Audios []struct {
Title string
DownloadUrl string
Title string
DownloadUrl string
AllowDownload bool
Url string
}
}
}
Expand All @@ -142,7 +146,9 @@ func getProgramUrls(queryId string) ([]File, error) {
}
audios {
title
downloadUrl
downloadUrl,
allowDownload,
url
}
}
}
Expand Down Expand Up @@ -210,6 +216,7 @@ func getEpisodeUrls(queryId string) ([]File, error) {
Audios []struct {
Title string
DownloadUrl *string
Url string
}
}
}
Expand All @@ -222,7 +229,8 @@ func getEpisodeUrls(queryId string) ([]File, error) {
audios {
title
downloadUrl
}
url
}
}
}`
variables := map[string]interface{}{
Expand All @@ -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)
}
}
}
Expand Down