From c42570c1ff3ba684155beb85ba48529330f2d0b0 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 12 Dec 2021 07:34:29 -0500 Subject: [PATCH] fix edge cases --- common/scrapers/douban.py | 2 ++ common/searcher.py | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/common/scrapers/douban.py b/common/scrapers/douban.py index c4961293..f107dec4 100644 --- a/common/scrapers/douban.py +++ b/common/scrapers/douban.py @@ -407,6 +407,8 @@ class DoubanMovieScraper(DoubanScrapperMixin, AbstractScraper): if genre_elem: genre = [] for g in genre_elem: + if g == '紀錄片 Documentary': # likely some original data on douban was corrupted + g = '纪录片' genre.append(genre_translator[g]) else: genre = None diff --git a/common/searcher.py b/common/searcher.py index c78aeca2..839c44b4 100644 --- a/common/searcher.py +++ b/common/searcher.py @@ -128,14 +128,14 @@ class TheMovieDatabase: if m['media_type'] == 'tv': cat = Category.TV title = m['name'] - subtitle = f"{m['first_air_date']} {m['original_name']}" + subtitle = f"{m.get('first_air_date')} {m.get('original_name')}" else: cat = Category.Movie title = m['title'] - subtitle = f"{m['release_date']} {m['original_title']}" - cover = f"https://image.tmdb.org/t/p/w500/{m['poster_path']}" + subtitle = f"{m.get('release_date')} {m.get('original_name')}" + cover = f"https://image.tmdb.org/t/p/w500/{m.get('poster_path')}" results.append(SearchResultItem( - cat, SourceSiteEnum.TMDB, url, title, subtitle, m['overview'], cover)) + cat, SourceSiteEnum.TMDB, url, title, subtitle, m.get('overview'), cover)) except Exception as e: logger.error(f"TMDb search '{q}' error: {e}") return results @@ -191,6 +191,8 @@ class Bandcamp: class ExternalSources: @classmethod def search(self, c, q, page=1): + if not q: + return [] results = [] if c == '' or c is None: c = 'all'