dmccurley Posted June 23, 2019 Share Posted June 23, 2019 New to Alfred. I understand what needs to be changed to access DEVONthink 3, but need some help on where the changed needs to be made. Link to comment
nestorito Posted September 8, 2019 Share Posted September 8, 2019 On 6/23/2019 at 2:00 AM, dmccurley said: New to Alfred. I understand what needs to be changed to access DEVONthink 3, but need some help on where the changed needs to be made. Second this: I updated the search scope with the new metadata folder, but apparently nothing changed; I guess some of the scripts in the workflow should be updated? For example in the tell block I think know the name of the app is "DNtp"...what do you say @brunoc? Link to comment
Jasondm007 Posted January 24, 2020 Share Posted January 24, 2020 @brunoc Thanks for sharing this workflow. It's fantastic - and has really improved my experience with DEVONthink! Thanks a ton!! Quick Question: Is it possible - either with some modifications to the "search groups" portion of the workflow or by creating a new action - to include Global Smart Groups? I use these a ton, and would love to quickly access them in the same manner that your fantastic workflow does for normal groups. Thanks again! Link to comment
brunoc Posted January 28, 2020 Author Share Posted January 28, 2020 On 1/24/2020 at 3:26 PM, Jasondm007 said: @brunoc Thanks for sharing this workflow. It's fantastic - and has really improved my experience with DEVONthink! Thanks a ton!! Quick Question: Is it possible - either with some modifications to the "search groups" portion of the workflow or by creating a new action - to include Global Smart Groups? I use these a ton, and would love to quickly access them in the same manner that your fantastic workflow does for normal groups. Thanks again! Hi @Jasondm007. Thanks for your feedback! Searching Global Smart Groups make perfect sense. I just have to figure a way to prevent this kind of choice in the "Move To..." file action. I'll give it some thought soon... Link to comment
brunoc Posted January 28, 2020 Author Share Posted January 28, 2020 On 9/8/2019 at 1:00 PM, nestorito said: Second this: I updated the search scope with the new metadata folder, but apparently nothing changed; I guess some of the scripts in the workflow should be updated? For example in the tell block I think know the name of the app is "DNtp"...what do you say @brunoc? I've updated the scripts in December – it should be working with DT3. Is it working for you guys? Link to comment
Jasondm007 Posted January 28, 2020 Share Posted January 28, 2020 1 hour ago, brunoc said: Hi @Jasondm007. Thanks for your feedback! Searching Global Smart Groups make perfect sense. I just have to figure a way to prevent this kind of choice in the "Move To..." file action. I'll give it some thought soon... Thanks a ton @brunoc!! I really appreciate it. Link to comment
giovanni Posted February 13, 2020 Share Posted February 13, 2020 Thank you @brunoc for creating this workflow, super helpful! Has anybody tried it across sync'd databases? I sync my DEVONthink database via a localsync store (and Alfred through a shared folder). The DEVONthink browser worked on both initially, but stopped working on my laptop. I reinstalled with no effect. Would you have recommendations on how to troubleshoot? Thanks! Giovanni Link to comment
brunoc Posted February 13, 2020 Author Share Posted February 13, 2020 Hi @giovanni. It should definitely work with sync'ed databases + Alfred preferences on a shared folder. I do exactly that with Dropbox in both a laptop and an iMac. Did you try forcing the cache update with dtp:refresh? Do you get any errors in debug mode () ? Link to comment
giovanni Posted February 13, 2020 Share Posted February 13, 2020 1) yes 2) this is what I get when I try 'dtp test' (no groups are shown in Alfred) [16:31:23.506] Logging Started... [16:31:26.957] DEVONthink Browser[Script Filter] Queuing argument '(null)' [16:31:27.068] DEVONthink Browser[Script Filter] Script with argv '(null)' finished Thanks! Giovanni Link to comment
brunoc Posted February 13, 2020 Author Share Posted February 13, 2020 @giovanni in addition, if you've ever duplicated the workflow, make sure it as a proper "Bundle id" (right click the workflow name on the list -> Edit details). It should be "br.com.brunoc.dtpbrowser" or anything else unique. Alfred 4 goes crazy without a warning if there's no bundle id attributed to the workflow. Link to comment
giovanni Posted February 14, 2020 Share Posted February 14, 2020 thanks @brunoc, yes I had duplicated it in the past, but left a single copy after reinstalling. I found a difference between laptop and desktop: if I force cache refresh in debug mode, I get this, on laptop only: [07:57:40.673] DEVONthink Browser[Script Filter] Queuing argument '(null)' [07:57:40.784] DEVONthink Browser[Script Filter] Script with argv '(null)' finished [07:57:42.174] DEVONthink Browser[Keyword] Processing complete [07:57:42.175] DEVONthink Browser[Keyword] Passing output '' to Run Script [07:57:42.337] STDERR: DEVONthink Browser[Run Script] ./dtp-list-groups.applescript:348:353: script error: Expected class name but found identifier. (-2741) [07:57:42.345] DEVONthink Browser[Run Script] Processing complete [07:57:42.346] DEVONthink Browser[Run Script] Passing output '' to Post Notification does this help? Thanks again Giovanni Link to comment
giovanni Posted February 21, 2020 Share Posted February 21, 2020 Quick update: this is now working on both computers. I have no idea what changed, I am happy to help troubleshoot if I can. Thanks again for getting back to me! Giovanni Link to comment
dgbeecher Posted April 10, 2020 Share Posted April 10, 2020 (edited) Wow, this workflow is amazing. I switched to Alfred (from Quicksilver!) back in 2015, mainly because I saw the potential for using it with DTPO. None of the Alfred/DTPO workflows available then satisfied me, I couldn't figure out how to make one myself, and I eventually gave up on linking my two favorite apps. What you've made is exactly what I've wanted all these years. Thank you!! (And thanks also for the Keyboard Maestro macro, which is a great way to keep the cache updated.) Edited April 10, 2020 by dgbeecher brunoc 1 Link to comment
PaulF Posted April 21, 2020 Share Posted April 21, 2020 (edited) Thanks @brunoc - I downloaded your workflow a few days ago and, after waiting for the cache to refresh, all seemed well. However, a few days later I went to use the workflow again and unfortunately couldn't get it to work correctly as it had before. Here is a sequence of screenshots that show how it is failing for me. I haven't tried to debug the workflow on my end because I have no expertise but would be happy to run any tests that might help you understand what is going on. I was particularly excited by the file actions and am motivated to do whatever I can on my end to make this work. Thanks for developing and sharing the workflow. Here is the sequence of events as I type dtp <space>. After the space, I seem to have dropped out of your workflow. Edited April 22, 2020 by PaulF insert copy of images instead of URL pointers to images Link to comment
PaulF Posted April 29, 2020 Share Posted April 29, 2020 I tried again today and all seems well. I really don't know what changed. I did see a "waiting for DEVONthink" message just before it "dropped out" of the dtp workflow before. I saw that same message today, but this time all went well. I really love the "Move to DEVONthink" file functionality combined with the group search - thanks again @brunoc! Link to comment
PaulF Posted May 3, 2020 Share Posted May 3, 2020 ... not working again (no DT groups are listed as indicated in previous screenshots) and now I have enabled debug and get the following error: [18:00:14.034] ERROR: DEVONthink Browser[Script Filter] JSON error: Badly formed object around character 185584. in JSON: {"items": [{"uid":"C6CB480C-35A4-4C ... ... ...[truncated] This is the first and only debug message after "logging started" and is thrown as soon as dtp is typed within Alfred. If I hit return to force the cache to refresh, clear the debug window and type dtp a second time I still get the same error. Any help for how to proceed would be most welcome. In the meantime, I am trying to find the cache file location so that I can parse the json file and see if the "badly formed" object is obvious to me. I see the environment; variable ${alfred_workflow_cache} but being new to workflows am still trying to see where that variable is defined since it isn't one of the user settings. Link to comment
brunoc Posted May 3, 2020 Author Share Posted May 3, 2020 @PaulF do you have any groups containing quotes (“) in their names? This is known to break the workflow. Link to comment
brunoc Posted May 3, 2020 Author Share Posted May 3, 2020 @dgbeecher thanks for your feedback! dgbeecher 1 Link to comment
PaulF Posted May 3, 2020 Share Posted May 3, 2020 @brunoc I have looked at my databases and I do have some groups with a quote (") in the name, and that is causing the problem. I created a small test database containing a group with a quote (") in the name. I then stepped through your script: dtp-list-groups.applescript (outside of Alfred) and captured the jsonOutput. I then looked at that data with a JSON formatter and I get an error unless: 1. I manually delete the extra quote (") 2. I manually insert a backslash (\) in front of the quote (") I see how an extra quote would cause problems given the reliance of the quote (") in the JSON format itself. However, I did find that people are using backslashes to escape the quote (") in similar situations How to escape double quotes in JSON. I don't know if you can encode the strings to protect the quote (") going into the jsonOutput or how this might affect the query side of your script. In the meantime, I will remove the quotes (") from those group names. Thanks again for providing this very useful workflow. Link to comment
PaulF Posted May 3, 2020 Share Posted May 3, 2020 @brunoc I just did a proof of concept test using my small test database that has the problematic group name 1. I ran "dtp" and forced the cache to update - it failed, as usual, because of the extra quote ("). 2. I then went to the cache and edited the "broken" jsonOutput by inserting a backslash (\) in front of the extra quote (") 3. I then reran "dtp" and this time there was no error and everything works as expected ... until the cache updates. Here is the window showing the group name with the internal quote ("). Selecting this group works as expected and the group is opened within DEVONthink correctly! Link to comment
brunoc Posted May 3, 2020 Author Share Posted May 3, 2020 @PaulF Those groups containing quote marks are the culprits! You'll have to rename them. Being a very lame AppleScript programmer myself, I was unable to find a way to protect some variables against this problem 😞 Link to comment
PaulF Posted May 3, 2020 Share Posted May 3, 2020 @brunoc from what I can see, you're much better than me! Maybe someone else will be able to help out, and I will take a look myself. If I make any progress I will share it with you. Link to comment
PaulF Posted May 3, 2020 Share Posted May 3, 2020 @brunoc I think this works: The strategy is to escape the quote (") as (\") as required for JSON. Quote The following characters are reserved in JSON and must be properly escaped to be used in strings: Backspace is replaced with \b Form feed is replaced with \f Newline is replaced with \n Carriage return is replaced with \r Tab is replaced with \t Double quote is replaced with \" Backslash is replaced with \\ All I did was introduce a "findAndReplaceInText" generic routine for replacing text in strings from the Mac Automation Scripting Guide which can then be used to escape the group name strings. I used that routine in your "addToGroups" to replace any quotes (") within "theName" to (\"). The routine string parameters are actually "\"", and "\\\" To add a single quote to a string in AppleScript already requires it be specified as \" To specify the required output means adding two backslashes, I think the first escapes the second! When I look at the JSON output, your original code using "theName" gives: "2019-08-19: 3" tie in west pasture" which causes a problem for JSON. However, using the modified code with "theEscapedName" gives: "2019-08-19: 3\" tie in west pasture" which is accepted by JSON and doesn't seem to affect the functioning of the rest of your code. Quote on findAndReplaceInText(theText, theSearchString, theReplacementString) set AppleScript's text item delimiters to theSearchString set theTextItems to every text item of theText set AppleScript's text item delimiters to theReplacementString set theText to theTextItems as string set AppleScript's text item delimiters to "" return theText end findAndReplaceInText on addToGroups(theName, theUUID, theDB) if (my numCurrentLevel ≥ my numLevelMin) and (my numCurrentLevel ≤ my numLevelMax) then set theEscapedName to findAndReplaceInText(theName, "\"", "\\\"") set the end of my lstGroups to {theEscapedName, theUUID, theDB} end if end addToGroups Link to comment
nestorito Posted May 4, 2020 Share Posted May 4, 2020 8 hours ago, PaulF said: @brunoc I think this works: The strategy is to escape the quote (") as (\") as required for JSON. All I did was introduce a "findAndReplaceInText" generic routine for replacing text in strings from the Mac Automation Scripting Guide which can then be used to escape the group name strings. I used that routine in your "addToGroups" to replace any quotes (") within "theName" to (\"). The routine string parameters are actually "\"", and "\\\" To add a single quote to a string in AppleScript already requires it be specified as \" To specify the required output means adding two backslashes, I think the first escapes the second! When I look at the JSON output, your original code using "theName" gives: "2019-08-19: 3" tie in west pasture" which causes a problem for JSON. However, using the modified code with "theEscapedName" gives: "2019-08-19: 3\" tie in west pasture" which is accepted by JSON and doesn't seem to affect the functioning of the rest of your code. Same problem here! I tested on a small new database and I had no problem while adding back my work database breaks the workflow with the same error: Quote JSON error: Unescaped control character around character 15453. in JSON The problem is I'm not able to finde a group in the work database that could contain quote marks, any hint on how 'correct' the problem? I don't understand where to add the rename routine... Link to comment
PaulF Posted May 5, 2020 Share Posted May 5, 2020 @nestorito any changes that I made will only address group names with quotes(") which break the workflow according to @brunoc Here is how I found my groups that contain quotes (") Hope this helps. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now