mirror of
https://codeberg.org/video-prize-ranch/rimgo.git
synced 2025-12-13 19:55:21 +00:00
Remove unneeded sections
This commit is contained in:
18
api/f.ts
18
api/f.ts
@@ -24,20 +24,4 @@ export const fetchTagPosts = async (tagID: string, sort: Sorting = 'viral'): Pro
|
||||
);
|
||||
return JSON.parse(response.body).data;
|
||||
/* eslint-enable max-len */
|
||||
}
|
||||
|
||||
export const fetchGallery = async (galleryID: string): Promise<Gallery> => {
|
||||
// https://imgur.com/gallery/g1bk7CB
|
||||
const response = await get(`https://imgur.com/gallery/${galleryID}`);
|
||||
const $ = cheerio.load(response.body);
|
||||
const postDataScript = $('head script:first-of-type').html();
|
||||
if (!postDataScript) {
|
||||
throw new Error('Could not find gallery data');
|
||||
}
|
||||
const postDataMatches = postDataScript.match(GALLERY_JSON_REGEX);
|
||||
if (!postDataMatches || postDataMatches.length < 2) {
|
||||
throw new Error('Could not parse gallery data');
|
||||
}
|
||||
const body = postDataMatches[1].replace(/\\'/g, "'");
|
||||
return JSON.parse(JSON.parse(body));
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user