Skip to content

Commit 8fb1cce

Browse files
committed
Add file support
1 parent daf8197 commit 8fb1cce

File tree

2 files changed

+40
-12
lines changed

2 files changed

+40
-12
lines changed

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
**📢 This repo is maintained and up to date.**
22

3-
<sup>(If it ever gets abandoned, this date will be far in the past: <i>September 1, 2022</i> )</sup>
3+
<sup>(If it ever gets abandoned, this date will be far in the past: <i>February 9, 2023</i> )</sup>
44

55
---
66

77
# 💌 Send to Hydrus
8-
Share URLs on Android into Hydrus Client API
8+
Share files and URLs on Android into Hydrus Client API
99

1010
## 🛠️ Setup
1111
- Download [HTTP Shortcuts](https://http-shortcuts.rmy.ch/)
12-
- Import [ZIP file](https://github.com/Wyrrrd/send-to-hydrus/releases/latest/download/shortcuts.zip)
12+
- Under "Import / Export", choose "Import from URL", enter<br>`https://github.com/Wyrrrd/send-to-hydrus/releases/latest/download/shortcuts.zip`
1313
- Set variable `hydrus_url` to your Hydrus Client API URL
14-
- Perform request or set variable `hydrus_api_key` to your API key
14+
- Perform request or set variable `hydrus_api_key` to your API key (needs file and URL permissions)
15+
16+
## ⬆️️ Upgrade
17+
If you are using the older, URL-only version, your API key will not have the file permission. To fix this, remove the API key in Hydrus and then create or request a new one.
1518

1619
## 🤲 Usage
1720

shortcuts.json

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@
1414
"name": "Request key",
1515
"responseHandling": {
1616
"failureOutput": "simple",
17-
"id": "e7e3bc62-4e79-4864-a301-9a3552dcb77a",
1817
"successMessage": "API key was saved.",
1918
"successOutput": "message",
2019
"uiType": "toast"
2120
},
22-
"url": "{{790c08b8-6204-4f7f-8e8e-e6a4806017bc}}/request_new_permissions?name\u003dPhone\u0026basic_permissions\u003d[0]"
21+
"retryPolicy": "wait_for_internet",
22+
"url": "{{790c08b8-6204-4f7f-8e8e-e6a4806017bc}}/request_new_permissions?name\u003dPhone\u0026basic_permissions\u003d[0,1]"
2323
},
2424
{
2525
"bodyContent": "{\n \"url\" : \"{{4d098304-464a-4c2a-9e5e-e43b68c13814}}\",\n \"destination_page_name\" : \"phone url import\"\n}",
26-
"codeOnSuccess": "var toast \u003d \"API key is valid.\\n\"\nif (JSON.parse(response.body).basic_permissions.includes(0)) {\n toast +\u003d \"URL permission granted.\";\n} else {\n toast +\u003d \"URL permission missing!\";\n}\nshowToast(toast);",
26+
"codeOnSuccess": "var toast \u003d \"API key is valid.\\n\"\nvar url \u003d JSON.parse(response.body).basic_permissions.includes(0)\nvar file \u003d JSON.parse(response.body).basic_permissions.includes(1)\n\nif (!url \u0026\u0026 !file) {\n toast +\u003d \"All permissions missing!\";\n} else if (!url) {\n toast +\u003d \"URL permission missing!\";\n} else if (!file) {\n toast +\u003d \"File permission missing!\";\n}\n\nshowToast(toast);",
2727
"contentType": "application/json",
2828
"description": "Verifies API key with Hydrus",
2929
"headers": [
3030
{
31-
"id": "08e815f3-0211-417c-ac30-dad66d3b4656",
31+
"id": "d1eb5ba6-051a-4b44-91cb-dacda569be9d",
3232
"key": "Hydrus-Client-API-Access-Key",
3333
"value": "{{2c7bf1c2-dabd-41fd-b572-8a67575f07c7}}"
3434
}
@@ -38,19 +38,44 @@
3838
"name": "Verify key",
3939
"responseHandling": {
4040
"failureOutput": "simple",
41-
"id": "e6438001-2f6a-4275-958f-53cf3b521b74",
4241
"successOutput": "none",
4342
"uiType": "toast"
4443
},
44+
"retryPolicy": "wait_for_internet",
4545
"url": "{{790c08b8-6204-4f7f-8e8e-e6a4806017bc}}/verify_access_key"
4646
},
47+
{
48+
"codeOnSuccess": "var toast \u003d \"File \"\nvar status \u003d JSON.parse(response.body).status\n\nswitch (status) {\n case 1:\n toast +\u003d \"was successfully imported.\";\n break;\n case 2:\n toast +\u003d \"already in database.\";\n break;\n case 3:\n toast +\u003d \"previously deleted.\";\n break;\n case 4:\n toast +\u003d \"failed to import.\";\n break;\n case 7:\n toast +\u003d \"vetoed.\";\n break;\n}\n\nshowToast(toast);",
49+
"contentType": "application/octet-stream",
50+
"description": "Sends a file to Hydrus",
51+
"headers": [
52+
{
53+
"id": "ea2f7272-29a1-4608-b0db-cfe804ff08f7",
54+
"key": "Hydrus-Client-API-Access-Key",
55+
"value": "{{2c7bf1c2-dabd-41fd-b572-8a67575f07c7}}"
56+
}
57+
],
58+
"iconName": "custom-icon_04e0e038-6af2-4bce-91fd-bece7728a1d3.png",
59+
"id": "22484fb3-bff9-470c-a699-38aaf825331f",
60+
"method": "POST",
61+
"name": "Send file",
62+
"requestBodyType": "file",
63+
"responseHandling": {
64+
"failureOutput": "simple",
65+
"successMessage": "File was sent to Hydrus.",
66+
"successOutput": "none",
67+
"uiType": "toast"
68+
},
69+
"retryPolicy": "wait_for_internet",
70+
"url": "{{790c08b8-6204-4f7f-8e8e-e6a4806017bc}}/add_files/add_file"
71+
},
4772
{
4873
"bodyContent": "{\n \"url\" : \"{{4d098304-464a-4c2a-9e5e-e43b68c13814}}\",\n \"destination_page_name\" : \"phone url import\"\n}",
4974
"contentType": "application/json",
5075
"description": "Sends a URL to Hydrus",
5176
"headers": [
5277
{
53-
"id": "5ddf5c91-4ddb-42a9-baf2-f37ed05abd0a",
78+
"id": "ea7dead9-05ee-4494-9ab3-67d0606428be",
5479
"key": "Hydrus-Client-API-Access-Key",
5580
"value": "{{2c7bf1c2-dabd-41fd-b572-8a67575f07c7}}"
5681
}
@@ -61,11 +86,11 @@
6186
"name": "Send URL",
6287
"responseHandling": {
6388
"failureOutput": "simple",
64-
"id": "5ccff8f8-1f3b-4292-a865-0fb833f29c68",
6589
"successMessage": "{{4d098304-464a-4c2a-9e5e-e43b68c13814}} was sent to Hydrus.",
6690
"successOutput": "message",
6791
"uiType": "toast"
6892
},
93+
"retryPolicy": "wait_for_internet",
6994
"url": "{{790c08b8-6204-4f7f-8e8e-e6a4806017bc}}/add_urls/add_url"
7095
}
7196
]
@@ -88,5 +113,5 @@
88113
"value": "\u003cEnter your client api url here\u003e"
89114
}
90115
],
91-
"version": 45
116+
"version": 56
92117
}

0 commit comments

Comments
 (0)