Fix for issue size limit #8
This commit is contained in:
parent
d1e89f060f
commit
16cdc5896c
28
Grabazine.go
28
Grabazine.go
|
|
@ -45,7 +45,9 @@ func main() {
|
||||||
}
|
}
|
||||||
loginToken := GetLoginToken(initialToken, *usernamePtr, *passwordPtr)
|
loginToken := GetLoginToken(initialToken, *usernamePtr, *passwordPtr)
|
||||||
issues := GetLibrary(loginToken, initialToken, *zinioHostPtr)
|
issues := GetLibrary(loginToken, initialToken, *zinioHostPtr)
|
||||||
fmt.Println("Found " + strconv.Itoa(len(issues.Data)) + " issues in library.")
|
for i := range issues {
|
||||||
|
issueList := issues[i]
|
||||||
|
//fmt.Println("Found " + strconv.Itoa(len(issues.Data)) + " issues in library.")
|
||||||
|
|
||||||
fmt.Println("Loading HTML template")
|
fmt.Println("Loading HTML template")
|
||||||
defaultTemplate := GetDefaultTemplate()
|
defaultTemplate := GetDefaultTemplate()
|
||||||
|
|
@ -66,7 +68,7 @@ func main() {
|
||||||
os.Mkdir(mydir+"/issue/", os.ModeDir)
|
os.Mkdir(mydir+"/issue/", os.ModeDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, issue := range issues.Data {
|
for _, issue := range issueList.Data {
|
||||||
issuePath := mydir + "/issue/" + strconv.Itoa(issue.Id)
|
issuePath := mydir + "/issue/" + strconv.Itoa(issue.Id)
|
||||||
|
|
||||||
completeName := mydir + "/issue/" + issue.Publication.Name + " - " + issue.Name + ".pdf"
|
completeName := mydir + "/issue/" + issue.Publication.Name + " - " + issue.Name + ".pdf"
|
||||||
|
|
@ -170,7 +172,10 @@ func main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
fmt.Println("Terminating the application...")
|
fmt.Println("Terminating the application...")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetPages(userToken LoginResponse, issue LibraryData, token string, endpoint string) Response {
|
func GetPages(userToken LoginResponse, issue LibraryData, token string, endpoint string) Response {
|
||||||
|
|
@ -230,10 +235,15 @@ func GetLoginToken(initialToken string, username string, password string) LoginR
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetLibrary(userToken LoginResponse, initialToken string, endpoint string) LibraryResponse {
|
func GetLibrary(userToken LoginResponse, initialToken string, endpoint string) []LibraryResponse {
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
|
|
||||||
req, _ := http.NewRequest("GET", "https://zinio.com/api/newsstand/newsstands/101/users/"+userToken.Data.User.UserIDString+"/library_issues", nil)
|
var itemsToReturn []LibraryResponse
|
||||||
|
issuesToFetch := 120
|
||||||
|
|
||||||
|
pageToFetch := 1
|
||||||
|
for {
|
||||||
|
req, _ := http.NewRequest("GET", "https://zinio.com/api/newsstand/newsstands/101/users/"+userToken.Data.User.UserIDString+"/library_issues?limit="+strconv.Itoa(issuesToFetch)+"&page="+strconv.Itoa(pageToFetch), nil)
|
||||||
|
|
||||||
req.Header.Add("Content-Type", "application/json")
|
req.Header.Add("Content-Type", "application/json")
|
||||||
//req.Header.Add("Authorization", "bearer "+userToken.Data.Token.AccessToken)
|
//req.Header.Add("Authorization", "bearer "+userToken.Data.Token.AccessToken)
|
||||||
|
|
@ -251,7 +261,15 @@ func GetLibrary(userToken LoginResponse, initialToken string, endpoint string) L
|
||||||
|
|
||||||
_ = json.Unmarshal(data, &responseType)
|
_ = json.Unmarshal(data, &responseType)
|
||||||
|
|
||||||
return responseType
|
if len(responseType.Data) > 0 {
|
||||||
|
itemsToReturn = append(itemsToReturn, responseType)
|
||||||
|
pageToFetch++
|
||||||
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return itemsToReturn
|
||||||
}
|
}
|
||||||
|
|
||||||
func fileExists(filename string) bool {
|
func fileExists(filename string) bool {
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue