Skip to content

Instantly share code, notes, and snippets.

@rblack
Created October 11, 2014 13:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rblack/80a0931cfc4aa8343123 to your computer and use it in GitHub Desktop.
Save rblack/80a0931cfc4aa8343123 to your computer and use it in GitHub Desktop.
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