1
"""Plugin for filesystem feeds."""
4
from flexget import plugin
5
from flexget.entry import Entry
7
log = logging.getLogger('listdir')
10
class Listdir(plugin.Plugin):
12
Uses local path content as an input.
16
listdir: /storage/movies/
20
from flexget import validator
21
root = validator.factory()
23
bundle = root.accept('list')
27
def on_feed_input(self, feed, config):
28
# If only a single path is passed turn it into a 1 element list
29
if isinstance(config, basestring):
33
path = os.path.expanduser(path)
34
for name in os.listdir(unicode(path)):
37
filepath = os.path.join(path, name)
38
# Windows paths need an extra / preceded to them
39
if not filepath.startswith('/'):
40
filepath = '/' + filepath
41
e['url'] = 'file://%s' % filepath
42
e['location'] = os.path.join(path, name)