PageRenderTime 46ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/README.md

https://github.com/deanishe/alfred-searchio
Markdown | 164 lines | 117 code | 47 blank | 0 comment | 0 complexity | 38e26c9ea3846a2f646c18db26bd35ac MD5 | raw file
  1. Searchio! workflow for Alfred
  2. =============================
  3. Auto-suggest search results from multiple search engines and languages.
  4. ![Searchio! Demo][demo]
  5. Contents
  6. --------
  7. <!-- MarkdownTOC autolink="true" bracket="round" depth="3" autoanchor="true" -->
  8. - [Download and installation](#download-and-installation)
  9. - [Usage](#usage)
  10. - [Configuration](#configuration)
  11. - [Workflow Configuration Sheet](#workflow-configuration-sheet)
  12. - [In-Workflow Configuration](#in-workflow-configuration)
  13. - [Importing Searches](#importing-searches)
  14. - [Adding Engines](#adding-engines)
  15. - [Licensing, thanks](#licensing-thanks)
  16. <!-- /MarkdownTOC -->
  17. Supports the following search engines/websites:
  18. - Amazon
  19. - Bing
  20. - DuckDuckGo
  21. - DuckDuckGo Image Search
  22. - eBay
  23. - Google
  24. - Google "I'm Feeling Lucky"
  25. - Google Images
  26. - Google Maps (requires a Google Places API key)
  27. - Naver
  28. - Wikia (only the top ~200 wikis, but you can [import](#importing-searches) any others)
  29. - Wikipedia
  30. - Wiktionary
  31. - Yandex
  32. - YouTube
  33. - **plus** it can [import a search configuration](#importing-searches) from *any* website that supports OpenSearch autosuggestions
  34. <a name="download-and-installation"></a>
  35. Download and installation
  36. -------------------------
  37. Download the latest version from the [GitHub releases page](https://github.com/deanishe/alfred-searchio/releases/latest).
  38. <a name="usage"></a>
  39. Usage
  40. -----
  41. There are several example searches pre-configured:
  42. - `g` Search Google in English
  43. - `gd` Search Google in German
  44. - `w` Search the English Wikipedia
  45. - `wd` Search the German Wikipedia
  46. - `yt` Search the United States version of YouTube
  47. - `ytd` Search the German version of YouTube
  48. <a name="configuration"></a>
  49. ### Configuration ###
  50. The workflow is configured via the `searchio` keyword and some [workflow variables](https://www.alfredapp.com/help/workflows/advanced/variables/) set in the workflow configuration sheet.
  51. <a name="workflow-configuration-sheet"></a>
  52. #### Workflow Configuration Sheet ####
  53. There are some variables in the workflow configuration screen (open the workflow in Alfred Preferences and hit the `[𝒙]` button):
  54. | Name | Description |
  55. |-------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
  56. | `ALFRED_SORTS_RESULTS` | Set to `1` or `yes` to enable Alfred's knowledge. Set to `0` or `no` to always show results in the order returned by the API. |
  57. | `GOOGLE_PLACES_API_KEY` | You must set this to use Google Maps search. You can get an API key [here](https://developers.google.com/places/web-service/get-api-key). |
  58. | `SHOW_QUERY_IN_RESULTS` | Set to `1` or `yes` to always append the entered query to the end of the results (so you can hit `↑` to select it). If unset (or set to `0` or `no`), the query will only be shown if there are no other results. |
  59. <a name="in-workflow-configuration"></a>
  60. #### In-Workflow Configuration ####
  61. - `searchio [<query>]` Show workflow settings
  62. - `Update Available …` Shown if there is a new version of the workflow available to download. Action the item to install it.
  63. - `Installed Searches …` View and delete your configured searches
  64. - `All Engines …` View supported engines and add new searches
  65. - `Import Search …` Import a new search configuration from a URL (see [Importing Searches](#importing-searches))
  66. - `Reload` Regenerate the workflow's Script Filters from your configured searches (and clean the cache). Run this if you screw up the Script Filters or an update overwrites them.
  67. - `Show Query in Results` Turn the option to show the query you entered in the results on/off. The query is added to the end of the results, so you can hit `↑` to go straight to it. The query is always shown if there are no other results.
  68. - `Alfred Sorts Results` Turns Alfred's knowledge on/off. If on,
  69. Alfred remembers which result you chose for which query and moves
  70. that result to the top. If off, results are always shown in the
  71. order they are returned by the API. If on, `Show Query in Results`
  72. cannot guarantee that the query is always the last result.
  73. - `Online Help` Open this page in your browser.
  74. - `Workflow up to Date` You have the latest version of the workflow. Action this item to force a check for a new version.
  75. <a name="importing-searches"></a>
  76. ### Importing Searches ###
  77. Searchio! has the ability to import a search configuration from any website that supports the OpenSearch autosuggestion API.
  78. Run `searchio` > `Import Search …` and the workflow will offer to import a search from a URL on your clipboard, the frontmost Safari tab or the frontmost Chrome tab.
  79. It will try to find and read the OpenSearch description at the URL and import it (and the website's icon if available), then ask you to assign a keyword for the search.
  80. **NOTE**: Although many websites support OpenSearch, few support the autosuggestion API that Searchio! uses. Sites based on MediaWiki usually support the API, so you can add all your favourite Wikia wikis (the built-in Wikia engine only supports the few hundred most popular wikis).
  81. <a name="adding-engines"></a>
  82. Adding Engines
  83. --------------
  84. In addition to the built-in engines, you can add your own definitions in the `engines` folder in the workflow's data directory. (Enter `searchio workflow:opendata` to open the data folder in Finder.)
  85. An engine definition looks like this:
  86. ```json
  87. {
  88. "description": "Alternative search engine",
  89. "jsonpath": "$[*].phrase",
  90. "title": "DuckDuckGo Images",
  91. "pcencode": false,
  92. "variants": [
  93. {
  94. "name": "Argentina",
  95. "search_url": "https://duckduckgo.com/?iax=images&ia=images&kp=-2&kz=-1&kl=ar-es&q={query}",
  96. "suggest_url": "https://duckduckgo.com/ac/?kp=-2&kz=-1&kl=ar-es&q={query}",
  97. "title": "DuckDuckGo Images Argentina",
  98. "uid": "ar-es"
  99. }
  100. ]
  101. }
  102. ```
  103. `title` and `description` are self-explanatory. `jsonpath` is the JSON path expression that extracts the search suggestions from the JSON returned by the suggestion API.
  104. The optional `pcencode` field tells Searchio! to percent-encode the search query rather than use plus-encoding (the default).
  105. `variants` define the actual searches supported by the search engine, typically one per region or language. All fields are required. `suggest_url` points to the autosuggestion endpoint and `search_url` is the URL of the search results that should be opened in the browser. Both URLs must contain the `{query}` placeholder, which is replaced with the user's search query.
  106. The (optional) icon for your custom engine should be placed in the `icons` directory alongside the `engines` one. It should have the same basename as the engine definition file, just with a different file extension. Supported icon extensions are `png`, `icns`, `jpg` and `jpeg`.
  107. <a name="licensing-thanks"></a>
  108. ## Licensing, thanks ##
  109. The code in this workflow is released under the [MIT Licence](http://opensource.org/licenses/MIT).
  110. The icons belong to the respective search engines and websites.
  111. This workflow uses the following libraries:
  112. - [Alfred-Workflow](https://www.deanishe.net/alfred-workflow/)
  113. - [AwGo](https://github.com/deanishe/awgo/)
  114. - [BeautifulSoup](https://pypi.org/project/beautifulsoup4/)
  115. - [docopt](http://docopt.org/)
  116. - [jsonpath-rw](https://pypi.org/project/jsonpath-rw/)
  117. [demo]: ./docs/demo.gif