Jump to content

Search the Community

Showing results for tags 'json'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Alfred 3
  • Make the Most of Alfred
    • Discussion & Help
    • Bug Reports
    • Alfred Feature Suggestions
    • Themes
  • Alfred Workflows
    • Share your Workflows
    • Workflow Help & Questions
    • Workflow Advanced Tips & Tricks
    • Workflow Automation Tasks
  • Alfred Themes
  • Alfred Remote for iOS
    • Alfred Remote Discussion & Help
    • Remote Connection Troubleshooting


  • Articles
    • Forum Integration
    • Frontpage
  • Pages
  • Miscellaneous
    • Databases
    • Templates
    • Media

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start




Website URL




Found 20 results

  1. I'm starting out trying to make workflows and have to this point just managed to do web searches on a specific website by using Alfred's buildt inn function with the {query} option. This has worked out perfectly with sites that displays a HTTP address for a search, but how can i tackle pages that does not do this? ATM i'm trying to make a search for this page http://www.magnusli.no/ifirooms/. I tried to inspect the getRoom() function and stole a link from there include/get_room.php?id= and tried to use the {query} on that (with eg. 'Caml' as a search) and that worked to a point where the function returned the data for that search, but that was not what i intended to do. The request returned this: Wanted outcome: Any tips or input as to where to start or how to tackle an issue like this would be much appreciated. Thank you!
  2. I probably spent far too much time not knowing what I was doing to produce this workflow but now that it will prettify a single obfuscated .json file, I could use some help with improvements: Support prettifying multiple selected files at a time (I've been able to do this with other languages, but haven't figured out how to work with an array of files in python in a Script Filter) Ignore any non-JSON files that might be passed in (currently if you run this against a TXT file, it'll replace the file contents with {query}! (whoops)) Improve the notifications based on whether a single or multiple files were processed I did take a look at @deanishe's Workflow Library or Python but it seemed like overkill for what I wanted to do. Also, I did find several other workflows that will prettify the clipboard's contents, but I specifically want to just handle files in Finder (for now). I found this technique which looked promising, but I kept getting syntax errors in the Script Filter when I would run it: import json import os # Read JSON data from file and pretty print it with open("{query}", "r") as jsonfile: # Convert JSON file to Python Types obj = json.load(jsonfile) # Pretty print JSON data pretty_json = json.dumps(obj, indent=4) print(pretty_json)
  3. I have a very basic python question that I was hoping to get a little help with that involves filtering out list items in a script filter. At the moment, the script filter works great except that it includes a few items I'd prefer not to see in Alfred's output. Is there any easy way to remove items whose titles can be found in another list? Admittedly, I normally do these sorts of things in AppleScript - which is pretty easy to do in this case - except that I’ve been trying to learn a little python, given all of the limitations with AppleScript (which @deanishe and @vitor have rightly reminded me of on numerous occasions, so hopefully this will make them proud 😃). For example, let’s say that I have the following list: titles_remove = {"Title A", "Title B", "Title C"} And, before outputting my results in Alfred, I’d like to remove all items whose titles can be found in titles_remove. At the moment, my script filter ends with the following line: print(json.dumps(result)) And, it’s JSON output follows the usual format where each item has a title, subtitle, uid, and arg. Now, if I modify that last line so that it’s output is: unfiltered_output = json.dumps(result) What should I do next to remove items whose titles can be found in the titles_remove list? I tried following several different python tutorials, but I kept receiving errors. I suspect that some of the methods weren't intended for dealing with strings. But I'm a complete newbie here. Thanks for any help you can lend! I really appreciate it. And, if anyone has any advice for python newbies that might want to do things with Alfred, I'd greatly appreciate any recommendations on potential resources to check out, etc. Thanks!!
  4. Hi all, I am working on a workflow which 1) loads a large (43MB) JSON object and then 2) uses Alfred to filter results (with word matching). Alfred currently takes ~3 sec to load the object. Here's my question: given that I am not fetching anything over the web or local network, would it still be beneficial (i.e. would make it faster) if I learn how to cache the JSON object? Or perhaps I should search via script and only serve the results to Alfred? Thanks!! Giovanni
  5. I’m struggling to get a script filter to work which outputs a variable containing a mixture of text and emojis. In the output, Alfred just spits out empty characters for the emojis (⍰ question mark in a box). There’s obviously an encoding issue I’m overlooking, and I haven’t been able to quite put my thumb on it. To explain, I’ve created a script filter with AppleScript that’s supposed to let the user select a playlist from their Apple Music library (to play it, move it, etc). I recently moved over from Spotify to Apple Music, and I have a ton of playlists (put that's a separate problem - ha)! And, as you might guess, some of my playlists include emojis. When I run the script filter, Alfred’s output just shows empty characters where the emoji’s used to be. Consider the following example: Playlist: Radiohead ⭐ Faves Script Filter/Alfred Output: Radiohead ⍰ Faves Debug: Radiohead \u2b50 Faves So, while most of this is over my head, from what I understand, my JSON output is being spit out as formatted for C/C++/Java Src (when it should be in the usual utf8 unicode format). Any suggestions for fixing it? I've never tinkered around with JSON.scpt file that does all of the heavy lifting, so hopefully it's just a minor issue with my code. Admittedly, I’ve always been confused about how JSON and AppleScript work together. Although I’ve been able to create script filters in the past thanks to everyone’s help, I’ve never made one that dealt with text that containing emojis. Thanks for any help you can lend! For testing purposes, I’ve uploaded a test workflow here: https://share.getcloudapp.com/xQuDN0dl. And, here's screenshot of its script filter:
  6. I have a very basic question about how script filters work that I haven’t been able to find a direct answer to on this forum or on Alfred’s support page. To be fair, there’s a ton of fantastic information on both, but I simply haven’t found one dumbs its explanation down enough for me to follow it. I've been using Alfred for quite some time, but have never been able to understand much about script filters. In short, I was wondering how to get items from an AppleScript list to show up as JSON formatted items in a script filter’s output (so that I can select one of them, and have it operate like the argument in a subsequent object)? For simplicity, let’s say I have an AppleScript that generates the following list: {"Red", "Green", "Blue”} But, in practice, that list will be dynamically produced and longer. In other words, I can't get away with just manually listing each item in the script filter (like in Alfred's jsonformat workflow example: Getting Started/Script Filter). Based on this example, how do I get the script filter’s output to operate like the following? Item 1 Title: Red SubTitle: Same Words Red Argument: Red Item 2 Title: Green SubTitle: Same Words Green Argument: Green Item 3 Title: Blue SubTitle: Same Words Blue Argument: Blue To illustrate, here’s what the output might look like when created with a list filter: *** @deanishe, I tried following your helpful advice and added a json.scpt file from another workflow that also used this approach. However, I couldn’t quite figure it out. Is there any way that I could talk you - or anyone else - into walking me through this, using the following example? 🙏 Based on the example above, I’ve created a very basic workflow to help illustrate things (for myself and others): Download Workflow. The workflow contains: (1) a script filter and (2) a list filter. The script filter has been stripped down to a single line of code that sets a variable to the afore mentioned list above (set theList to {"Red", "Green", "Blue"}) (AppleScript). In other words, I removed all of my failed attempts, and have only included this line in the AppleScript as a starting point (I understand there’s more to be done here). As for the list filter, it was included to illustrate how I’d like the script filter to perform (i.e., its output). I understand that if the string/list was fixed, that I could always just use it (instead of a script filter). Again, this was added strictly for illustrative purposes. To keep things simple, both filters simply copy their output to the clipboard. So, if you select the “Green” item from Alfred’s output, it would copy the word “Green” to the clipboard. In practice, this would be connected to another object that would do something else with the variable. But this struck me as an easiest way to test things. Can someone help walk me through how to set up the script filter so that it operates like the list filter (using an applescript list of variables)? Thanks in advance for any help you can lend! I really appreciate it.
  7. Hello,everybody! I write a javascript in alfred workflow, try to return the json and copy the result to clipboard at the same time. Could anybody tell me how to make it?Thanks~ function run(argv) { var temp = argv[0]; var num; num = temp * 1000; return JSON.stringify({items: [ {title: "The number is :", subtitle:num } ]}) //return num;//It dosn't work. }
  8. This is my error : [ERROR: input.scriptfilter] JSON error: JSON text did not start with array or object and option to allow fragments not set. in JSON: input the {"items":[]} "input the" is the result of code "echo $userInput This Alfred node, runs a script called search.rb. I've screen shotted it below as well. The script calls all redbooth API's(a project management app) Projects, Tasklists and tasks. It then runs a loop through each item and looks for titles that match the user input/ARGV. I have run the script locally in my terminal and the script returns the correct objects and should be printing them/returning to Alfred. However I get the above issue and I can't seem to figure out where my disconnect is. Additional info/screen shots below. search.rb/the script alfred runs to generate the script filter options. This code(below/list_proj.rb) calls the redbooth API and takes all returned objects/projects and converts the data to json. When the script rubs as is in a alfred script node- it populates the filter options. This code works to the desired effect. Posting for comparison This is a snap shot of the work flow. Everything works with the exception of the Search function/nodes Please let me know if I can provide anything else. I have a separate plugin that provides user auth for the work flow to access the redbooth client API. Any insights to this error or what I may have missed would be well appreciated. Thanks!
  9. I'm new to creating Workflows. I'm trying to create a workflow that will pull the data via API to JSON and show results directly in Alfred without the need to visit the website to look at the response. API REQUEST GET https://api.website.com/?domain=test.com&apikey=yourapikey&output=output_type So, what I'm trying to do is this: type "dns test.com" then request is: GET https://api.website.com/?domain=test.com&apikey=123123123123123&output=json The response will be: JSON response will look like this: { "query": { "tool": "name of the tool", "domain": "test.com" }, "expectedresponse": "", "response": { "server": [ { "location": "Town, Country", "resultvalue": "", "resultstatus": "ok" }, { "location": "Another Town, Another Country", "resultvalue": "", "resultstatus": "ok" }, ] } } and I'm trying to show it in the Alfred window: DNS test of test.com Expected Response: 1. Town, Country - - NOT OK 2. Another Town, Another Country - - OK etc. Any help would be appreciated
  10. I'm new to writing workflows. I'm having a trigger that launches a php script, I have a loading text for that trigger, but the items returned by my script will also take time when the user chooses them, so I'd like to change also the subtitle once it's chosen, so that the user knows something is being worked on after his choice. Is there a way? Or am I missing something in how the script filters work? I am not launching another script once the user selects an option, and I don't post anything (just grabbing data from an API, and injecting the results in Alfred items at the final step). Thanks
  11. Working on Workflow...Script Filter Alfredv3.1.1 (737) Mac O SX 10.12 Dropbox Link <removed> Trying to get the results displayed as choices in Alfred. Error [ERROR: input.scriptfilter] JSON error: JSON text did not start with array or object and option to allow fragments not set. in JSON With (bash) base_uri="https://xyz.execute-api.us-west-2.amazonaws.com/prod/listfromalfred?user=${user}&task=${data}" post_result=$(/usr/local/bin/curl -X GET ${base_uri}) post_success=`echo ${post_result} | grep items` echo ${post_success} | sed 's/\\//g' This test code works #test='<items><item uid= "test " arg= "one "><title>em11@mail.com</title><subtitle>em11@mail.com</subtitle><icon>icon.png</icon></item></items>' #echo ${test} However, when I call the API I get: 'Response code: 200\n' [2016-10-23 12:19:23][ERROR: input.scriptfilter] JSON error: JSON text did not start with array or object and option to allow fragments not set. in JSON: "<items><item uid= "test" arg= "one"><title>em11@mail.com</title><subtitle>em11@mail.com</subtitle><icon>icon.png</icon></item></items>" Debugging for hours and can't seem to fix the issue. Trying to get the results displayed as choices in Alfred. HELP
  12. A tiny thing, really. In the documentation for the JSON feedback format, the term "array" is used for JSON objects. text, mod and icon are objects. items is an array (inside an object). In JavaScript, and thus JSON, "arrays" are ordered lists: ["this", "is", "an", "array"], while dictionaries/mappings are called "objects": {"this": "is", "an": "object"} (In JS, thing["key"] is equivalent to thing.key) http://www.json.org
  13. Currently, if I output the following: {"items": [ { "title": "Foo", "arg": "unicorn" } ]} I have to handle the `unicorn` arg in a connected output action in the workflow. It would be useful to be able to dynamically handle it without needing to create an output action. This can be useful for very dynamic results and creating reusable modules that create output with different actions. I propose adding a `script` property to the JSON format that when specified makes it not pass the output to any connected output action (like `valid: false`) and instead executes the `script` and passes `arg` to it. {"items": [ { "title": "Foo", "arg": "unicorn", "script": "run-foo.sh" } ]} This would make script filters a lot more powerful.
  14. Hi, I'm using Alfred 3's Script Filter + JSON format to return a list. However, I found that despite I output a static ordered list, the ordering that display on Alfred is dynamic. That is, Alfred seems to alter the ordering. It looks like Alfred tend to put the most recent used item to the top. I'm wondering if there is any way to configure this behavior or turn it off? Thanks.
  15. Good morning, I'm currently trying to create a simple Script Filter Alfred 3 Workflow using Python. I found an earlier example which demonstrated how to pass XML results to a Python workflow: xmloutput = """ <?xml version="1.0" encoding="utf-8" ?> <items> <item arg="testitem"> <title>FooBar</title> <subtitle>foo bar is a test item</subtitle> <icon>icon.png</icon> </item> </items> """ print(xmloutput) My question is, what is the syntax for doing the same with the new JSON data structure? regards, Andrew
  16. Is it possible to use a JSON Config block to affect the keyword of a connected block? I've tried copying the copy the config of a Script Filter block into a JSON Config block and changing the keyword, but it appears to have no effect. Overall, can anyone provide any details on how the JSON Config blocks are intended to be used?
  17. Hello, Im rewriting my old alfred 2 workflows using great alfred 3 json api and it is difficult to understand what icon types I can use - https://www.alfredapp.com/help/workflows/inputs/script-filter/json/- it is not clearly described there(( "icon": { "type": "fileicon", "path": "~/Desktop" } - What other icon types I can use? Can I load icons using url? (I know that was impossible in alfred 2) or I should use something like https://github.com/sananth12/ImageScraper ? this is my old workflow preview I use it not only for movies but for parsing dynamic web content and an ability to load images using url and dynamicly resize them would make my life much easier - If it is not possible it is ok - I just wanted to check in case I missed it
  18. Hi, For my Spotify Mini Player workflow, I need to parse a library.json file which contains all spottily playlists of the user. The json data looks like: [ { "data" : { "discNumber" : 1, "album" : { "artist" : { "portrait" : "", "type" : "artist", "name" : "J-Boogie's Dubtronic Science", "uri" : "spotify:artist:76MRWSA9TZZg6s3Ijy7mxW" }, "availableForPlayback" : true, "availability" : 0, "cover" : "spotify:image:b9346fb9030ede38617e42eafd553d17fa7cf307", "year" : 2009, "type" : "album", "numTracks" : 0, "name" : "Soul Vibrations Dub Remixes", "uri" : "spotify:album:1QMgSZ88TOWU6ctJRAW4T6" }, "trackNumber" : 12, "availableForPlayback" : true, "uri" : "spotify:track:7AAR8NjH6RY4Dk5Ny5xQcb", "starred" : false, "artists" : [ { "portrait" : "", "type" : "artist", "name" : "J-Boogie's Dubtronic Science", "uri" : "spotify:artist:76MRWSA9TZZg6s3Ijy7mxW" } ], "popularity" : 23, "type" : "track", "isAd" : false, "availability" : 0, "isLocal" : false, "isPlaceholder" : false, "isExplicit" : false, "duration" : 290000, "isInvalid" : false, "isLoaded" : true, "name" : "1.4.u Dub - Feat. Ohmega Watts & Ragen Fykes" } } ] I am new to php (this is the first time i use it), so to parse this json file, I "loop" on all items and use strpos() to find matches: $json = file_get_contents($w->data() . "/library.json"); $json = json_decode($json,true); foreach ($json as $item) { if (strpos(strtolower($item['data']['album']['artist']['name']),strtolower($query)) !== false || strpos(strtolower($item['data']['album']['name']),strtolower($query)) !== false || strpos(strtolower($item['data']['name']),strtolower($query)) !== false) { // do something } }; This is working fine and I don't have any performances issues(i was surprised by the speed actually) with my Spotify library (2.2Mb JSON file with around 2200 tracks) But some users have more than 100 playlists, so the json file is about 15Mb To decode the json file, I had to add: ini_set('memory_limit', '128M' ); Questions: Is it a problem to set memory_limit like this? Is there a clever way to read/parse a JSON file? What about transforming the json data into a SQL db? Would it give better performances? I'm open to any suggestions :-) Cheers
  19. Hi, (among other starter problems) I have the following problem: The below script runs fine in the Mac OSX terminal. But as an "run script" action (type "python") it hangs. When I delete the urlopen line the script runs to the end (but of course without a JSON result). The small workflow is here: http://d.pr/f/K3t So something seems to be wrong with the line "response = urllib2....": import urllib2 import urllib import json url='{query}' endpoint='http://api.longurl.org/v2/expand' params = {'url':url, 'title':'1','format':'json'} response = urllib2.urlopen(endpoint+'?'+ urllib.urlencode(params)) try: json_data = json.loads(response.read()) print 'URL: '+json_data[u'long-url'] #print 'Page title: '+json_data[u'title'] except: print 'Sorry - could not find the long URL' How can I debug this? How should I retrieve a JSON result from a webservice? Thanks in advance! Thomas
  20. Workflows' JSON API (new) (Recommended) API on Github: https://raw.github.com/hzlzh/AlfredWorkflow.com/master/workflow-api.json API backup: http://www.alfredworkflow.com/workflows-api/ -- API info -- Download Link by Author = workflow-download-link (Important!) Backup download link on Github = https://raw.github.com/hzlzh/AlfredWorkflow.com/master/Downloads/Workflows/ + workflow-file Everyone can load all the workflows' download links by using this API, mybe @phyllisstein can add this in Alleyoop.
  • Create New...