Skip to content

Commit

Permalink
Fix group download, now limited to first 100 videos
Browse files Browse the repository at this point in the history
  • Loading branch information
snobu committed Nov 14, 2020
1 parent ac0fdf5 commit ad483f3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/ApiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ export class ApiClient {
return true;
}
logger.warn(`Got HTTP code ${err?.response?.status ?? undefined}. Retrying request...`);
logger.verbose(`Here is the error message: \n '${err.response?.data}`);
logger.verbose('Here is the error message: ');
console.dir(err.response?.data);
logger.verbose('We called this URL: ' + err.response?.config.baseURL + err.response?.config.url);

const shouldRetry: boolean = retryCodes.includes(err?.response?.status ?? 0);

Expand Down
3 changes: 2 additions & 1 deletion src/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ async function extractGuids(url: string, client: ApiClient): Promise<Array<strin
const videoNumber: number = await client.callApi(`groups/${groupMatch[1]}`, 'get')
.then((response: AxiosResponse<any> | undefined) => response?.data.metrics.videos);

let result: Array<string> = await client.callApi(`groups/${groupMatch[1]}/videos?$top=${videoNumber}&$orderby=publishedDate asc`, 'get')
// Anything over $top=100 will return a 400 Bad Request
let result: Array<string> = await client.callApi(`groups/${groupMatch[1]}/videos?$top=100&$orderby=publishedDate asc`, 'get')
.then((response: AxiosResponse<any> | undefined) => response?.data.value.map((item: any) => item.id));

return result;
Expand Down

0 comments on commit ad483f3

Please sign in to comment.