From 7335bae9cfb3821609b29b6093addb94a71b5335 Mon Sep 17 00:00:00 2001 From: Leon Date: Thu, 2 Nov 2023 15:12:34 +0100 Subject: [PATCH] Filter shows and movies in IMDB suggestions --- apps/api/src/handlers/suggest.ts | 4 +++- apps/client/src/main.go | 9 +++------ apps/navigator/src/pages/Home/index.tsx | 2 +- apps/navigator/src/style.css | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/apps/api/src/handlers/suggest.ts b/apps/api/src/handlers/suggest.ts index ed6d163..b9c2d56 100644 --- a/apps/api/src/handlers/suggest.ts +++ b/apps/api/src/handlers/suggest.ts @@ -4,7 +4,9 @@ export const suggest = async (ctx) => { const query = ctx.req.query("query"); try { - const results = await imdb.suggest({ query }); + const results = (await imdb.suggest({ query })).filter((r) => + ["movie", "tvSeries", "tvMiniSeries", "short"].includes(r.type) + ); return ctx.json(results); } catch (e) { return ctx.json({ error: e.message }, 500); diff --git a/apps/client/src/main.go b/apps/client/src/main.go index 2815d8e..713ac9a 100644 --- a/apps/client/src/main.go +++ b/apps/client/src/main.go @@ -11,7 +11,9 @@ var config *Config var scrapeClient *scraper.Scraper var db *bolt.DB -func setupDatabase() { +func main() { + scrapeClient = scraper.MakeScraper() + config = MakeConfig() var err error db, err = bolt.Open(config.OutputPath+"/.clientdb", 0600, nil) FatalError(err) @@ -21,12 +23,7 @@ func setupDatabase() { FatalError(err) return nil }) -} -func main() { - scrapeClient = scraper.MakeScraper() - config = MakeConfig() - setupDatabase() defer db.Close() go cleanup() gin.SetMode(gin.ReleaseMode) diff --git a/apps/navigator/src/pages/Home/index.tsx b/apps/navigator/src/pages/Home/index.tsx index ccd077a..d5ab676 100644 --- a/apps/navigator/src/pages/Home/index.tsx +++ b/apps/navigator/src/pages/Home/index.tsx @@ -47,7 +47,7 @@ const SearchInput = ({ value }) => { - input && input.focus()} autoFocus value={search.query} onInput={onInput} id="default-search" class="block w-full p-4 pl-10 text-sm text-gray-900 border border-gray-300 rounded-lg bg-gray-50 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white border-transparent focus:border-transparent focus:outline-none" placeholder="Search tv/film e.g. The bear s01e02" required /> + input && input.focus()} autoFocus value={search.query} onInput={onInput} id="default-search" class="block w-full p-4 pl-10 text-sm text-gray-900 border border-gray-300 rounded-lg bg-gray-50 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white border-transparent focus:border-transparent focus:outline-none" placeholder="Search e.g. Alone s01e01" required /> Search
diff --git a/apps/navigator/src/style.css b/apps/navigator/src/style.css index 97ba5db..63d4c54 100644 --- a/apps/navigator/src/style.css +++ b/apps/navigator/src/style.css @@ -60,7 +60,7 @@ main { @media (max-width: 639px) { main { - margin: 2rem; + padding: 2rem; } }