Created
October 11, 2014 13:24
-
-
Save rblack/80a0931cfc4aa8343123 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var max_count = 200; | |
var start_offset = 0; | |
var my_params = {"owner_id": "-78352393"}; | |
var key = "items"; | |
var params = {"count": max_count} + my_params; | |
var res = API.video.get(params); | |
if (res["count"]){ | |
var count = res["count"]; | |
var items = res[key]; | |
var offset = 0; | |
var i = 1; | |
while(i < 25 && offset < count) { | |
offset = i * max_count + start_offset; | |
params = {"count": max_count, "offset": offset}; | |
params = params + my_params; | |
res = API.video.get(params); | |
items = items + res[key]; | |
i = i + 1; | |
} | |
return {"count": count, "items": items, "offset": offset, "end": offset >= count}; | |
} else { | |
return {"count": 0, "items": 0, "offset": 0, "end": true}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment