I'm working on a script to play music using MPD. I want to list available albums and have Alfred filter them rather than doing the filtering myself in a script filter. But when I check the "Alfred filters results" check box, the result is an empty list regardless of what I type:
If, on the other hand, I uncheck that box, I get a list of albums as expected, but I can't type to filter them:
Here's my code, in Python. It's really not very complicated:
from __future__ import unicode_literals
from __future__ import print_function
import json
import os
import subprocess
import sys
MUSIC_DIR = '/Users/Shared/iTunes/iTunes Media/Music'
FIND_CMD = [
'/usr/local/bin/mpc', 'list', 'album'
]
def make_item(album_name):
return dict(
title=album_name,
uid=album_name,
valid=True,
arg=json.dumps({'album': album_name}),
icon='icon.png',
autocomplete=album_name,
)
def main():
print(json.dumps({
'items': [
make_item(item)
for item in subprocess.check_output(FIND_CMD).decode('utf-8').split('\n')
if item.strip()
]
}))
if __name__ == '__main__':
sys.exit(main())
Can anyone tell me what I might be doing wrong?