diff options
author | Gonzalo Odiard <godiard@gmail.com> | 2011-08-09 19:50:52 (GMT) |
---|---|---|
committer | Gonzalo Odiard <godiard@gmail.com> | 2011-08-09 19:50:52 (GMT) |
commit | 38f10a30c2531606aa6375812cd835182b155b29 (patch) | |
tree | 233781ae046378f99f516cb169726a03050a54a9 | |
parent | 57597a8fb570499bc11710f24aca24c3cc4f7bfc (diff) |
Implement support to blacklist OPDS Catalogs
The configuration add a 'blacklist' field where we can put a comma separated
list of catalogs names we don't want display. In FeedBooks there are
OPDS Catalogs for example for erotic books.
I have changed the default configuration of FeedBooks to show only
public domian books.
-rw-r--r-- | GetIABooksActivity.py | 21 | ||||
-rw-r--r-- | get-books.cfg | 4 |
2 files changed, 20 insertions, 5 deletions
diff --git a/GetIABooksActivity.py b/GetIABooksActivity.py index 0411def..8aac5b4 100644 --- a/GetIABooksActivity.py +++ b/GetIABooksActivity.py @@ -199,10 +199,17 @@ class GetIABooksActivity(activity.Activity): repo_config['query_uri'] = config.get(section, 'query_uri') repo_config['opds_cover'] = config.get(section, 'opds_cover') if config.has_option(section, 'summary_field'): - repo_config['summary_field'] = \ - config.get(section, 'summary_field') + repo_config['summary_field'] = \ + config.get(section, 'summary_field') else: - repo_config['summary_field'] = None + repo_config['summary_field'] = None + if config.has_option(section, 'blacklist'): + blacklist = config.get(section, 'blacklist') + repo_config['blacklist'] = blacklist.split(',') + # TODO strip? + else: + repo_config['blacklist'] = [] + _SOURCES_CONFIG[section] = repo_config logging.error('_SOURCES %s', _SOURCES) @@ -804,6 +811,7 @@ class GetIABooksActivity(activity.Activity): def catalogs_updated(self, query, midway): self.catalogs = {} for catalog_item in self.queryresults.get_catalog_list(): + logging.debug('Add catalog %s', catalog_item.get_title()) catalog_config = {} download_link = '' download_links = catalog_item.get_download_links() @@ -814,10 +822,15 @@ class GetIABooksActivity(activity.Activity): catalog_config['opds_cover'] = \ catalog_item._configuration['opds_cover'] catalog_config['source'] = catalog_item._configuration['source'] + source_config = _SOURCES_CONFIG[catalog_config['source']] catalog_config['name'] = catalog_item.get_title() catalog_config['summary_field'] = \ catalog_item._configuration['summary_field'] - self.catalogs[catalog_item.get_title().strip()] = catalog_config + if catalog_item.get_title() in source_config['blacklist']: + logging.debug('Catalog "%s" is in blacklist', + catalog_item.get_title()) + else: + self.catalogs[catalog_item.get_title().strip()] = catalog_config if len(self.catalogs) > 0: len_cat = len(self.catalog_history) diff --git a/get-books.cfg b/get-books.cfg index f1c642b..dd07716 100644 --- a/get-books.cfg +++ b/get-books.cfg @@ -7,6 +7,7 @@ name = Feedbooks query_uri = http://www.feedbooks.com/books/search.atom?query= opds_cover = http://opds-spec.org/image summary_field = summary +blacklist = Erotica,Romance [Catalogs_Feedbooks] Science Fiction = http://www.feedbooks.com/books/top.atom?category=FBFIC028000&range=week @@ -14,7 +15,8 @@ Short stories = http://www.feedbooks.com/books/top?category=FBFIC029000&range=we Fairy Tales, Folk Tales & Mythology = http://www.feedbooks.com/books/top?category=FBFIC010000&range=week Juvenile = http://www.feedbooks.com/books/top?category=FBJUV000000&range=week Action & Adventure = http://www.feedbooks.com/books/top?category=FBFIC002000&range=week -Feed Books Catalog Index = http://www.feedbooks.com/catalog +Public Domain Books = http://www.feedbooks.com/publicdomain/catalog.atom +#Feed Books Catalog Index = http://www.feedbooks.com/catalog [Internet Archive] name = Internet Archive |