Fix issues with getting PDF pages
This commit is contained in:
parent
05fb51e18f
commit
f488750132
|
|
@ -140,18 +140,18 @@ func main() {
|
||||||
|
|
||||||
var filenames []string
|
var filenames []string
|
||||||
conf := pdfcpu.NewAESConfiguration(passwordToUse, passwordToUse, 256)
|
conf := pdfcpu.NewAESConfiguration(passwordToUse, passwordToUse, 256)
|
||||||
for i := 0; i < len(pages.Data); i++ {
|
for i := 0; i < len(pages.Data.Pages); i++ {
|
||||||
if len(pages.Data[i].Src) == 0 {
|
if len(pages.Data.Pages[i].Src) == 0 {
|
||||||
|
|
||||||
fmt.Println("No Download URL for page ", i)
|
fmt.Println("No Download URL for page ", i)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
fmt.Println("Source ", pages.Data[i].Src)
|
fmt.Println("Source ", pages.Data.Pages[i].Src)
|
||||||
fmt.Println("ID: ", pages.Data[i].Index)
|
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
|
// handle the error if there is one
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|
@ -216,11 +216,11 @@ func GetIssueDetails(userToken LoginResponse, id int) IssueDetails {
|
||||||
return responseType
|
return responseType
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetPages(userToken LoginResponse, issue LibraryData, endpoint string) AutoGenerated {
|
func GetPages(userToken LoginResponse, issue LibraryData, endpoint string) IssueDetails {
|
||||||
|
|
||||||
client := &http.Client{}
|
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")
|
req.Header.Add("Content-Type", "application/json")
|
||||||
for _, cookie := range userToken.Data.Cookies {
|
for _, cookie := range userToken.Data.Cookies {
|
||||||
|
|
@ -231,7 +231,7 @@ func GetPages(userToken LoginResponse, issue LibraryData, endpoint string) AutoG
|
||||||
resp, _ := client.Do(req)
|
resp, _ := client.Do(req)
|
||||||
data, _ := ioutil.ReadAll(resp.Body)
|
data, _ := ioutil.ReadAll(resp.Body)
|
||||||
|
|
||||||
responseType := AutoGenerated{}
|
responseType := IssueDetails{}
|
||||||
|
|
||||||
_ = json.Unmarshal([]byte(data), &responseType)
|
_ = json.Unmarshal([]byte(data), &responseType)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<object type="image/svg+xml" data="SVG_PATH</object>
|
<object type="image/svg+xml" data="SVG_PATH"></object>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
window.onload = fixpage;
|
window.onload = fixpage;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue