Last active
October 10, 2025 02:23
-
-
Save rodhfr/f03cffad002d5556ab5f93030164a757 to your computer and use it in GitHub Desktop.
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
| from flexget import plugin | |
| from flexget.entry import Entry | |
| from flexget.task import Task | |
| from flexget.event import event | |
| import logging | |
| log = logging.getLogger('RoundRobinRSS') | |
| class RoundRobinRSS(object): | |
| """ | |
| Seleciona feeds RSS de forma round-robin. | |
| Mantém o índice entre execuções usando task.manager.persistent | |
| """ | |
| schema = { | |
| 'type': 'object', | |
| 'properties': { | |
| 'feeds': {'type': 'array', 'items': {'type': 'string'}} | |
| }, | |
| 'required': ['feeds'], | |
| 'additionalProperties': False | |
| } | |
| def on_task_input(self, task: Task, config): | |
| feeds = config['feeds'] | |
| if not feeds: | |
| log.warning('Nenhum feed definido para round_robin_rss.') | |
| return | |
| # Recupera o índice persistente | |
| index = task.manager.persistent.get('round_robin_index', 0) | |
| feed_url = feeds[index % len(feeds)] | |
| log.info(f'Round-robin RSS: selecionando feed {feed_url}') | |
| # Atualiza índice para próxima execução | |
| task.manager.persistent['round_robin_index'] = (index + 1) % len(feeds) | |
| task.manager.persistent.commit() | |
| # Retorna entradas do feed usando o plugin RSS interno | |
| rss_plugin = task.get_plugin_by_name('rss') | |
| return rss_plugin.feed_entries(feed_url) | |
| @event('plugin.register') | |
| def register_plugin(): | |
| plugin.register(RoundRobinRSS, "round_robin_rss", api_ver=2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment