From f488750132e2220fb1cba79c79cd5dccbeb7cc48 Mon Sep 17 00:00:00 2001 From: Charles Boyung Date: Wed, 31 Jan 2024 10:18:56 -0600 Subject: [PATCH] Fix issues with getting PDF pages --- ZiniGo/main.go | 18 +++++++++--------- built/template.html | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ZiniGo/main.go b/ZiniGo/main.go index 440c245..7ce8d65 100644 --- a/ZiniGo/main.go +++ b/ZiniGo/main.go @@ -140,18 +140,18 @@ func main() { var filenames []string conf := pdfcpu.NewAESConfiguration(passwordToUse, passwordToUse, 256) - for i := 0; i < len(pages.Data); i++ { - if len(pages.Data[i].Src) == 0 { + for i := 0; i < len(pages.Data.Pages); i++ { + if len(pages.Data.Pages[i].Src) == 0 { fmt.Println("No Download URL for page ", i) continue } - fmt.Println("Source ", pages.Data[i].Src) - fmt.Println("ID: ", pages.Data[i].Index) + fmt.Println("Source ", pages.Data.Pages[i].Src) + fmt.Println("ID: ", pages.Data.Pages[i].Index) - pathString := issuePath + "_" + pages.Data[i].Index + pathString := issuePath + "_" + pages.Data.Pages[i].Index - resp, err := http.Get(pages.Data[i].Src) + resp, err := http.Get(pages.Data.Pages[i].Src) // handle the error if there is one if err != nil { panic(err) @@ -216,11 +216,11 @@ func GetIssueDetails(userToken LoginResponse, id int) IssueDetails { return responseType } -func GetPages(userToken LoginResponse, issue LibraryData, endpoint string) AutoGenerated { +func GetPages(userToken LoginResponse, issue LibraryData, endpoint string) IssueDetails { client := &http.Client{} - req, _ := http.NewRequest("GET", "https://zinio.com/api/newsstand/newsstands/101/issues/"+strconv.Itoa(issue.Id)+"/content/pages?format=pdf&application_id=9901&css_content=true&user_id="+userToken.Data.User.UserIDString, nil) + req, _ := http.NewRequest("GET", "https://zinio.com/api/reader/content?issue_id="+strconv.Itoa(issue.Id)+"&newsstand_id=101&user_id="+userToken.Data.User.UserIDString, nil) req.Header.Add("Content-Type", "application/json") for _, cookie := range userToken.Data.Cookies { @@ -231,7 +231,7 @@ func GetPages(userToken LoginResponse, issue LibraryData, endpoint string) AutoG resp, _ := client.Do(req) data, _ := ioutil.ReadAll(resp.Body) - responseType := AutoGenerated{} + responseType := IssueDetails{} _ = json.Unmarshal([]byte(data), &responseType) diff --git a/built/template.html b/built/template.html index 45e210a..8f4a174 100644 --- a/built/template.html +++ b/built/template.html @@ -24,7 +24,7 @@ -