Fix issues with getting PDF pages

This commit is contained in:
Charles Boyung 2024-01-31 10:18:56 -06:00
parent 05fb51e18f
commit f488750132
2 changed files with 10 additions and 10 deletions

View File

@ -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)

View File

@ -24,7 +24,7 @@
</style>
</head>
<body>
<object type="image/svg+xml" data="SVG_PATH</object>
<object type="image/svg+xml" data="SVG_PATH"></object>
<script>
window.onload = fixpage;