mirror of
https://github.com/progval/Limnoria.git
synced 2025-04-26 13:01:06 -05:00
add config options useOembedRegistry and useOembedDiscovery
This commit is contained in:
parent
eadac11ab6
commit
427845a358
@ -95,4 +95,12 @@ conf.registerGlobalValue(Web.fetch, 'timeout',
|
|||||||
seconds the bot will wait for the site to respond, when using the 'fetch'
|
seconds the bot will wait for the site to respond, when using the 'fetch'
|
||||||
command in this plugin. If 0, will use socket.defaulttimeout"""))
|
command in this plugin. If 0, will use socket.defaulttimeout"""))
|
||||||
|
|
||||||
|
conf.registerGlobalValue(Web, 'useOembedRegistry',
|
||||||
|
registry.Boolean(False, _("""Determines whether the bot will use the
|
||||||
|
oembed.com providers registry.""")))
|
||||||
|
|
||||||
|
conf.registerGlobalValue(Web, 'useOembedDiscovery',
|
||||||
|
registry.Boolean(False, _("""Determines whether the bot will use HTML
|
||||||
|
discovery to find oEmbed endpoints.""")))
|
||||||
|
|
||||||
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
||||||
|
@ -287,6 +287,7 @@ class Web(callbacks.PluginRegexp):
|
|||||||
First tries the providers registry if enabled, then falls back to
|
First tries the providers registry if enabled, then falls back to
|
||||||
HTML discovery if needed and enabled.
|
HTML discovery if needed and enabled.
|
||||||
"""
|
"""
|
||||||
|
if self.registryValue('useOembedRegistry'):
|
||||||
providers = self._loadOEmbedProviders()
|
providers = self._loadOEmbedProviders()
|
||||||
for provider in providers:
|
for provider in providers:
|
||||||
for pattern in provider.get('endpoints', []):
|
for pattern in provider.get('endpoints', []):
|
||||||
@ -296,6 +297,7 @@ class Web(callbacks.PluginRegexp):
|
|||||||
regex = re.escape(scheme).replace(r'\*', '.*')
|
regex = re.escape(scheme).replace(r'\*', '.*')
|
||||||
if re.match(regex, url):
|
if re.match(regex, url):
|
||||||
return endpoint
|
return endpoint
|
||||||
|
if self.registryValue('useOembedDiscovery'):
|
||||||
try:
|
try:
|
||||||
timeout = self.registryValue('timeout')
|
timeout = self.registryValue('timeout')
|
||||||
response = utils.web.getUrl(url, timeout=timeout)
|
response = utils.web.getUrl(url, timeout=timeout)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user