Jump to content

Script Filter Sorting Not Working with Python

Recommended Posts



I have several script filter workflows that are in essence collections of bookmarks on some topic. E.g. keyword 'ebike' produces a list of URLs for webpages on ebikes.


Some of the script filters are scripted in ruby, and these produce a list in sorted order: the last or most used URLs are listed first. This is the behaviour that I want. Other workflows are scripted in python, and these I cannot get to sort the way I like.


Here is an example in ruby:

require 'json'

arg = ARGV.to_s

if !arg.include? " "
arg = ARGV[0]
query = arg.to_s

arg = ARGV.join(" ")
query = arg.to_s

URL0 = "http://la-conjugaison.nouvelobs.com/rechercher/index.php?mot=" + query + "&moteur=conjugaison"
URL1 = "http://la-conjugaison.nouvelobs.com/rechercher/index.php?mot=" + query + "&moteur=synonyme"
URL2 = "http://la-conjugaison.nouvelobs.com/rechercher/index.php?mot=" + query + "&moteur=definition"

script_filter_items = []

script_filter_items.push(uid: 'JAAE-CONJ-00000', title: 'Conjugaison', arg: URL0)
script_filter_items.push(uid: 'JAAE-CONJ-00001', title: 'Synonyme', arg: URL1)
script_filter_items.push(uid: 'JAAE-CONJ-00002', title: 'Definition', arg: URL2)

puts({ items: script_filter_items }.to_json)


And here an example in python:

import json
import sys

URLs = {
"eBikes on Reddit": ["https://www.reddit.com/r/ebikes/","JAAE-ebikes-0000001"],
"Modern Bike": ["https://www.modernbike.com/","JAAE-ebikes-0000002"],
"Pedelec Forum": ["https://www.pedelecforum.de/forum/index.php?forums/bosch.30/","JAAE-ebikes-0000003"],
"Youtube 'The Yorkshire Bike Mechanic'": ["https://www.youtube.com/c/TheYorkshireBikeMechanic/videos","JAAE-ebikes-0000004"]
alfred_results = []
for key in URLs.keys():
 	result = {
 			"title": key,
 			"subtitle": "",
 			"arg": URLs[key][0],
 			"UID": URLs[key][1]
response = json.dumps({
 	"items": alfred_results


What am I doing wrong or overlooking?


Any help would be greatly appreciated.



Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...