You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.0 KiB
36 lines
1.0 KiB
14 years ago
|
from couchpotato.api import addApiView
|
||
|
from couchpotato.core.event import fireEvent
|
||
14 years ago
|
from couchpotato.core.plugins.base import Plugin
|
||
14 years ago
|
from flask.globals import request
|
||
14 years ago
|
from flask.helpers import url_for
|
||
14 years ago
|
from flask.templating import render_template_string
|
||
|
import os
|
||
14 years ago
|
|
||
|
|
||
|
class Extension(Plugin):
|
||
|
|
||
|
def __init__(self):
|
||
14 years ago
|
addApiView('userscript', self.getExtension)
|
||
14 years ago
|
|
||
|
def getExtension(self):
|
||
|
|
||
|
params = {
|
||
14 years ago
|
'includes': fireEvent('userscript.get_includes', merge = True),
|
||
|
'excludes': fireEvent('userscript.get_excludes', merge = True),
|
||
14 years ago
|
'version': self.getVersion(),
|
||
14 years ago
|
'host': '%s%userscript.add_via_url/' % (request.host_url.rstrip('/'), url_for('api.index')),
|
||
14 years ago
|
}
|
||
|
|
||
14 years ago
|
template = open(os.path.join(os.path.dirname(__file__), 'template.js'), 'r').read()
|
||
|
return render_template_string(template, **params)
|
||
14 years ago
|
|
||
|
def getVersion(self):
|
||
|
|
||
14 years ago
|
versions = fireEvent('userscript.get_version')
|
||
14 years ago
|
|
||
|
version = 0
|
||
|
for v in versions:
|
||
|
version += v
|
||
|
|
||
|
return version
|