3
from flexget.plugin import register_plugin
4
from flexget.utils.template import render_from_feed, get_template
6
PLUGIN_NAME = 'make_html'
8
log = logging.getLogger(PLUGIN_NAME)
14
from flexget import validator
15
root = validator.factory('dict')
16
root.accept('text', key='template')
17
root.accept('text', key='file', required=True)
20
def on_feed_output(self, feed, config):
21
# Use the default template if none is specified
22
if not config.get('template'):
23
config['template'] = 'default.template'
25
filename = os.path.expanduser(config['template'])
26
output = os.path.expanduser(config['file'])
27
# Output to config directory if absolute path has not been specified
28
if not os.path.isabs(output):
29
output = os.path.join(feed.manager.config_base, output)
32
template = render_from_feed(get_template(filename, PLUGIN_NAME), feed)
34
log.verbose('Writing output html to %s' % output)
36
f.write(template.encode('utf-8'))
39
register_plugin(OutputHtml, PLUGIN_NAME, api_ver=2)