From ee689be3a918c867445b4c8e66febab70fb0fa6d Mon Sep 17 00:00:00 2001 From: video-prize-ranch Date: Tue, 18 Jan 2022 18:31:26 -0500 Subject: [PATCH] Remove unneeded sections --- api/f.ts | 18 +----------------- pages/h.ts | 17 ----------------- 2 files changed, 1 insertion(+), 34 deletions(-) diff --git a/api/f.ts b/api/f.ts index 1034b7c..8022f63 100644 --- a/api/f.ts +++ b/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 => { - // 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)); -}; \ No newline at end of file +} \ No newline at end of file diff --git a/pages/h.ts b/pages/h.ts index 131146e..4734bcf 100644 --- a/pages/h.ts +++ b/pages/h.ts @@ -1,6 +1,3 @@ - - - export const handleUser = async (request: Hapi.Request, h: Hapi.ResponseToolkit) => { // https://imgur.com/user/MomBotNumber5 if (!CONFIG.use_api) { @@ -38,18 +35,4 @@ export const handleTag = async (request: Hapi.Request, h: Hapi.ResponseToolkit) tag: result, util, }); -}; - -export const handleGallery = async (request: Hapi.Request, h: Hapi.ResponseToolkit) => { - const galleryID = request.params.galleryID; - const gallery = await fetchGallery(galleryID); - const comments = CONFIG.use_api - ? await fetchComments(galleryID) - : null; - return h.view('gallery', { - ...gallery, - comments, - pageTitle: CONFIG.page_title, - util, - }); }; \ No newline at end of file