From 580960c712a9f97bb6a634e952ef2a163041b78f Mon Sep 17 00:00:00 2001 From: PrgmrBill Date: Sun, 7 Jun 2015 09:40:24 -0400 Subject: [PATCH] Documents coub.com feature for SpiffyTitles and adds coubHandlerEnabled option to be consistent with the other handlers. --- README.md | 10 ++++++++++ config.py | 3 +++ plugin.py | 7 +++++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c21b2b7..ce9f856 100644 --- a/README.md +++ b/README.md @@ -123,6 +123,16 @@ Example output: - If you see something from [the imgur api](https://api.imgur.com/models/image) that you want and is not available in the above example, [please open an issue!](https://github.com/prgmrbill/limnoria-plugins/issues/new) +### coub handler + +`coubTemplate` - Template for [coub](http://coub.com) links. + +Default value: `^ {%if not_safe_for_work %}NSFW{% endif %} [{{channel.title}}] {{title}} :: {{views_count}} views :: {{likes_count}} likes :: {{recoubs_count}} recoubs` + +`coubHandlerEnabled` - Whether to enable additional information about coub videos. + +## Other options + `useBold` - Whether to bold the title. Default value: `False` `linkCacheLifetimeInSeconds` - Caches the title of links. This is useful for reducing API usage and diff --git a/config.py b/config.py index 7109993..8e6305d 100644 --- a/config.py +++ b/config.py @@ -45,6 +45,9 @@ conf.registerGlobalValue(SpiffyTitles, 'coubTemplate', registry.String("^ {%if not_safe_for_work %}NSFW{% endif %} [{{channel.title}}] {{title}} :: {{views_count}} views :: {{likes_count}} likes :: {{recoubs_count}} recoubs", _("""Uses Coub API to get additional information about coub.com links"""))) # enable/disable toggles +conf.registerGlobalValue(SpiffyTitles, 'coubHandlerEnabled', + registry.Boolean(True, _("""Whether to add additional information about coub links"""))) + conf.registerGlobalValue(SpiffyTitles, 'defaultHandlerEnabled', registry.Boolean(True, _("""Whether to add additional information about regular links"""))) diff --git a/plugin.py b/plugin.py index 92ea268..e02c257 100644 --- a/plugin.py +++ b/plugin.py @@ -71,11 +71,12 @@ class SpiffyTitles(callbacks.Plugin): """ Handles coub.com links """ + coub_handler_enabled = self.registryValue("coubHandlerEnabled") self.log.info("SpiffyTitles: calling coub handler for %s" % url) title = None """ Get video ID """ - if "/view/" in url: + if coub_handler_enabled and "/view/" in url: video_id = url.split("/view/")[1] """ Remove any query strings """ @@ -108,7 +109,9 @@ class SpiffyTitles(callbacks.Plugin): self.log.error("SpiffyTitles: coub handler returned %s: %s" % (request.status_code, request.text[:200])) if title is None: - self.log.info("SpiffyTitles: %s does not appear to be a video link!" % url) + if coub_handler_enabled: + self.log.info("SpiffyTitles: %s does not appear to be a video link!" % url) + return self.handler_default(url) else: return title