Skip to content

Instantly share code, notes, and snippets.

@gazpachoking
Created November 13, 2012 18:48
Show Gist options
  • Save gazpachoking/4067620 to your computer and use it in GitHub Desktop.
Save gazpachoking/4067620 to your computer and use it in GitHub Desktop.
Plugin to set the comment in a torrent
import logging
from flexget.plugin import priority, register_plugin
from flexget.utils.template import RenderError
log = logging.getLogger('set_torrent_comment')
class SetTorrentComment(object):
"""
Changes comment in torrent file
Configuration example:
set_torrent_comment: <comment>
"""
def validator(self):
from flexget import validator
return validator.factory('text')
@priority(127)
def on_task_modify(self, task, config):
for entry in task.entries:
if 'torrent' in entry:
comment = entry.get('torrent_comment', config)
try:
comment = entry.render(comment)
except RenderError, e:
log.error('Error rendering torrent comment: %s' % e)
continue
entry['torrent'].set_comment(comment)
register_plugin(SetTorrentComment, 'set_torrent_comment', api_ver=2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment