move configs to groups, imdb template improved

This commit is contained in:
oddluck 2019-12-23 21:18:25 +00:00
parent 0a3b84b6c4
commit ff173281c5
2 changed files with 256 additions and 176 deletions

View File

@ -37,25 +37,6 @@ conf.registerGlobalValue(SpiffyTitles, 'wallClockTimeoutInSeconds',
conf.registerGlobalValue(SpiffyTitles, 'language',
registry.String("en-US", _("""Language code""")))
# enable/disable toggles
conf.registerChannelValue(SpiffyTitles, 'coubHandlerEnabled',
registry.Boolean(True, _("""Whether to add additional information about coub links""")))
conf.registerChannelValue(SpiffyTitles, 'defaultHandlerEnabled',
registry.Boolean(True, _("""Whether to add additional information about regular links""")))
conf.registerChannelValue(SpiffyTitles, 'youtubeHandlerEnabled',
registry.Boolean(True, _("""Whether to add additional information about YouTube videos""")))
conf.registerChannelValue(SpiffyTitles, 'imgurHandlerEnabled',
registry.Boolean(True, _("""Whether to add additional information about imgur links""")))
conf.registerChannelValue(SpiffyTitles, 'imdbHandlerEnabled',
registry.Boolean(True, _("""Whether to add additional information about IMDB links""")))
conf.registerChannelValue(SpiffyTitles, 'twitchHandlerEnabled',
registry.Boolean(True, _("""Whether to add additional information about Twitch links""")))
# URL regex
conf.registerGlobalValue(SpiffyTitles, 'urlRegularExpression',
registry.String(r"(https?:\/\/(?:www\.|(?!www))[^\s\.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,})", _("""This regular expression will be used to match URLs""")))
@ -64,17 +45,185 @@ conf.registerGlobalValue(SpiffyTitles, 'urlRegularExpression',
conf.registerChannelValue(SpiffyTitles, 'useBold',
registry.Boolean(False, _("""Use bold in titles""")))
# Title template - show a warning if redirects to a different domain
conf.registerChannelValue(SpiffyTitles, 'defaultTitleTemplate',
# User agents
conf.registerGlobalValue(SpiffyTitles, 'userAgents',
registry.CommaSeparatedListOfStrings(["Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.60 Safari/537.36", "Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0", "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; AS; rv:11.0) like Gecko"], _("""Reported user agent when fetching links""")))
# Mime Types
conf.registerGlobalValue(SpiffyTitles, 'mimeTypes',
registry.CommaSeparatedListOfStrings(["text/html"], _("""Acceptable mime types for displaying titles""")))
# Ignored domain pattern
conf.registerChannelValue(SpiffyTitles, 'ignoredDomainPattern',
registry.Regexp("", _("""Domains matching this patterns will be ignored""")))
# Whitelist domain pattern
conf.registerChannelValue(SpiffyTitles, 'whitelistDomainPattern',
registry.Regexp("", _("""Domains not matching this patterns will be ignored""")))
# Channel whitelist
conf.registerGlobalValue(SpiffyTitles, 'channelWhitelist',
registry.CommaSeparatedListOfStrings([], _("""Only show titles on these channels, or all if empty""")))
# Channel blacklist
conf.registerGlobalValue(SpiffyTitles, 'channelBlacklist',
registry.CommaSeparatedListOfStrings([], _("""Never show titles on these channels""")))
# Link cache lifetime
conf.registerGlobalValue(SpiffyTitles, 'linkCacheLifetimeInSeconds',
registry.Integer(60, _("""Link cache lifetime in seconds""")))
conf.registerChannelValue(SpiffyTitles, 'onDemandTitleError',
registry.String("Error retrieving title.", _("""This error message is used when there is a problem getting an on-demand title""")))
conf.registerGlobalValue(SpiffyTitles, 'linkMessageIgnorePattern',
registry.Regexp("", _("""Messages matching this pattern will be ignored.""")))
conf.registerChannelValue(SpiffyTitles, 'ignoreActionLinks',
registry.Boolean(True, _("""Ignores URLs that appear in an action such as /me""")))
conf.registerChannelValue(SpiffyTitles, 'requireCapability',
registry.String("", _("""If defined, SpiffyTitles will only acknowledge links from users with this capability. Useful for hostile environments.""")))
conf.registerChannelValue(SpiffyTitles, 'ignoredTitlePattern',
registry.Regexp("", _("""Titles matching this pattern will be ignored.""")))
#default configs
conf.registerGroup(SpiffyTitles, 'default')
conf.registerChannelValue(SpiffyTitles.default, 'enabled',
registry.Boolean(True, _("""Whether to add additional information about regular links""")))
# default title template - show a warning if redirects to a different domain
conf.registerChannelValue(SpiffyTitles.default, 'template',
registry.String("{% if redirect %}(REDIRECT) {% endif %}^ {{title}}", _("""Template used for default title responses""")))
#Wikipedia configs
conf.registerGroup(SpiffyTitles, 'wikipedia')
#wikipedia enabler
conf.registerChannelValue(SpiffyTitles.wikipedia, 'enabled',
registry.Boolean(True, _("""Whether to fetch extracts for Wikipedia articles.""")))
conf.registerChannelValue(SpiffyTitles.wikipedia, 'apiParams',
registry.SpaceSeparatedListOfStrings([], _("""Add or override API query parameters with a space-separated list of key=value pairs.""")))
conf.registerChannelValue(SpiffyTitles.wikipedia, 'titleParam',
registry.String("titles", _("""The query parameter that will hold the page title from the URL.""")))
# Ideally, links to specific article sections would produce the relevant output for that section. This is not currently implemented.
conf.registerChannelValue(SpiffyTitles.wikipedia, 'ignoreSectionLinks',
registry.Boolean(True, _("""Ignore links to specific article sections.""")))
conf.registerChannelValue(SpiffyTitles.wikipedia, 'maxChars',
registry.Integer(240, _("""Extract will be cut to this length (including '...').""")))
# Remove parenthesized text from output.
conf.registerChannelValue(SpiffyTitles.wikipedia, 'removeParentheses',
registry.Boolean(True, _("""Remove parenthesized text from output.""")))
conf.registerChannelValue(SpiffyTitles.wikipedia, 'extractTemplate',
registry.String("^ {{extract}}", _("""Wikipedia template.""")))
#Reddit configs
conf.registerGroup(SpiffyTitles, 'reddit')
#Reddit enabler
conf.registerChannelValue(SpiffyTitles.reddit, 'enabled',
registry.Boolean(True, _("""Whether to add additional info about Reddit links.""")))
#Reddit templates
conf.registerChannelValue(SpiffyTitles.reddit, 'linkThreadTemplate',
registry.String(u"/r/{{subreddit}}{% if title %} :: {{title}}{% endif %} :: {{score}} points ({{percent}}) :: {{comments}} comments :: Posted {{age}} by {{author}}{% if url %} :: {{url}} ({{domain}}){% endif %}", _("""Template used for Reddit link thread title responses""")))
conf.registerChannelValue(SpiffyTitles.reddit, 'textThreadTemplate',
registry.String(u"/r/{{subreddit}}{% if title %} :: {{title}}{% endif %}{% if extract %} :: {{extract}}{% endif %} :: {{score}} points ({{percent}}) :: {{comments}} comments :: Posted {{age}} by {{author}}", _("""Template used for Reddit text thread title responses""")))
conf.registerChannelValue(SpiffyTitles.reddit, 'commentTemplate',
registry.String(u"/r/{{subreddit}}{% if extract %} :: {{extract}}{% endif %} :: {{score}} points :: Posted {{age}} by {{author}} on \"{{title}}\"", _("""Template used for Reddit comment title responses""")))
conf.registerChannelValue(SpiffyTitles.reddit, 'userTemplate',
registry.String(u"/u/{{user}}{% if gold %} :: (GOLD{% if mod %}, MOD{% endif %}){% endif %} :: Joined: {{created}} :: Link karma: {{link_karma}} :: Comment karma: {{comment_karma}}", _("""Template used for Reddit user page title responses""")))
#Reddit max characters
conf.registerChannelValue(SpiffyTitles.reddit, 'maxChars',
registry.Integer(400, _("""Length of response (title/extract will be cut to fit).""")))
#YouTube configs
conf.registerGroup(SpiffyTitles, 'youtube')
#youtube enabler
conf.registerChannelValue(SpiffyTitles.youtube, 'enabled',
registry.Boolean(True, _("""Whether to add additional information about YouTube videos""")))
# Youtube API
conf.registerGlobalValue(SpiffyTitles.youtube, 'developerKey',
registry.String("", _("""Youtube developer key - required for Youtube handler."""), private=True))
# YouTube Logo
conf.registerChannelValue(SpiffyTitles.youtube, 'logo',
registry.String("\x030,4 ► \x031,0YouTube", _("""Logo used with {{yt_logo}} in template""")))
# YouTube template
conf.registerChannelValue(SpiffyTitles.youtube, 'template',
registry.String("^ {{yt_logo}} :: {{title}} {%if timestamp%} @ {{timestamp}}{% endif %} :: Duration: {{duration}} :: Views: {{view_count}} uploaded by {{channel_title}} :: {{like_count}} likes :: {{dislike_count}} dislikes :: {{favorite_count}} favorites", _("""Template used for YouTube title responses""")))
#imgur configs
conf.registerGroup(SpiffyTitles, 'imgur')
#imgur enabler
conf.registerChannelValue(SpiffyTitles.imgur, 'enabled',
registry.Boolean(True, _("""Whether to add additional information about imgur links""")))
# imgur API
conf.registerGlobalValue(SpiffyTitles.imgur, 'clientID',
registry.String("", _("""imgur client ID"""), private=True))
conf.registerGlobalValue(SpiffyTitles.imgur, 'clientSecret',
registry.String("", _("""imgur client secret"""), private=True))
conf.registerChannelValue(SpiffyTitles.imgur, 'template',
registry.String("^{%if section %} [{{section}}] {% endif -%}{%- if title -%} {{title}} :: {% endif %}{{type}} {{width}}x{{height}} {{file_size}} :: {{view_count}} views :: {%if nsfw == None %}not sure if safe for work{% elif nsfw == True %}not safe for work!{% else %}safe for work{% endif %}", _("""imgur template""")))
conf.registerChannelValue(SpiffyTitles.imgur, 'albumTemplate',
registry.String("^{%if section %} [{{section}}] {% endif -%}{%- if title -%} {{title}} :: {% endif %}{{image_count}} images :: {{view_count}} views :: {%if nsfw == None %}not sure if safe for work{% elif nsfw == True %}not safe for work!{% else %}safe for work{% endif %}", _("""imgur template""")))
#dailymotion configs
conf.registerGroup(SpiffyTitles, 'dailymotion')
#dailymotion enabler
conf.registerChannelValue(SpiffyTitles.dailymotion, 'enabled',
registry.Boolean(True, _("""Enable additional information about dailymotion videos""")))
# dailymotion template
conf.registerChannelValue(SpiffyTitles.dailymotion, 'template',
registry.String("^ [{{ownerscreenname}}] {{title}} :: Duration: {{duration}} :: {{views_total}} views", _("""Template used for Vimeo title responses""")))
#Twitch configs
conf.registerGroup(SpiffyTitles, 'twitch')
#twitch enabler
conf.registerChannelValue(SpiffyTitles.twitch, 'enabled',
registry.Boolean(True, _("""Whether to add additional information about Twitch links""")))
#Twitch API Key
conf.registerGlobalValue(SpiffyTitles.twitch, 'clientID',
registry.String('', _("""Twitch API Client_ID""")))
# Twitch Logo
conf.registerChannelValue(SpiffyTitles.twitch, 'twitchLogo',
conf.registerChannelValue(SpiffyTitles.twitch, 'logo',
registry.String("\x030,6💬twitch", _("""Logo used with {{twitch_logo}} in template""")))
conf.registerChannelValue(SpiffyTitles.twitch, 'channelTemplate',
@ -89,147 +238,49 @@ conf.registerChannelValue(SpiffyTitles.twitch, 'videoTemplate',
conf.registerChannelValue(SpiffyTitles.twitch, 'clipTemplate',
registry.String("^ {{twitch_logo}} :: {{display_name}} {%if game_name%}:: [{{game_name}}] {%endif%}{%if title%}:: {{title}} {%endif%}:: Created: {{created_at}} :: Viewers: {{view_count}} {%if description%}:: {{description}}{%endif%}", _("""twitch.tv clip template""")))
#OMDB API Key
conf.registerGlobalValue(SpiffyTitles, 'omdbAPI',
registry.String('', _("""OMDB API Key""")))
# imdb template
conf.registerChannelValue(SpiffyTitles, 'imdbTemplate',
registry.String("^ {{Title}} ({{Year}}, {{Country}}) - Rating: {{imdbRating}} :: {{Plot}}", _("""IMDB title template""")))
# alternative imdb template:
# ^ {{Title}} ({{Year}} - {{Director}}) :: [i:{{imdbRating}} r:{{tomatoMeter}} m:{{Metascore}}] {{Plot}}
#vimeo configs
conf.registerGroup(SpiffyTitles, 'vimeo')
# coub template
conf.registerChannelValue(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""")))
# YouTube Logo
conf.registerChannelValue(SpiffyTitles, 'youtubeLogo',
registry.String("\x030,4 ► \x031,0YouTube", _("""Logo used with {{yt_logo}} in template""")))
# YouTube template
conf.registerChannelValue(SpiffyTitles, 'youtubeTitleTemplate',
registry.String("^ {{yt_logo}} :: {{title}} {%if timestamp%} @ {{timestamp}}{% endif %} :: Duration: {{duration}} :: Views: {{view_count}} uploaded by {{channel_title}} :: {{like_count}} likes :: {{dislike_count}} dislikes :: {{favorite_count}} favorites", _("""Template used for YouTube title responses""")))
# Vimeo template
conf.registerChannelValue(SpiffyTitles, 'vimeoTitleTemplate',
registry.String("^ {{title}} :: Duration: {{duration}} :: {{stats_number_of_plays}} plays :: {{stats_number_of_comments}} comments", _("""Template used for Vimeo title responses""")))
conf.registerChannelValue(SpiffyTitles, 'vimeoHandlerEnabled',
#vimeo enabler
conf.registerChannelValue(SpiffyTitles.vimeo, 'enabled',
registry.Boolean(True, _("""Enable additional information about Vimeo videos""")))
# dailymotion template
conf.registerChannelValue(SpiffyTitles, 'dailymotionVideoTitleTemplate',
registry.String("^ [{{ownerscreenname}}] {{title}} :: Duration: {{duration}} :: {{views_total}} views", _("""Template used for Vimeo title responses""")))
conf.registerChannelValue(SpiffyTitles, 'dailymotionHandlerEnabled',
registry.Boolean(True, _("""Enable additional information about dailymotion videos""")))
# User agents
conf.registerGlobalValue(SpiffyTitles, 'userAgents',
registry.CommaSeparatedListOfStrings(["Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.60 Safari/537.36", "Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0", "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; AS; rv:11.0) like Gecko"], _("""Reported user agent when fetching links""")))
# Mime Types
conf.registerGlobalValue(SpiffyTitles, 'mimeTypes',
registry.CommaSeparatedListOfStrings(["text/html"], _("""Acceptable mime types for displaying titles""")))
# Ignored domain pattern
conf.registerChannelValue(SpiffyTitles, 'ignoredDomainPattern',
registry.Regexp("", _("""Domains matching this patterns will be ignored""")))
# Whitelist domain pattern
conf.registerChannelValue(SpiffyTitles, 'whitelistDomainPattern',
registry.Regexp("", _("""Domains not matching this patterns will be ignored""")))
# Channel whitelist
conf.registerGlobalValue(SpiffyTitles, 'channelWhitelist',
registry.CommaSeparatedListOfStrings([], _("""Only show titles on these channels, or all if empty""")))
# Channel blacklist
conf.registerGlobalValue(SpiffyTitles, 'channelBlacklist',
registry.CommaSeparatedListOfStrings([], _("""Never show titles on these channels""")))
# imgur API
conf.registerGlobalValue(SpiffyTitles, 'imgurClientID',
registry.String("", _("""imgur client ID"""), private=True))
conf.registerGlobalValue(SpiffyTitles, 'imgurClientSecret',
registry.String("", _("""imgur client secret"""), private=True))
conf.registerChannelValue(SpiffyTitles, 'imgurTemplate',
registry.String("^{%if section %} [{{section}}] {% endif -%}{%- if title -%} {{title}} :: {% endif %}{{type}} {{width}}x{{height}} {{file_size}} :: {{view_count}} views :: {%if nsfw == None %}not sure if safe for work{% elif nsfw == True %}not safe for work!{% else %}safe for work{% endif %}", _("""imgur template""")))
conf.registerChannelValue(SpiffyTitles, 'imgurAlbumTemplate',
registry.String("^{%if section %} [{{section}}] {% endif -%}{%- if title -%} {{title}} :: {% endif %}{{image_count}} images :: {{view_count}} views :: {%if nsfw == None %}not sure if safe for work{% elif nsfw == True %}not safe for work!{% else %}safe for work{% endif %}", _("""imgur template""")))
# Youtube API
conf.registerGlobalValue(SpiffyTitles, 'youtubeDeveloperKey',
registry.String("", _("""Youtube developer key - required for Youtube handler."""), private=True))
# Link cache lifetime
conf.registerGlobalValue(SpiffyTitles, 'linkCacheLifetimeInSeconds',
registry.Integer(60, _("""Link cache lifetime in seconds""")))
conf.registerChannelValue(SpiffyTitles, 'onDemandTitleError',
registry.String("Error retrieving title.", _("""This error message is used when there is a problem getting an on-demand title""")))
conf.registerGlobalValue(SpiffyTitles, 'linkMessageIgnorePattern',
registry.Regexp("", _("""Messages matching this pattern will be ignored.""")))
conf.registerChannelValue(SpiffyTitles, 'ignoreActionLinks',
registry.Boolean(True, _("""Ignores URLs that appear in an action such as /me""")))
conf.registerChannelValue(SpiffyTitles, 'requireCapability',
registry.String("", _("""If defined, SpiffyTitles will only acknowledge links from users with this capability. Useful for hostile environments.""")))
conf.registerChannelValue(SpiffyTitles, 'ignoredTitlePattern',
registry.Regexp("", _("""Titles matching this pattern will be ignored.""")))
# Vimeo template
conf.registerChannelValue(SpiffyTitles.vimeo, 'template',
registry.String("^ {{title}} :: Duration: {{duration}} :: {{stats_number_of_plays}} plays :: {{stats_number_of_comments}} comments", _("""Template used for Vimeo title responses""")))
conf.registerGroup(SpiffyTitles, 'wikipedia')
conf.registerChannelValue(SpiffyTitles.wikipedia, 'enabled',
registry.Boolean(True, _("""Whether to fetch extracts for Wikipedia articles.""")))
#IMDB configs
conf.registerGroup(SpiffyTitles, 'imdb')
conf.registerChannelValue(SpiffyTitles.wikipedia, 'apiParams',
registry.SpaceSeparatedListOfStrings([], _("""Add or override API query parameters with a space-separated list of key=value pairs.""")))
#imdb enabler
conf.registerChannelValue(SpiffyTitles.imdb, 'enabled',
registry.Boolean(True, _("""Whether to add additional information about IMDB links""")))
conf.registerChannelValue(SpiffyTitles.wikipedia, 'titleParam',
registry.String("titles", _("""The query parameter that will hold the page title from the URL.""")))
#OMDB API Key
conf.registerGlobalValue(SpiffyTitles.imdb, 'omdbAPI',
registry.String('', _("""OMDB API Key""")))
# Ideally, links to specific article sections would produce the relevant output for that section. This is not currently implemented.
conf.registerChannelValue(SpiffyTitles.wikipedia, 'ignoreSectionLinks',
registry.Boolean(True, _("""Ignore links to specific article sections.""")))
# IMDB Logo
conf.registerChannelValue(SpiffyTitles.imdb, 'logo',
registry.String("\x02\x031,8IMDB", _("""Logo used with {{imdb_logo}} in template""")))
conf.registerChannelValue(SpiffyTitles.wikipedia, 'maxChars',
registry.Integer(240, _("""Extract will be cut to this length (including '...').""")))
# Remove parenthesized text from output.
conf.registerChannelValue(SpiffyTitles.wikipedia, 'removeParentheses',
registry.Boolean(True, _("""Remove parenthesized text from output.""")))
conf.registerChannelValue(SpiffyTitles.wikipedia, 'extractTemplate',
registry.String("^ {{extract}}", _("""Wikipedia template.""")))
# IMDB template
conf.registerChannelValue(SpiffyTitles.imdb, 'template',
registry.String("^ {{imdb_logo}} :: {{title}} ({{year}}, {{country}} [{{rated}}], {{genre}}, {{runtime}}) :: IMDB: {{imdb_rating}} MC: {{metascore}} :: {{plot}}", _("""IMDB title template""")))
conf.registerGroup(SpiffyTitles, 'reddit')
conf.registerChannelValue(SpiffyTitles.reddit, 'enabled',
registry.Boolean(True, _("""Whether to add additional info about Reddit links.""")))
#coub configs
conf.registerGroup(SpiffyTitles, 'coub')
conf.registerChannelValue(SpiffyTitles.reddit, 'linkThreadTemplate',
registry.String(u"/r/{{subreddit}}{% if title %} :: {{title}}{% endif %} :: {{score}} points ({{percent}}) :: {{comments}} comments :: Posted {{age}} by {{author}}{% if url %} :: {{url}} ({{domain}}){% endif %}", _("""Template used for Reddit link thread title responses""")))
conf.registerChannelValue(SpiffyTitles.reddit, 'textThreadTemplate',
registry.String(u"/r/{{subreddit}}{% if title %} :: {{title}}{% endif %}{% if extract %} :: {{extract}}{% endif %} :: {{score}} points ({{percent}}) :: {{comments}} comments :: Posted {{age}} by {{author}}", _("""Template used for Reddit text thread title responses""")))
conf.registerChannelValue(SpiffyTitles.reddit, 'commentTemplate',
registry.String(u"/r/{{subreddit}}{% if extract %} :: {{extract}}{% endif %} :: {{score}} points :: Posted {{age}} by {{author}} on \"{{title}}\"", _("""Template used for Reddit comment title responses""")))
conf.registerChannelValue(SpiffyTitles.reddit, 'userTemplate',
registry.String(u"/u/{{user}}{% if gold %} :: (GOLD{% if mod %}, MOD{% endif %}){% endif %} :: Joined: {{created}} :: Link karma: {{link_karma}} :: Comment karma: {{comment_karma}}", _("""Template used for Reddit user page title responses""")))
conf.registerChannelValue(SpiffyTitles.reddit, 'maxChars',
registry.Integer(400, _("""Length of response (title/extract will be cut to fit).""")))
#coub enabler
conf.registerChannelValue(SpiffyTitles.coub, 'enabled',
registry.Boolean(True, _("""Whether to add additional information about coub links""")))
# coub template
conf.registerChannelValue(SpiffyTitles.coub, 'template',
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""")))

View File

@ -58,7 +58,7 @@ class SpiffyTitles(callbacks.Plugin):
self.__parent.__init__(irc)
self.wall_clock_timeout = self.registryValue("wallClockTimeoutInSeconds")
self.default_handler_enabled = self.registryValue("defaultHandlerEnabled")
self.default_handler_enabled = self.registryValue("default.enabled")
self.add_handlers()
@ -94,7 +94,7 @@ class SpiffyTitles(callbacks.Plugin):
def add_twitch_handlers(self):
"""
Enables meta info about IMDB links through the OMDB API
Enables meta info about Twitch links through the Twitch API
"""
self.handlers["twitch.tv"] = self.handler_twitch
self.handlers["www.twitch.tv"] = self.handler_twitch
@ -125,7 +125,7 @@ class SpiffyTitles(callbacks.Plugin):
"""
Handles dailymotion links
"""
dailymotion_handler_enabled = self.registryValue("dailymotionHandlerEnabled",
dailymotion_handler_enabled = self.registryValue("dailymotion.enabled",
channel=channel)
log.debug("SpiffyTitles: calling dailymotion handler for %s" % url)
title = None
@ -154,7 +154,7 @@ class SpiffyTitles(callbacks.Plugin):
if response is not None and "title" in response:
video = response
dailymotion_template = \
Template(self.registryValue("dailymotionVideoTitleTemplate",
Template(self.registryValue("dailymotion.template",
channel=channel))
video["views_total"] = "{:,}".format(int(video["views_total"]))
video["duration"] = self.get_duration_from_seconds(video["duration"])
@ -179,7 +179,7 @@ class SpiffyTitles(callbacks.Plugin):
"""
Handles Vimeo links
"""
vimeo_handler_enabled = self.registryValue("vimeoHandlerEnabled", channel=channel)
vimeo_handler_enabled = self.registryValue("vimeo.enabled", channel=channel)
log.debug("SpiffyTitles: calling vimeo handler for %s" % url)
title = None
video_id = None
@ -208,7 +208,7 @@ class SpiffyTitles(callbacks.Plugin):
if response is not None and "title" in response[0]:
video = response[0]
vimeo_template = Template(self.registryValue("vimeoTitleTemplate",
vimeo_template = Template(self.registryValue("vimeo.template",
channel=channel))
"""
@ -247,7 +247,7 @@ class SpiffyTitles(callbacks.Plugin):
"""
Handles coub.com links
"""
coub_handler_enabled = self.registryValue("coubHandlerEnabled", channel=channel)
coub_handler_enabled = self.registryValue("coub.enabled", channel=channel)
log.debug("SpiffyTitles: calling coub handler for %s" % url)
title = None
@ -274,7 +274,7 @@ class SpiffyTitles(callbacks.Plugin):
if response:
video = response
coub_template = Template(self.registryValue("coubTemplate"))
coub_template = Template(self.registryValue("coub.template"))
video["likes_count"] = "{:,}".format(int(video["likes_count"]))
video["recoubs_count"] = "{:,}".format(int(video["recoubs_count"]))
@ -299,9 +299,9 @@ class SpiffyTitles(callbacks.Plugin):
imgur API client
"""
if self.imgur_client is None:
imgur_client_id = self.registryValue("imgurClientID")
imgur_client_secret = self.registryValue("imgurClientSecret")
imgur_handler_enabled = self.registryValue("imgurHandlerEnabled", channel=channel)
imgur_client_id = self.registryValue("imgur.clientID")
imgur_client_secret = self.registryValue("imgur.clientSecret")
imgur_handler_enabled = self.registryValue("imgur.enabled", channel=channel)
if imgur_handler_enabled and imgur_client_id and imgur_client_secret:
log.debug("SpiffyTitles: enabling imgur handler")
@ -618,8 +618,8 @@ class SpiffyTitles(callbacks.Plugin):
Uses the Youtube API to provide additional meta data about
Youtube Video links posted.
"""
youtube_handler_enabled = self.registryValue("youtubeHandlerEnabled", channel=channel)
developer_key = self.registryValue("youtubeDeveloperKey")
youtube_handler_enabled = self.registryValue("youtube.enabled", channel=channel)
developer_key = self.registryValue("youtube.developerKey")
if not youtube_handler_enabled:
return None
@ -631,7 +631,7 @@ class SpiffyTitles(callbacks.Plugin):
log.debug("SpiffyTitles: calling Youtube handler for %s" % (url))
video_id = self.get_video_id_from_url(url, domain)
yt_template = Template(self.registryValue("youtubeTitleTemplate", channel=channel))
yt_template = Template(self.registryValue("youtube.template", channel=channel))
title = ""
if video_id:
@ -749,20 +749,29 @@ class SpiffyTitles(callbacks.Plugin):
def get_youtube_logo(self):
use_bold = self.registryValue("useBold", dynamic.channel)
if use_bold:
yt_logo = "{0}\x0F\x02".format(self.registryValue("youtubeLogo", dynamic.channel))
yt_logo = "{0}\x0F\x02".format(self.registryValue("youtube.logo", dynamic.channel))
else:
yt_logo = "{0}\x0F".format(self.registryValue("youtubeLogo", dynamic.channel))
yt_logo = "{0}\x0F".format(self.registryValue("youtube.logo", dynamic.channel))
return yt_logo
def get_twitch_logo(self):
use_bold = self.registryValue("useBold", dynamic.channel)
if use_bold:
twitch_logo = "{0}\x0F\x02".format(self.registryValue("twitch.twitchLogo", dynamic.channel))
twitch_logo = "{0}\x0F\x02".format(self.registryValue("twitch.logo", dynamic.channel))
else:
twitch_logo = "{0}\x0F".format(self.registryValue("twitch.twitchLogo", dynamic.channel))
twitch_logo = "{0}\x0F".format(self.registryValue("twitch.logo", dynamic.channel))
return twitch_logo
def get_imdb_logo(self):
use_bold = self.registryValue("useBold", dynamic.channel)
if use_bold:
imdb_logo = "{0}\x0F\x02".format(self.registryValue("imdb.logo", dynamic.channel))
else:
imdb_logo = "{0}\x0F".format(self.registryValue("imdb.logo", dynamic.channel))
return imdb_logo
def get_total_seconds_from_duration(self, input):
"""
@ -812,10 +821,10 @@ class SpiffyTitles(callbacks.Plugin):
"""
Default handler for websites
"""
default_handler_enabled = self.registryValue("defaultHandlerEnabled", channel=channel)
default_handler_enabled = self.registryValue("default.enabled", channel=channel)
if default_handler_enabled:
log.debug("SpiffyTitles: calling default handler for %s" % (url))
default_template = Template(self.registryValue("defaultTitleTemplate", channel=channel))
default_template = Template(self.registryValue("default.template", channel=channel))
(html, is_redirect) = self.get_source_by_url(url)
if html is not None and html:
@ -835,7 +844,7 @@ class SpiffyTitles(callbacks.Plugin):
"""
url = url.split("?")[0]
twitch_client_id = self.registryValue("twitch.clientID")
twitch_handler_enabled = self.registryValue("twitchHandlerEnabled", channel=channel)
twitch_handler_enabled = self.registryValue("twitch.enabled", channel=channel)
if not twitch_handler_enabled or not twitch_client_id:
return self.handler_default(url, channel)
self.log.debug("SpiffyTitles: calling twitch handler for %s" % (url))
@ -1061,11 +1070,11 @@ class SpiffyTitles(callbacks.Plugin):
Typical IMDB URL: http://www.imdb.com/title/tt2467372/
"""
apikey = self.registryValue('omdbAPI')
apikey = self.registryValue('imdb.omdbAPI')
headers = self.get_headers()
result = None
if not self.registryValue("imdbHandlerEnabled", channel=channel):
if not self.registryValue("imdb.enabled", channel=channel):
log.debug("SpiffyTitles: IMDB handler disabled. Falling back to default handler.")
return self.handler_default(url, channel)
@ -1085,14 +1094,33 @@ class SpiffyTitles(callbacks.Plugin):
if request.status_code == requests.codes.ok:
response = json.loads(request.text)
result = None
imdb_template = Template(self.registryValue("imdbTemplate"))
imdb_template = Template(self.registryValue("imdb.template"))
not_found = "Error" in response
unknown_error = response["Response"] != "True"
if not_found or unknown_error:
log.debug("SpiffyTitles: OMDB error for %s" % (omdb_url))
else:
result = imdb_template.render(response)
template_vars = {
"title": response["Title"],
"year": response["Year"],
"country": response["Country"],
"director": response["Director"],
"plot": response["Plot"],
"imdb_id": response["imdbID"],
"imdb_rating": response["imdbRating"],
"tomatoMeter": response["tomatoMeter"],
"metascore": response["Metascore"],
"released": response["Released"],
"genre": response["Genre"],
"awards": response["Awards"],
"actors": response["Actors"],
"rated": response["Rated"],
"runtime": response["Runtime"],
"writer": response["Writer"],
"imdb_logo": self.get_imdb_logo()
}
result = imdb_template.render(template_vars)
else:
log.error("SpiffyTitles OMDB API %s - %s" % (request.status_code, request.text))
@ -1377,7 +1405,7 @@ class SpiffyTitles(callbacks.Plugin):
album = self.imgur_client.get_album(album_id)
if album:
album_template = self.registryValue("imgurAlbumTemplate", channel=channel)
album_template = self.registryValue("imgur.template", channel=channel)
imgur_album_template = Template(album_template)
compiled_template = imgur_album_template.render({
"title": album.title,
@ -1431,7 +1459,7 @@ class SpiffyTitles(callbacks.Plugin):
image = self.imgur_client.get_image(image_id)
if image:
channel_template = self.registryValue("imgurTemplate", channel=channel)
channel_template = self.registryValue("imgur.template", channel=channel)
imgur_template = Template(channel_template)
readable_file_size = self.get_readable_file_size(image.size)
compiled_template = imgur_template.render({
@ -1695,3 +1723,4 @@ class SpiffyTitles(callbacks.Plugin):
return template
Class = SpiffyTitles