VARIABLES
Set variable
Input
to
Shortcut Input
COMMENT
First check if user is signed into Instagram within Scriptable app
MISSING
Under Construction
SCRIPTING
Get
Value
for
loggedIn
in
Output

Dictionary Value
SCRIPTING
If
Dictionary Value
is
false
COMMENT
User is not logged in, trying to get the user to login now...
SCRIPTING
Show alert
Informational Message
MISSING
Under Construction
SCRIPTING
Exit shortcut with
Result
SCRIPTING
End If

If Result
DICTIONARY

Dictionary
VARIABLES
Set variable
Dict
to
MainDict
VARIABLES
Set variable
SName
to
Dict
COMMENT
1.58
- Fix for when media doesn't have a caption and error appears
1.57
- Fix for Caption grabbing
1.56
- Fix for constant rollback message
1.55
- Revamp for instagram code changes and now urilizing scriptable to maintain cookies and login presence.
- Private items can now download without safari usage (except for private story)
- Removed periodic update check to reduce unnecessary actions now that update checks are almost instantaneous
- Remove input type checks as no longer needed
LIST

List
VARIABLES
Set variable
Yes No
to
List
NUMBER
1

Number
VARIABLES
Set variable
1
to
Number
DOCUMENTS
Create Folder
Path
[{'value': '/Shortcuts/', 'class': 'text'}, {'class': 'magic', 'value': 'SName', 'glyph': 'assets/cat/Variable.svg', 'UUID': ''}]
DOCUMENTS
Get File
File Path
/Shortcuts/example.txt

File
SCRIPTING
If
File
does not have any value
LIST

List
TEXT
Where do you want your media stored?
This setting is saved for future runs.
To reset, delete the file "settings.json" at:
iCloud Drive/Shortcuts/
SName
This can also be done from the main menu

Text
SCRIPTING
Choose from
List
Prompt
[{'class': 'magic', 'value': 'Text', 'glyph': '', 'UUID': 'EDC965CE-11FE-4C1F-9666-26ADC5721089'}]

Chosen Item
DICTIONARY

Dictionary
DOCUMENTS
Save
Dictionary
Destination Path
[{'value': '/Shortcuts/', 'class': 'text'}, {'class': 'magic', 'value': 'SName', 'glyph': 'assets/cat/Variable.svg', 'UUID': ''}, {'value': '/settings.json', 'class': 'text'}]Overwrite If File Exists

Saved File
SCRIPTING
End If

If Result
VARIABLES
Set variable
Settings
to
If Result
VARIABLES
Set variable
InitialSettings
to
Settings
TEXT
Settings

Text
VARIABLES
Set variable
StorageLoc
to
Text
COMMENT
Update Check 🔽🔽🔽
NETWORK
Get contents of
https://raw.githubusercontent.com/mvan231/Shortcuts/main/InstagramMediaSaver.json
Options Under Construction

Contents of URL
SCRIPTING
If
Server
contains
success
TEXT
<html><head></head><body><script>
// Swing Engine 1.2.2
// © D3W10 - 𝗗𝗼𝗻'𝘁 𝗰𝗼𝗽𝘆 𝘁𝗵𝗶𝘀 𝗰𝗼𝗱𝗲 𝘄𝗶𝘁𝗵𝗼𝘂𝘁 𝗽𝗲𝗿𝗺𝗶𝘀𝘀𝗶𝗼𝗻.
function sue (a, b) {
let pa = a.split('.');
let pb = b.split('.');
for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
let na = Number(pa[i]);
let nb = Number(pb[i]);
if (isNaN(na)) na = 0;
if (isNaN(nb)) nb = 0;
if (na > nb) return "Rollback";
if (nb > na) return "Update";
}
if (a != b) return "Update";
return "Updated";
};
let data = {"current":"
Dict
","new":"
Server
"};
document.write(sue(data.current, data.new));
</script></body></html>

Text
URL
data:text/html,
Engine Code

URL
SAFARI
Get contents of web page at
URL

Contents of Web Page
SCRIPTING
If
EngineResult
does not contain
Updated
SCRIPTING
If
EngineResult
is
Update

Text
SCRIPTING
Otherwise

Text
SCRIPTING
End If

If Result
DOCUMENTS
Show
If Result
in Quick Look
LIST

List
SCRIPTING

Chosen Item
SCRIPTING
If
Chosen Item
is
If Result
DOCUMENTS
Replace
.*com
with
shortcuts:/
in
Server

Updated Text
SAFARI
Open
Updated Text
MISSING
output Under Construction
SCRIPTING
End If

If Result
SCRIPTING
End If

If Result
SCRIPTING
End If

If Result
COMMENT
Update check 🔼🔼🔼
SCRIPTING
If
Input
does not have any value
DICTIONARY

Dictionary
VARIABLES
Set variable
switches
to
Dictionary
SCRIPTING
If
Settings
contains
showSaveNotifications
VARIABLES
Set variable
on-or-off
to
Settings
SCRIPTING
If
on-or-off
is
Yes
TEXT
BEGIN:VCARD
VERSION:3.0
N;CHARSET=utf-8:Save Notifications On;
ORG:;
PHOTO;ENCODING=b:
switches
END:VCARD

Text
SCRIPTING
Otherwise
TEXT
BEGIN:VCARD
VERSION:3.0
N;CHARSET=utf-8:Save Notifications Off;
ORG:;
PHOTO;ENCODING=b:
switches
END:VCARD

Text
SCRIPTING
End If

If Result
SCRIPTING
Otherwise
NOTHING
Nothing
SCRIPTING
End If

If Result
TEXT
BEGIN:VCARD
VERSION:3.0
N;CHARSET=utf-8:Run Shortcut (multi-post or from clipboard);
ORG:;
END:VCARD
BEGIN:VCARD
VERSION:3.0
N;CHARSET=utf-8:Reset Settings;
ORG:;
END:VCARD
BEGIN:VCARD
VERSION:3.0
N;CHARSET=utf-8:Delete URLs File (if it exists);
ORG:;
END:VCARD
BEGIN:VCARD
VERSION:3.0
N;CHARSET=utf-8:Delete Downloaded Media (iCloud Drive);
ORG:;
END:VCARD
If Result

Text
SCRIPTING
Set name of
Text
to
menu.vcf

Renamed Item
TEXT
Welcome to
SName
!
You didn't share a post to the shortcut, so this menu allows some other features.

Text
SCRIPTING
Choose from
Renamed Item
Prompt
[{'class': 'magic', 'value': 'Text', 'glyph': '', 'UUID': '29429BC2-ADB0-4116-99C0-58E9C60E1AE4'}]

Chosen Item
SCRIPTING
If
Chosen Item
contains
Notifications
SCRIPTING
If
Chosen Item
contains
On
SCRIPTING
Set
showSaveNotifications
to
No
in
Dictionary

Dictionary
SCRIPTING
Otherwise
SCRIPTING
Set
showSaveNotifications
to
Yes
in
Dictionary

Dictionary
SCRIPTING
End If

If Result
DOCUMENTS
Save
If Result
Destination Path
[{'value': '/Shortcuts/', 'class': 'text'}, {'class': 'magic', 'value': 'SName', 'glyph': 'assets/cat/Variable.svg', 'UUID': ''}, {'value': '/settings.json', 'class': 'text'}]Overwrite If File Exists

Saved File
SHORTCUTS
Run
SName

Shortcut Result
SCRIPTING
Exit shortcut with
Result
SCRIPTING
End If

If Result
NOTHING
Nothing
SCRIPTING
If
Chosen Item
contains
Delete URLs
DOCUMENTS
Get File
File Path
/Shortcuts/example.txt

File
SCRIPTING
Otherwise
SCRIPTING
If
Chosen Item
contains
Delete Downloaded Media
MISSING
file.getfoldercontents Under Construction
FILES
Filter
Contents of Folder
where
[{'class': 'filter-property', 'value': 'Name'}, {'class': 'filter-operator', 'value': 'is not'}, {'class': 'filter-benchmark', 'value': 'settings'}]

Files
SCRIPTING
Otherwise
SCRIPTING
If
Chosen Item
contains
Reset Settings
DOCUMENTS
Get File
File Path
/Shortcuts/example.txt

File
SCRIPTING
End If

If Result
SCRIPTING
End If

If Result
SCRIPTING
End If

If Result
SCRIPTING
If
If Result
has any value
DOCUMENTS
SCRIPTING
Exit shortcut with
Result
SCRIPTING
End If

If Result
DOCUMENTS
Get File
File Path
/Shortcuts/example.txt

File
SCRIPTING
If
File
has any value