Separated and improved request throttling.
This commit is contained in:
@@ -17,9 +17,15 @@ function normalizeType(type) {
|
||||
}
|
||||
|
||||
async function redditAlbum(host, post, { reddit }) {
|
||||
// fetched through the authenticated/throttled client, not a raw fetch()/bhttp request -
|
||||
// reddit's anonymous-traffic bot challenge blocks plain unauthenticated .json requests
|
||||
const data = await reddit.getSubmission(post.id);
|
||||
// reddit's submission listing already embeds media_metadata/gallery_data for gallery posts,
|
||||
// and curate/posts.js carries them through as post.mediaMetadata/post.galleryData - reuse
|
||||
// those instead of re-fetching the same post individually through reddit's own client
|
||||
// (reservoir: 6/min, maxConcurrent: 1 - see src/reddit/client.js), which would otherwise cost
|
||||
// one full throttled round trip per gallery post. Only fall back to a fresh fetch if the
|
||||
// listing didn't have it for some reason (e.g. gallery_data null on the listing too).
|
||||
const data = post.mediaMetadata
|
||||
? { media_metadata: post.mediaMetadata, gallery_data: post.galleryData }
|
||||
: await reddit.getSubmission(post.id);
|
||||
const mediaMetadata = data.media_metadata || {};
|
||||
|
||||
// gallery_data (the ordered {media_id, is_deleted, ...} list for this gallery) has been
|
||||
|
||||
Reference in New Issue
Block a user