Flexget/Flexget — pull request #394 by cvium (2014-12-08 15:14:56+00:00)
Title: Draft of a subtitle queue

I'm tired of having a separate program downloading subtitles, so I have created a very rough draft of a subtitle queue, which a subtitle plugin such as Subliminal can use as input.

This is the schema:
```python
schema = {
"oneOf": [
{
'type': 'object',
'properties': {
'action': {'type': 'string', 'enum': ['add', 'remove', 'emit']},
'stop_after': {'type': 'string', 'format': 'interval'},
'languages': {"oneOf": [
{'type': 'array', 'items': {'type': 'string'}, 'minItems': 1},
{'type': 'string'},
]},
},
'required': ['action'],
'additionalProperties': False
},
]
}
```
Example tasks:
```yaml
populate_subtitle_queue: # just run this once per session to keep queue uptodate
seen: local
find:
path:
- /media/TV Shows/
regexp: '.*\.(avi|mkv|mp4)$'
accept_all: yes
regexp:
reject:
- '.*[sS]ample.*'
subtitle_queue:
action: add

download:
discover:
what:
- emit_series:
from_start: yes
from:
- piratebay: yes
series:
- "Arrow":
begin: S02E01
subtitle_queue:
action: add
languages:
- eng
set:
path: /media/downloads
movedone: "/media/TV Shows/{{series_name}}"
content_filename: "{{ series_name }}"
magnets: no
```
So what does this ugly code do?

The plugin has the ability to queue local files or torrents (does not support magnets). Add the contents of a torrent to the subtitle queue -- if torrent only contains 1 file, then that file is queued and if it contains more than 1 file, then the folder is queued instead.

What annoyed me most about something like this is that sorting tasks will mess with the queue. Therefore this plugin can be used in the same task as `move` and it will add the destination as an alternative filepath in the queue (same goes for torrents wrt. `path` and `movedone`).

`stop_after` is an interval that will drop queued items after the specified interval.

This is all still very rough around the edges and I'm not even sure if it works just yet, but it's at a stage where some third party input would be much appreciated.