Skip to content
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

Fix issues with getting PDF pages #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
18 changes: 9 additions & 9 deletions ZiniGo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand All @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion built/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down