Created
November 13, 2012 18:48
-
-
Save gazpachoking/4067620 to your computer and use it in GitHub Desktop.
Plugin to set the comment in a torrent
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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