The iPhone downloader that actually downloads from “everywhere”.
It even tells you what it installs.
Found a video or photo gallery you want to keep? Tap Share → GetTheUltimate and choose what to save. You can also copy a link and open the shortcut directly.
🎬 VIDEO
Save an MP4 from YouTube (including Shorts), Instagram (including Reels), TikTok, Threads, X (Twitter), Facebook, Reddit, Pinterest, LinkedIn, Bluesky, or Snapchat Spotlight.
You can also use links from Dailymotion, Vimeo, Twitch, Bilibili, Douyin, Rumble, Kick, Odysee, Streamable, ARTE, Internet Archive, P*rnhub and more.
🖼️ PHOTOS AND GALLERIES
Save the available images from Instagram posts and carousels, Pinterest pins, Threads, X, Reddit and Bluesky posts, Flickr photos and albums, Imgur images and galleries, and Tumblr posts.
You can save up to 50 images in one run. If a page only offers a preview image, GetTheUltimate asks before saving it.
🎧 AUDIO
Save an M4A from YouTube Music, SoundCloud, Audiomack, Bandcamp, or Mixcloud. You can also extract the audio from a supported video link.
📁 WHERE IT GOES
Save videos and images to your photo library, choose an existing album, or create a new one. In Files, you can pick or create a folder for videos, images, and audio.
⚙️ FIRST RUN
1. Install a-Shell mini and open it once.
App Store · https://apps.apple.com/app/a-shell-mini/id1543537943
2. Open GetTheUltimate and choose Install or Update Tools. The shortcut installs yt-dlp and gallery-dl for you.
3. When you see Tools are ready, share a link and choose where to save it.
Downloads run on your device. What you can save depends on what each site makes available for that public link.
CREDITS
LibreGet by OpenSelena inspired the separate video and image downloads and the lookup for public Threads posts.
https://github.com/OpenSelena/libreget
Media downloads use yt-dlp and gallery-dl.
🔒 PRIVACY AND USE
When opened directly, GetTheUltimate checks your clipboard for a supported link. When you choose to download, it requests the media from the source site and its media hosts.
Tool installation and updates fetch packages from PyPI. Download only media you own or have permission to save.
What's New
First release
What it does
162 actions-
CommentGETTHEULTIMATE · 0.9.2 ━━━━━━━━━━━━━━━━━━ Share a link from an app or browser. You can also copy the link and run GetTheUltimate from Shortcuts. ▶ VIDEO Save an iPhone compatible MP4 in Photos or Files. Try public links from YouTube and Shorts, Inst…
-
Random Number
-
Random Number
-
Random Number
-
Choose from MenuGetTheUltimate 0.9.2
-
Choose from MenuVideo → Photos
-
Match Text
-
If
-
Show AlertGetTheUltimate 0.9.2
-
Stop This Shortcut
-
Get Item from List
-
Base64 Encode
-
Execute CommandAsheKube.app.a-Shell-mini
-
Wait to Return
-
Get FileAsheKube.app.a-Shell-mini
-
If
-
Show AlertGetTheUltimate 0.9.2
-
Stop This Shortcut
-
Get Text from Input
-
Get FileAsheKube.app.a-Shell-mini
-
If
-
Show AlertGetTheUltimate 0.9.2
-
Stop This Shortcut
-
Get Text from Input
-
Get FileAsheKube.app.a-Shell-mini
-
If
-
Show AlertGetTheUltimate 0.9.2
-
Stop This Shortcut
-
Choose from MenuSave to Photos
-
Choose from MenuPhoto Library
-
Save to Photo Album
-
Choose from MenuExisting Album
-
Save to Photo Album
-
Choose from MenuNew Album
-
Ask for InputName your new album
-
Create Album
-
Choose from MenuVideo → Files
-
Match Text
-
If
-
Show AlertGetTheUltimate 0.9.2
-
Stop This Shortcut
-
Get Item from List
-
Base64 Encode
-
Execute CommandAsheKube.app.a-Shell-mini
-
Wait to Return
-
Get FileAsheKube.app.a-Shell-mini
-
If
-
Show AlertGetTheUltimate 0.9.2
-
Stop This Shortcut
-
Get Text from Input
-
Get FileAsheKube.app.a-Shell-mini
-
If
-
Show AlertGetTheUltimate 0.9.2
-
Stop This Shortcut
-
Get Text from Input
-
Get FileAsheKube.app.a-Shell-mini
-
If
-
Show AlertGetTheUltimate 0.9.2
-
Stop This Shortcut
-
Save File
-
Choose from MenuImages → Photos
-
Match Text
-
If
-
Show AlertGetTheUltimate 0.9.2
-
Stop This Shortcut
-
Get Item from List
-
Base64 Encode
-
Execute CommandAsheKube.app.a-Shell-mini
-
Wait to Return
-
Get FileAsheKube.app.a-Shell-mini
-
If
-
Show AlertGetTheUltimate 0.9.2
-
Stop This Shortcut
-
Get Text from Input
-
Get FileAsheKube.app.a-Shell-mini
-
If
-
Show AlertGetTheUltimate 0.9.2
-
Stop This Shortcut
-
Get Text from Input
-
Get FileAsheKube.app.a-Shell-mini
-
If
-
Show AlertGetTheUltimate 0.9.2
-
Stop This Shortcut
-
Get FileAsheKube.app.a-Shell-mini
-
If
-
If
-
Get Text from Input
-
Show AlertGetTheUltimate 0.9.2
-
Extract Archive
-
Choose from MenuSave to Photos
-
Choose from MenuPhoto Library
-
Save to Photo Album
-
Choose from MenuExisting Album
-
Save to Photo Album
-
Choose from MenuNew Album
-
Ask for InputName your new album
-
Create Album
-
Choose from MenuImages → Files
-
Match Text
-
If
-
Show AlertGetTheUltimate 0.9.2
-
Stop This Shortcut
-
Get Item from List
-
Base64 Encode
-
Execute CommandAsheKube.app.a-Shell-mini
-
Wait to Return
-
Get FileAsheKube.app.a-Shell-mini
-
If
-
Show AlertGetTheUltimate 0.9.2
-
Stop This Shortcut
-
Get Text from Input
-
Get FileAsheKube.app.a-Shell-mini
-
If
-
Show AlertGetTheUltimate 0.9.2
-
Stop This Shortcut
-
Get Text from Input
-
Get FileAsheKube.app.a-Shell-mini
-
If
-
Show AlertGetTheUltimate 0.9.2
-
Stop This Shortcut
-
Get FileAsheKube.app.a-Shell-mini
-
If
-
If
-
Get Text from Input
-
Show AlertGetTheUltimate 0.9.2
-
Extract Archive
-
Save File
-
Choose from MenuAudio → Files
-
Match Text
-
If
-
Show AlertGetTheUltimate 0.9.2
-
Stop This Shortcut
-
Get Item from List
-
Base64 Encode
-
Execute CommandAsheKube.app.a-Shell-mini
-
Wait to Return
-
Get FileAsheKube.app.a-Shell-mini
-
If
-
Show AlertGetTheUltimate 0.9.2
-
Stop This Shortcut
-
Get Text from Input
-
Get FileAsheKube.app.a-Shell-mini
-
If
-
Show AlertGetTheUltimate 0.9.2
-
Stop This Shortcut
-
Get Text from Input
-
Get FileAsheKube.app.a-Shell-mini
-
If
-
Show AlertGetTheUltimate 0.9.2
-
Stop This Shortcut
-
Save File
-
Choose from MenuInstall or Update Tools
-
Text
-
Put FileAsheKube.app.a-Shell-mini
-
Execute CommandAsheKube.app.a-Shell-mini
-
Wait to Return
-
Get FileAsheKube.app.a-Shell-mini
-
If
-
Show AlertGetTheUltimate 0.9.2
-
Stop This Shortcut
-
Get Text from Input
-
Show AlertGetTheUltimate 0.9.2
View as code
Every action of this Shortcut written out as Cherri, a programming language for Shortcuts. Great for learning how it works.
#include 'actions/crypto'
#define color blue
#define glyph magicWandAlt
/*
GETTHEULTIMATE · 0.9.2
━━━━━━━━━━━━━━━━━━
Share a link from an app or browser. You can also copy the link and run GetTheUltimate from Shortcuts.
▶ VIDEO
Save an iPhone compatible MP4 in Photos or Files. Try public links from YouTube and Shorts, Instagram, TikTok, Threads, X, Facebook, Reddit, Pinterest, LinkedIn, Bluesky, Dailymotion, Vimeo, Twitch, Snapchat Spotlight, XVideos, Pornhub, Bilibili, Douyin, Rumble, Kick, Odysee, Streamable, ARTE and Internet Archive.
▧ IMAGES
Save the photos in a public post, including posts with multiple images where the site makes them available. Try Instagram, Pinterest, Threads, X, Reddit, Bluesky, Flickr, Imgur and Tumblr. If only a link preview is available, you’ll be asked before saving it.
♪ AUDIO
Save an M4A track in Files. Try YouTube Music, SoundCloud, Audiomack, Bandcamp and Mixcloud, or extract audio from a video.
📁 WHERE IT GOES
In Photos, save to your library, choose an album or make a new one. In Files, pick a folder or create one in the save window. Large downloads are saved under On My iPhone → a-Shell mini → GetTheUltimate.
⚙ FIRST RUN
Install a-Shell mini from the App Store and open it once. Then run GetTheUltimate and select Install or Update Tools. The shortcut sets up yt-dlp and gallery-dl for you. Allow the iOS permission prompts for the places you want to save to.
Public links work best. Some sites restrict certain posts, formats or regions. Use Install or Update Tools when a site stops working.
*/
randomNumber(100, 999)
randomNumber(100, 999)
randomNumber(100, 999)
menu "GetTheUltimate 0.9.2" {
item "Video → Photos":
const Matches = containsText(ShortcutInput, "(?i)\bhttps?://(?:(?:[a-z0-9-]+\.)*instagram\.com/(?:(?:[a-z0-9_.]+/)?(?:p|reels?|tv)/[a-z0-9_-]+|share/(?:reel/|p/)?[a-z0-9_-]+)/?(?:\?[^\s<>\\"'`\\\x00-\x1f\x7f]{0,1024})?|(?:[a-z0-9-]+\.)*(?:pinterest\.co\.uk|dailymotion\.com|soundcloud\.com|streamable\.com|pinterest\.com|audiomack\.com|facebook\.com|pinterest\.de|linkedin\.com|snapchat\.com|bilibili\.com|bandcamp\.com|mixcloud\.com|youtube\.com|threads\.com|threads\.net|twitter\.com|xvideos\.com|pornhub\.com|archive\.org|tiktok\.com|reddit\.com|douyin\.com|rumble\.com|odysee\.com|flickr\.com|tumblr\.com|vimeo\.com|twitch\.tv|imgur\.com|youtu\.be|fb\.watch|bsky\.app|kick\.com|redd\.it|arte\.tv|flic\.kr|fb\.com|pin\.it|dai\.ly|b23\.tv|x\.com)/[^\s<>\\"'`\\\x00-\x1f\x7f]{1,4066})(?=$|[\s<>\\"'`\\\x00-\x1f\x7f])")
if !Matches {
alert("No supported link was found. Use Copy Link in the app and run GetTheUltimate again.", "GetTheUltimate 0.9.2")
stop()
}
const ItemFromList = getRandomItem(Matches)
base64Encode(ItemFromList)
rawAction("AsheKube.app.a-Shell-mini.ExecuteCommandIntent", {
"ShowWhenRun": false,
"command": "dash -c 'cd \\\"${SHORTCUTS:-.}\\\" || exit; j=\\\"{}-{}-{}\\\"; d=\\\"GetTheUltimate/$j\\\"; r=\\\"$HOME/Library/GetTheUltimate/engine-0.9.2.py\\\"; if [ -f \\\"$r\\\" ]; then python3 \\\"$r\\\" photos \\\"$j\\\" \\\"{}\\\"; else mkdir -p \\\"$d\\\" \u0026\u0026 printf \\\"%s\\n\\\" \\\"Open GetTheUltimate and choose Install or Update Tools first.\\\" \u003e \\\"$d/message.txt\\\"; fi; open shortcuts://'",
"keepGoing": false,
"openWindow": "open"
})
waitToReturn()
rawAction("AsheKube.app.a-Shell-mini.GetFileIntent", {
"ShowWhenRun": false,
"copyFile": true,
"errorIfNotFound": false,
"fileName": "GetTheUltimate/{}-{}-{}/message.txt"
})
if !File {
alert("a-Shell mini did not return a result. Open a-Shell mini to see where it stopped.", "GetTheUltimate 0.9.2")
stop()
}
getText(File)
rawAction("AsheKube.app.a-Shell-mini.GetFileIntent", {
"ShowWhenRun": false,
"copyFile": true,
"errorIfNotFound": false,
"fileName": "GetTheUltimate/{}-{}-{}/filename.txt"
})
if !File1 {
alert(, "GetTheUltimate 0.9.2")
stop()
}
getText(File1)
rawAction("AsheKube.app.a-Shell-mini.GetFileIntent", {
"ShowWhenRun": false,
"copyFile": true,
"errorIfNotFound": false,
"fileName": "GetTheUltimate/{}-{}-{}/{}"
})
if !File2 {
alert("The download finished, but Shortcuts could not open the file. Try sharing the link again.", "GetTheUltimate 0.9.2")
stop()
}
menu "Save to Photos" {
item "Photo Library":
savePhoto(File2)
item "Existing Album":
savePhoto(File2, Ask: "Choose an album")
item "New Album":
prompt("Name your new album", "Text")
createAlbum(, File2)
}
item "Video → Files":
const Matches1 = containsText(ShortcutInput, "(?i)\bhttps?://(?:(?:[a-z0-9-]+\.)*instagram\.com/(?:(?:[a-z0-9_.]+/)?(?:p|reels?|tv)/[a-z0-9_-]+|share/(?:reel/|p/)?[a-z0-9_-]+)/?(?:\?[^\s<>\\"'`\\\x00-\x1f\x7f]{0,1024})?|(?:[a-z0-9-]+\.)*(?:pinterest\.co\.uk|dailymotion\.com|soundcloud\.com|streamable\.com|pinterest\.com|audiomack\.com|facebook\.com|pinterest\.de|linkedin\.com|snapchat\.com|bilibili\.com|bandcamp\.com|mixcloud\.com|youtube\.com|threads\.com|threads\.net|twitter\.com|xvideos\.com|pornhub\.com|archive\.org|tiktok\.com|reddit\.com|douyin\.com|rumble\.com|odysee\.com|flickr\.com|tumblr\.com|vimeo\.com|twitch\.tv|imgur\.com|youtu\.be|fb\.watch|bsky\.app|kick\.com|redd\.it|arte\.tv|flic\.kr|fb\.com|pin\.it|dai\.ly|b23\.tv|x\.com)/[^\s<>\\"'`\\\x00-\x1f\x7f]{1,4066})(?=$|[\s<>\\"'`\\\x00-\x1f\x7f])")
if !Matches1 {
alert("No supported link was found. Use Copy Link in the app and run GetTheUltimate again.", "GetTheUltimate 0.9.2")
stop()
}
const ItemFromList1 = getListItem(Matches1, 0)
base64Encode(ItemFromList1)
rawAction("AsheKube.app.a-Shell-mini.ExecuteCommandIntent", {
"ShowWhenRun": false,
"command": "dash -c 'cd \\\"${SHORTCUTS:-.}\\\" || exit; j=\\\"{}-{}-{}\\\"; d=\\\"GetTheUltimate/$j\\\"; r=\\\"$HOME/Library/GetTheUltimate/engine-0.9.2.py\\\"; if [ -f \\\"$r\\\" ]; then python3 \\\"$r\\\" video \\\"$j\\\" \\\"{}\\\"; else mkdir -p \\\"$d\\\" \u0026\u0026 printf \\\"%s\\n\\\" \\\"Open GetTheUltimate and choose Install or Update Tools first.\\\" \u003e \\\"$d/message.txt\\\"; fi; open shortcuts://'",
"keepGoing": false,
"openWindow": "open"
})
waitToReturn()
rawAction("AsheKube.app.a-Shell-mini.GetFileIntent", {
"ShowWhenRun": false,
"copyFile": true,
"errorIfNotFound": false,
"fileName": "GetTheUltimate/{}-{}-{}/message.txt"
})
if !File3 {
alert("a-Shell mini did not return a result. Open a-Shell mini to see where it stopped.", "GetTheUltimate 0.9.2")
stop()
}
getText(File3)
rawAction("AsheKube.app.a-Shell-mini.GetFileIntent", {
"ShowWhenRun": false,
"copyFile": true,
"errorIfNotFound": false,
"fileName": "GetTheUltimate/{}-{}-{}/filename.txt"
})
if !File4 {
alert(, "GetTheUltimate 0.9.2")
stop()
}
getText(File4)
rawAction("AsheKube.app.a-Shell-mini.GetFileIntent", {
"ShowWhenRun": false,
"copyFile": true,
"errorIfNotFound": false,
"fileName": "GetTheUltimate/{}-{}-{}/{}"
})
if !File5 {
alert("The download finished, but Shortcuts could not open the file. Try sharing the link again.", "GetTheUltimate 0.9.2")
stop()
}
saveFile("", File5, false)
item "Images → Photos":
const Matches2 = containsText(ShortcutInput, "(?i)\bhttps?://(?:(?:[a-z0-9-]+\.)*instagram\.com/(?:(?:[a-z0-9_.]+/)?(?:p|reels?|tv)/[a-z0-9_-]+|share/(?:reel/|p/)?[a-z0-9_-]+)/?(?:\?[^\s<>\\"'`\\\x00-\x1f\x7f]{0,1024})?|(?:[a-z0-9-]+\.)*(?:pinterest\.co\.uk|dailymotion\.com|soundcloud\.com|streamable\.com|pinterest\.com|audiomack\.com|facebook\.com|pinterest\.de|linkedin\.com|snapchat\.com|bilibili\.com|bandcamp\.com|mixcloud\.com|youtube\.com|threads\.com|threads\.net|twitter\.com|xvideos\.com|pornhub\.com|archive\.org|tiktok\.com|reddit\.com|douyin\.com|rumble\.com|odysee\.com|flickr\.com|tumblr\.com|vimeo\.com|twitch\.tv|imgur\.com|youtu\.be|fb\.watch|bsky\.app|kick\.com|redd\.it|arte\.tv|flic\.kr|fb\.com|pin\.it|dai\.ly|b23\.tv|x\.com)/[^\s<>\\"'`\\\x00-\x1f\x7f]{1,4066})(?=$|[\s<>\\"'`\\\x00-\x1f\x7f])")
if !Matches2 {
alert("No supported link was found. Use Copy Link in the app and run GetTheUltimate again.", "GetTheUltimate 0.9.2")
stop()
}
const ItemFromList2 = getListItem(Matches2, 0)
base64Encode(ItemFromList2)
rawAction("AsheKube.app.a-Shell-mini.ExecuteCommandIntent", {
"ShowWhenRun": false,
"command": "dash -c 'cd \\\"${SHORTCUTS:-.}\\\" || exit; j=\\\"{}-{}-{}\\\"; d=\\\"GetTheUltimate/$j\\\"; r=\\\"$HOME/Library/GetTheUltimate/engine-0.9.2.py\\\"; if [ -f \\\"$r\\\" ]; then python3 \\\"$r\\\" image_photos \\\"$j\\\" \\\"{}\\\"; else mkdir -p \\\"$d\\\" \u0026\u0026 printf \\\"%s\\n\\\" \\\"Open GetTheUltimate and choose Install or Update Tools first.\\\" \u003e \\\"$d/message.txt\\\"; fi; open shortcuts://'",
"keepGoing": false,
"openWindow": "open"
})
waitToReturn()
rawAction("AsheKube.app.a-Shell-mini.GetFileIntent", {
"ShowWhenRun": false,
"copyFile": true,
"errorIfNotFound": false,
"fileName": "GetTheUltimate/{}-{}-{}/message.txt"
})
if !File6 {
alert("a-Shell mini did not return a result. Open a-Shell mini to see where it stopped.", "GetTheUltimate 0.9.2")
stop()
}
getText(File6)
rawAction("AsheKube.app.a-Shell-mini.GetFileIntent", {
"ShowWhenRun": false,
"copyFile": true,
"errorIfNotFound": false,
"fileName": "GetTheUltimate/{}-{}-{}/filename.txt"
})
if !File7 {
alert(, "GetTheUltimate 0.9.2")
stop()
}
getText(File7)
rawAction("AsheKube.app.a-Shell-mini.GetFileIntent", {
"ShowWhenRun": false,
"copyFile": true,
"errorIfNotFound": false,
"fileName": "GetTheUltimate/{}-{}-{}/{}"
})
if !File8 {
alert("The download finished, but Shortcuts could not open the file. Try sharing the link again.", "GetTheUltimate 0.9.2")
stop()
}
rawAction("AsheKube.app.a-Shell-mini.GetFileIntent", {
"ShowWhenRun": false,
"copyFile": true,
"errorIfNotFound": false,
"fileName": "GetTheUltimate/{}-{}-{}/notice.txt"
})
if !File9 {
} else {
getText(File9)
alert(, "GetTheUltimate 0.9.2")
}
const Files = extractArchive(File8)
menu "Save to Photos" {
item "Photo Library":
savePhoto(Files)
item "Existing Album":
savePhoto(Files, Ask: "Choose an album")
item "New Album":
prompt("Name your new album", "Text")
createAlbum(, Files)
}
item "Images → Files":
const Matches3 = containsText(ShortcutInput, "(?i)\bhttps?://(?:(?:[a-z0-9-]+\.)*instagram\.com/(?:(?:[a-z0-9_.]+/)?(?:p|reels?|tv)/[a-z0-9_-]+|share/(?:reel/|p/)?[a-z0-9_-]+)/?(?:\?[^\s<>\\"'`\\\x00-\x1f\x7f]{0,1024})?|(?:[a-z0-9-]+\.)*(?:pinterest\.co\.uk|dailymotion\.com|soundcloud\.com|streamable\.com|pinterest\.com|audiomack\.com|facebook\.com|pinterest\.de|linkedin\.com|snapchat\.com|bilibili\.com|bandcamp\.com|mixcloud\.com|youtube\.com|threads\.com|threads\.net|twitter\.com|xvideos\.com|pornhub\.com|archive\.org|tiktok\.com|reddit\.com|douyin\.com|rumble\.com|odysee\.com|flickr\.com|tumblr\.com|vimeo\.com|twitch\.tv|imgur\.com|youtu\.be|fb\.watch|bsky\.app|kick\.com|redd\.it|arte\.tv|flic\.kr|fb\.com|pin\.it|dai\.ly|b23\.tv|x\.com)/[^\s<>\\"'`\\\x00-\x1f\x7f]{1,4066})(?=$|[\s<>\\"'`\\\x00-\x1f\x7f])")
if !Matches3 {
alert("No supported link was found. Use Copy Link in the app and run GetTheUltimate again.", "GetTheUltimate 0.9.2")
stop()
}
const ItemFromList3 = getListItems(Matches3, 0, 0)
base64Encode(ItemFromList3)
rawAction("AsheKube.app.a-Shell-mini.ExecuteCommandIntent", {
"ShowWhenRun": false,
"command": "dash -c 'cd \\\"${SHORTCUTS:-.}\\\" || exit; j=\\\"{}-{}-{}\\\"; d=\\\"GetTheUltimate/$j\\\"; r=\\\"$HOME/Library/GetTheUltimate/engine-0.9.2.py\\\"; if [ -f \\\"$r\\\" ]; then python3 \\\"$r\\\" image_files \\\"$j\\\" \\\"{}\\\"; else mkdir -p \\\"$d\\\" \u0026\u0026 printf \\\"%s\\n\\\" \\\"Open GetTheUltimate and choose Install or Update Tools first.\\\" \u003e \\\"$d/message.txt\\\"; fi; open shortcuts://'",
"keepGoing": false,
"openWindow": "open"
})
waitToReturn()
rawAction("AsheKube.app.a-Shell-mini.GetFileIntent", {
"ShowWhenRun": false,
"copyFile": true,
"errorIfNotFound": false,
"fileName": "GetTheUltimate/{}-{}-{}/message.txt"
})
if !File10 {
alert("a-Shell mini did not return a result. Open a-Shell mini to see where it stopped.", "GetTheUltimate 0.9.2")
stop()
}
getText(File10)
rawAction("AsheKube.app.a-Shell-mini.GetFileIntent", {
"ShowWhenRun": false,
"copyFile": true,
"errorIfNotFound": false,
"fileName": "GetTheUltimate/{}-{}-{}/filename.txt"
})
if !File11 {
alert(, "GetTheUltimate 0.9.2")
stop()
}
getText(File11)
rawAction("AsheKube.app.a-Shell-mini.GetFileIntent", {
"ShowWhenRun": false,
"copyFile": true,
"errorIfNotFound": false,
"fileName": "GetTheUltimate/{}-{}-{}/{}"
})
if !File12 {
alert("The download finished, but Shortcuts could not open the file. Try sharing the link again.", "GetTheUltimate 0.9.2")
stop()
}
rawAction("AsheKube.app.a-Shell-mini.GetFileIntent", {
"ShowWhenRun": false,
"copyFile": true,
"errorIfNotFound": false,
"fileName": "GetTheUltimate/{}-{}-{}/notice.txt"
})
if !File13 {
} else {
getText(File13)
alert(, "GetTheUltimate 0.9.2")
}
const Files1 = extractArchive(File12)
saveFile("", Files1, false)
item "Audio → Files":
const Matches4 = containsText(ShortcutInput, "(?i)\bhttps?://(?:(?:[a-z0-9-]+\.)*instagram\.com/(?:(?:[a-z0-9_.]+/)?(?:p|reels?|tv)/[a-z0-9_-]+|share/(?:reel/|p/)?[a-z0-9_-]+)/?(?:\?[^\s<>\\"'`\\\x00-\x1f\x7f]{0,1024})?|(?:[a-z0-9-]+\.)*(?:pinterest\.co\.uk|dailymotion\.com|soundcloud\.com|streamable\.com|pinterest\.com|audiomack\.com|facebook\.com|pinterest\.de|linkedin\.com|snapchat\.com|bilibili\.com|bandcamp\.com|mixcloud\.com|youtube\.com|threads\.com|threads\.net|twitter\.com|xvideos\.com|pornhub\.com|archive\.org|tiktok\.com|reddit\.com|douyin\.com|rumble\.com|odysee\.com|flickr\.com|tumblr\.com|vimeo\.com|twitch\.tv|imgur\.com|youtu\.be|fb\.watch|bsky\.app|kick\.com|redd\.it|arte\.tv|flic\.kr|fb\.com|pin\.it|dai\.ly|b23\.tv|x\.com)/[^\s<>\\"'`\\\x00-\x1f\x7f]{1,4066})(?=$|[\s<>\\"'`\\\x00-\x1f\x7f])")
if !Matches4 {
alert("No supported link was found. Use Copy Link in the app and run GetTheUltimate again.", "GetTheUltimate 0.9.2")
stop()
}
const ItemFromList4 = getFirstItem(Matches4)
base64Encode(ItemFromList4)
rawAction("AsheKube.app.a-Shell-mini.ExecuteCommandIntent", {
"ShowWhenRun": false,
"command": "dash -c 'cd \\\"${SHORTCUTS:-.}\\\" || exit; j=\\\"{}-{}-{}\\\"; d=\\\"GetTheUltimate/$j\\\"; r=\\\"$HOME/Library/GetTheUltimate/engine-0.9.2.py\\\"; if [ -f \\\"$r\\\" ]; then python3 \\\"$r\\\" audio \\\"$j\\\" \\\"{}\\\"; else mkdir -p \\\"$d\\\" \u0026\u0026 printf \\\"%s\\n\\\" \\\"Open GetTheUltimate and choose Install or Update Tools first.\\\" \u003e \\\"$d/message.txt\\\"; fi; open shortcuts://'",
"keepGoing": false,
"openWindow": "open"
})
waitToReturn()
rawAction("AsheKube.app.a-Shell-mini.GetFileIntent", {
"ShowWhenRun": false,
"copyFile": true,
"errorIfNotFound": false,
"fileName": "GetTheUltimate/{}-{}-{}/message.txt"
})
if !File14 {
alert("a-Shell mini did not return a result. Open a-Shell mini to see where it stopped.", "GetTheUltimate 0.9.2")
stop()
}
getText(File14)
rawAction("AsheKube.app.a-Shell-mini.GetFileIntent", {
"ShowWhenRun": false,
"copyFile": true,
"errorIfNotFound": false,
"fileName": "GetTheUltimate/{}-{}-{}/filename.txt"
})
if !File15 {
alert(, "GetTheUltimate 0.9.2")
stop()
}
getText(File15)
rawAction("AsheKube.app.a-Shell-mini.GetFileIntent", {
"ShowWhenRun": false,
"copyFile": true,
"errorIfNotFound": false,
"fileName": "GetTheUltimate/{}-{}-{}/{}"
})
if !File16 {
alert("The download finished, but Shortcuts could not open the file. Try sharing the link again.", "GetTheUltimate 0.9.2")
stop()
}
saveFile("", File16, false)
item "Install or Update Tools":
const Text = "0x475455092\n\\"\\"\\"The local engine embedded in the GetTheUltimate iPhone shortcut.\\"\\"\\"\n\nimport base64\nimport binascii\nfrom contextlib import contextmanager\nimport fcntl\nimport html\nfrom html.parser import HTMLParser\nfrom importlib.metadata import distributions\nimport ipaddress\nimport json\nimport logging\nimport os\nfrom pathlib import Path\nimport re\nimport shutil\nimport subprocess\nimport sys\nimport tempfile\nimport time\nimport unicodedata\nfrom urllib.parse import parse_qsl, urlencode, urljoin, urlsplit, urlunsplit\nimport uuid\nfrom zipfile import ZipFile\n\n\nPLATFORMS = (\n (\\"YouTube / YouTube Music\\", (\\"youtube.com\\", \\"youtu.be\\")),\n (\\"TikTok\\", (\\"tiktok.com\\",)),\n (\\"Instagram\\", (\\"instagram.com\\",)),\n (\\"Threads\\", (\\"threads.com\\", \\"threads.net\\")),\n (\\"X\\", (\\"x.com\\", \\"twitter.com\\")),\n (\\"Facebook\\", (\\"facebook.com\\", \\"fb.watch\\", \\"fb.com\\")),\n (\\"Reddit\\", (\\"reddit.com\\", \\"redd.it\\")),\n (\\"Pinterest\\", (\\"pinterest.com\\", \\"pinterest.de\\", \\"pinterest.co.uk\\", \\"pin.it\\")),\n (\\"LinkedIn\\", (\\"linkedin.com\\",)),\n (\\"Bluesky\\", (\\"bsky.app\\",)),\n (\\"Dailymotion\\", (\\"dailymotion.com\\", \\"dai.ly\\")),\n (\\"Vimeo\\", (\\"vimeo.com\\",)),\n (\\"Twitch\\", (\\"twitch.tv\\",)),\n (\\"SoundCloud\\", (\\"soundcloud.com\\",)),\n (\\"XVideos\\", (\\"xvideos.com\\",)),\n (\\"Pornhub\\", (\\"pornhub.com\\",)),\n (\\"Audiomack\\", (\\"audiomack.com\\",)),\n (\\"Snapchat\\", (\\"snapchat.com\\",)),\n (\\"Bilibili\\", (\\"bilibili.com\\", \\"b23.tv\\")),\n (\\"Douyin\\", (\\"douyin.com\\",)),\n (\\"Rumble\\", (\\"rumble.com\\",)),\n (\\"Kick\\", (\\"kick.com\\",)),\n (\\"Odysee\\", (\\"odysee.com\\",)),\n (\\"Streamable\\", (\\"streamable.com\\",)),\n (\\"ARTE\\", (\\"arte.tv\\",)),\n (\\"Internet Archive\\", (\\"archive.org\\",)),\n (\\"Bandcamp\\", (\\"bandcamp.com\\",)),\n (\\"Mixcloud\\", (\\"mixcloud.com\\",)),\n (\\"Flickr\\", (\\"flickr.com\\", \\"flic.kr\\")),\n (\\"Imgur\\", (\\"imgur.com\\",)),\n (\\"Tumblr\\", (\\"tumblr.com\\",)),\n)\n\nNAME = \\"GetTheUltimate\\"\nVERSION = \\"0.9.2\\"\nSHARED_FOLDER = NAME\nRUNNER_FILENAME = f\\"engine-{VERSION}.py\\"\nOUTPUT_LABEL = \\"Files → On My iPhone → a-Shell mini → GetTheUltimate\\"\nINSTALL_MENU = \\"Install or Update Tools\\"\nINSTALL_HINT = f\\"Open GetTheUltimate and choose {INSTALL_MENU} first.\\"\n# Shortcuts can use the first text line as the filename and keep the line in\n# the file. A hexadecimal integer is valid Python even when the line is kept.\nINSTALL_MARKER = \\"0x475455092\\"\nIMAGE_MODES = {\\"image_photos\\", \\"image_files\\"}\nVIDEO_MODES = {\\"photos\\", \\"video\\"}\nMODES = VIDEO_MODES | IMAGE_MODES | {\\"audio\\", \\"setup\\"}\nMAX_URL = 4096\n# Copies returned by the a-Shell intent are read into memory in their entirety.\nTRANSFER_LIMIT = 150 * 1024 * 1024\nMAX_IMAGES = 50\nJOB_PATTERN = re.compile(r\\"[0-9]{3}(?:-[0-9]{3}){2}\Z\\")\nMAX_AGE = 24 * 3600\nPACKAGES = (\n \\"yt-dlp>=2026.10.26\\", \\"yt-dlp-apple-webkit-jsi\\", \\"gallery-dl==1.32.20\\", \\"certifi\\", \\"requests>=2.32.2,<3\\",\n \\"urllib3>=2.0.2,<3\\", \\"idna\\", \\"chardet==5.2.0\\", \\"mutagen\\", \\"websockets>=13\\",\n)\n# Try a ready-to-play file before asking FFmpeg to merge separate tracks.\nVIDEO_FORMAT = (\n r\\"b[ext=mp4][vcodec~='^(avc|h264)'][acodec~='^(mp4a|aac)']/\\"\n r\\"bv[ext=mp4][vcodec~='^(avc|h264)']+ba[ext=m4a]/\\"\n r\\"b[ext=mp4]/b/bv*+ba/bv\\"\n)\nPAGE_LIMIT = 8 * 1024 * 1024\nIMAGE_SIZE_LIMIT = TRANSFER_LIMIT\nIMAGE_EXTENSIONS = {\n \\".jpg\\", \\".jpeg\\", \\".png\\", \\".gif\\", \\".webp\\", \\".avif\\", \\".heic\\", \\".bmp\\", \\".tiff\\",\n}\nGALLERY_PLATFORMS = {\n \\"Instagram\\", \\"Pinterest\\", \\"X\\", \\"Reddit\\", \\"Bluesky\\", \\"Flickr\\", \\"Imgur\\", \\"Tumblr\\",\n}\nMETA_CDNS = (\\"cdninstagram.com\\", \\"fbcdn.net\\")\n\n\nclass DownloadError(Exception):\n pass\n\n\ndef matches_domain(host, domains):\n return any(host == domain or host.endswith(\\".\\" + domain) for domain in domains)\n\n\ndef recognized_platform(host):\n return next((label for label, domains in PLATFORMS if matches_domain(host, domains)), None)\n\n\ndef decode_link(encoded):\n if len(encoded) > 4 * ((MAX_URL + 2) // 3):\n raise DownloadError(\\"The link is too long. Use Copy Link in the app and try again.\\")\n try:\n link = html.unescape(base64.b64decode(encoded, validate=True).decode(\\"utf-8\\"))\n parts = urlsplit(link)\n port = parts.port\n except (binascii.Error, UnicodeError, ValueError) as exc:\n raise DownloadError(\\"The shortcut could not read that link.\\") from exc\n if (not link or len(link) > MAX_URL or parts.scheme not in {\\"https\\", \\"http\\"}\n or parts.username is not None or parts.password is not None or port is not None\n or re.search(r\\"[\s\x00-\x1f\x7f\\]\\", link)):\n raise DownloadError(\\"Share a public link to a post, video or audio track.\\")\n host = parts.hostname or \\"\\"\n platform = recognized_platform(host)\n if platform is None or not parts.path or parts.path == \\"/\\":\n raise DownloadError(\\"Share a link to an item on a supported site.\\")\n if platform == \\"Instagram\\":\n post = re.fullmatch(r\\"/(?:[A-Za-z0-9_.]+/)?(p|reels?|tv)/([\w-]+)/?\\", parts.path, re.ASCII)\n if post:\n kind = \\"reel\\" if post[1] == \\"reels\\" else post[1]\n return platform, f\\"https://www.instagram.com/{kind}/{post[2]}/\\"\n if not re.fullmatch(r\\"/share/(?:reel/|p/)?[\w-]+/?\\", parts.path, re.ASCII):\n raise DownloadError(\\"Open the Instagram post and use Copy Link.\\")\n # Keep functional query parameters and drop link-sharing identifiers where known.\n query = parts.query\n if platform == \\"YouTube / YouTube Music\\":\n query = urlencode([(k, v) for k, v in parse_qsl(query, keep_blank_values=True)\n if k not in {\\"si\\", \\"feature\\", \\"pp\\"}])\n return platform, urlunsplit((\\"https\\", host, parts.path, query, \\"\\"))\n\n\n@contextmanager\ndef locked_packages(root, *, updating=False):\n root.mkdir(parents=True, exist_ok=True)\n with (root / \\"packages.lock\\").open(\\"a\\") as lock:\n access = fcntl.LOCK_EX if updating else fcntl.LOCK_SH\n try:\n fcntl.flock(lock, access | fcntl.LOCK_NB)\n except BlockingIOError as exc:\n raise DownloadError(\\"A download or update is already using the tools. Try again when it finishes.\\") from exc\n yield\n\n\ndef install_packages(root):\n with locked_packages(root, updating=True):\n version = root / (\\"packages-\\" + uuid.uuid4().hex)\n current = root / \\"active-packages\\"\n candidate = root / \\"active-packages.new\\"\n version.mkdir()\n pip = [\\"python3\\", \\"-m\\", \\"pip\\", \\"--isolated\\", \\"install\\", \\"--index-url\\",\n \\"https://pypi.org/simple\\", \\"--no-input\\", \\"--disable-pip-version-check\\",\n \\"--timeout\\", \\"15\\", \\"--retries\\", \\"2\\", \\"--only-binary=:all:\\", \\"--no-deps\\", \\"--no-compile\\",\n \\"--target\\", str(version)]\n try:\n subprocess.run([*pip, *PACKAGES], check=True)\n yt_dlp = next(dist for dist in distributions(path=[str(version)])\n if dist.metadata[\\"Name\\"] == \\"yt-dlp\\")\n ejs = next(req.split(\\";\\", 1)[0].strip() for req in yt_dlp.requires or []\n if re.match(r\\"yt-dlp-ejs\s*[=<>~!]\\", req))\n # Upstream pins the compatible EJS package for each yt-dlp release.\n subprocess.run([*pip, ejs], check=True)\n # Require the pure Python detector to import before activating the new installation.\n probe = (\\"import sys,warnings;sys.path.insert(0,sys.argv[1]);\\"\n \\"warnings.filterwarnings('error',message='Unable to find acceptable character detection dependency');\\"\n \\"import yt_dlp,certifi,chardet,requests;\\"\n \\"from gallery_dl import config,job;\\"\n \\"from importlib.metadata import version;\\"\n \\"print('yt-dlp',version('yt-dlp'),'EJS',version('yt-dlp-ejs'),\\"\n \\"'gallery-dl',version('gallery-dl'))\\")\n subprocess.run([\\"python3\\", \\"-c\\", probe, str(version)], check=True)\n candidate.write_text(version.name, encoding=\\"ascii\\")\n candidate.replace(current)\n except (OSError, StopIteration, subprocess.SubprocessError):\n shutil.rmtree(version, ignore_errors=True)\n candidate.unlink(missing_ok=True)\n raise DownloadError(\\"Tool installation failed. Check your internet connection and retry Install or Update Tools.\\") from None\n for previous in root.glob(\\"packages-*\\"):\n if previous != version:\n shutil.rmtree(previous, ignore_errors=True)\n return \\"Tools are ready. Share a link and choose what you want to save.\\"\n\n\ndef install_runner(root, source):\n root.mkdir(parents=True, exist_ok=True)\n with tempfile.NamedTemporaryFile(dir=root, prefix=\\".engine-\\", delete=False) as temp:\n staged = Path(temp.name)\n try:\n temp.write(source)\n temp.close()\n staged.replace(root / RUNNER_FILENAME)\n finally:\n staged.unlink(missing_ok=True)\n\n\ndef activate_packages(root, *modules):\n try:\n name = (root / \\"active-packages\\").read_text(encoding=\\"ascii\\")\n if not re.fullmatch(r\\"packages-[0-9a-f]{32}\\", name):\n raise OSError(\\"Invalid package directory\\")\n packages = root / name\n if not all((packages / module / \\"__init__.py\\").is_file() for module in modules):\n raise OSError(\\"Installed packages are incomplete\\")\n except (OSError, UnicodeError) as exc:\n raise DownloadError(INSTALL_HINT) from exc\n sys.path.insert(0, str(packages))\n\n\ndef explain_error(exc, platform):\n message = str(exc).lower()\n if any(value in message for value in (\\"drm\\", \\"encrypted media\\")):\n return \\"This item is protected by DRM.\\"\n if \\"impersonat\\" in message:\n return f\\"{platform} is asking for a browser connection that the installed tools could not provide.\\"\n if any(value in message for value in (\\"login\\", \\"log in\\", \\"sign in\\", \\"sign-in\\", \\"cookies\\", \\"private\\")):\n return f\\"{platform} requires a session or has restricted this item. Try a public link.\\"\n if \\"ffmpeg\\" in message or \\"ffprobe\\" in message:\n return \\"a-Shell mini could not process the video or audio. Check for an app update.\\"\n if \\"unsupported url\\" in message or \\"no video\\" in message or \\"no media\\" in message:\n return f\\"No video or audio was available from this {platform} link.\\"\n if \\"403\\" in message or \\"429\\" in message or \\"rate limit\\" in message:\n return f\\"{platform} blocked or temporarily limited this download.\\"\n if any(value in message for value in (\\"timeout\\", \\"timed out\\", \\"connection\\", \\"certificate\\")):\n return f\\"Could not reach {platform}. Check your connection and try again.\\"\n if \\"not available\\" in message or \\"requested format\\" in message:\n return f\\"The requested format or item is unavailable on {platform}.\\"\n return f\\"{platform} did not return a file. Try updating the tools and sharing the item again.\\"\n\n\nclass QuietLogger:\n # Share URLs and titles can occur in upstream diagnostics. Only show sanitized errors.\n def debug(self, message):\n pass\n\n warning = error = debug\n\n\nclass PageMetadata(HTMLParser):\n def __init__(self, parse_post=False):\n super().__init__(convert_charrefs=True)\n self.image = None\n self.title = None\n self.scripts = []\n self.script = None\n self.parse_post = parse_post\n\n def handle_starttag(self, tag, attrs):\n values = dict(attrs)\n if tag == \\"meta\\" and values.get(\\"content\\"):\n key = (values.get(\\"property\\") or values.get(\\"name\\") or \\"\\").lower()\n if key in {\\"og:image\\", \\"og:image:secure_url\\", \\"twitter:image\\", \\"twitter:image:src\\"}:\n self.image = self.image or values[\\"content\\"]\n elif key == \\"og:title\\":\n self.title = values[\\"content\\"]\n elif tag == \\"script\\" and self.parse_post and (\n \\"data-sjs\\" in values or values.get(\\"type\\") == \\"application/json\\"\n ):\n self.script = []\n\n def handle_data(self, data):\n if self.script is not None:\n self.script.append(data)\n\n def handle_endtag(self, tag):\n if tag == \\"script\\" and self.script is not None:\n self.scripts.append(\\"\\".join(self.script))\n self.script = None\n\n\nMOBILE_UA = (\n \\"Mozilla/5.0 (iPhone; CPU iPhone OS 18_0 like Mac OS X) \\"\n \\"AppleWebKit/605.1.15 Version/18.0 Mobile/15E148 Safari/604.1\\"\n)\n\n\ndef public_http_url(url, domains=()):\n try:\n parts = urlsplit(url)\n host = (parts.hostname or \\"\\").rstrip(\\".\\")\n if (parts.scheme not in {\\"http\\", \\"https\\"} or not host or parts.username is not None\n or parts.password is not None or parts.port is not None or \\"%\\" in host\n or re.search(r\\"[\s\x00-\x1f\x7f\\]\\", url)):\n raise ValueError\n try:\n address = ipaddress.ip_address(host)\n except ValueError:\n address = None\n if address is not None or \\".\\" not in host or host.endswith((\\".localhost\\", \\".local\\", \\".internal\\")):\n raise ValueError\n if re.fullmatch(r\\"(?:0x[0-9a-f]+|[0-9]+)(?:\.(?:0x[0-9a-f]+|[0-9]+))*\\", host):\n raise ValueError\n if domains and not matches_domain(host, domains):\n raise ValueError\n return url\n except (ValueError, TypeError) as exc:\n raise DownloadError(\\"The site returned an invalid media link.\\") from exc\n\n\ndef public_get(requests, url, *, domains=(), referer=None):\n headers = {\\"User-Agent\\": MOBILE_UA}\n if referer:\n headers[\\"Referer\\"] = referer\n target = public_http_url(url, domains)\n for _ in range(6):\n response = requests.get(target, headers=headers, timeout=(10, 25), stream=True, allow_redirects=False)\n if response.status_code not in {301, 302, 303, 307, 308}:\n try:\n response.raise_for_status()\n except requests.RequestException:\n response.close()\n raise\n return response\n location = response.headers.get(\\"Location\\")\n response.close()\n if not location:\n break\n target = public_http_url(urljoin(target, location), domains)\n raise DownloadError(\\"The site redirected the link too many times.\\")\n\n\ndef page_metadata(response, *, parse_post=False):\n data = bytearray()\n for chunk in response.iter_content(chunk_size=64 * 1024):\n data.extend(chunk)\n if len(data) >= PAGE_LIMIT:\n break\n parser = PageMetadata(parse_post)\n parser.feed(data.decode(response.encoding or \\"utf-8\\", errors=\\"replace\\"))\n return parser\n\n\ndef image_format(path):\n \\"\\"\\"Read the signature. Some CDNs return a misleading extension or MIME type.\\"\\"\\"\n with path.open(\\"rb\\") as source:\n head = source.read(32)\n if head.startswith(b\\"\xff\xd8\xff\\"):\n return \\".jpg\\"\n if head.startswith(b\\"\x89PNG\r\n\x1a\n\\"):\n return \\".png\\"\n if head[:6] in {b\\"GIF87a\\", b\\"GIF89a\\"}:\n return \\".gif\\"\n if head[:4] == b\\"RIFF\\" and head[8:12] == b\\"WEBP\\":\n return \\".webp\\"\n if head[4:8] == b\\"ftyp\\":\n if head[8:12] in {b\\"avif\\", b\\"avis\\"}:\n return \\".avif\\"\n if head[8:12] in {b\\"heic\\", b\\"heix\\", b\\"mif1\\", b\\"msf1\\"}:\n return \\".heic\\"\n if head[:4] in {b\\"II*\x00\\", b\\"MM\x00*\\"}:\n return \\".tiff\\"\n if head.startswith(b\\"BM\\"):\n return \\".bmp\\"\n return None\n\n\ndef save_image(response, target):\n mime = response.headers.get(\\"Content-Type\\", \\"\\").split(\\";\\", 1)[0].strip().lower()\n if mime and mime != \\"application/octet-stream\\" and not mime.startswith(\\"image/\\"):\n raise DownloadError(\\"This link did not return an image.\\")\n size = 0\n try:\n with target.open(\\"wb\\") as output:\n for chunk in response.iter_content(chunk_size=64 * 1024):\n size += len(chunk)\n if size > IMAGE_SIZE_LIMIT:\n raise DownloadError(\\"This image is too large to transfer through Shortcuts.\\")\n output.write(chunk)\n suffix = image_format(target)\n if not suffix:\n raise DownloadError(\\"The site did not return a readable image.\\")\n dest = target.with_suffix(suffix)\n target.replace(dest)\n return dest\n finally:\n target.unlink(missing_ok=True)\n\n\ndef post_code(platform, url):\n path = urlsplit(url).path\n pattern = (r\\"/(?:@[^/]+/post|t)/([A-Za-z0-9_-]+)(?:/.*)?\\"\n if platform == \\"Threads\\" else r\\"/(?:[A-Za-z0-9_.]+/)?(?:p|reels?|tv)/([A-Za-z0-9_-]+)(?:/.*)?\\")\n match = re.fullmatch(pattern, path)\n return match[1] if match else None\n\n\ndef post_assets(metadata, code):\n \\"\\"\\"Return media from the requested post rather than nearby replies or recommendations.\\"\\"\\"\n if not code:\n return []\n for script in metadata.scripts:\n if code not in script:\n continue\n try:\n stack = [json.loads(script)]\n except (ValueError, RecursionError):\n continue\n while stack:\n item = stack.pop()\n if isinstance(item, list):\n stack.extend(reversed(item))\n continue\n if not isinstance(item, dict):\n continue\n if item.get(\\"code\\") == code or item.get(\\"shortcode\\") == code:\n media = item.get(\\"media\\") if isinstance(item.get(\\"media\\"), dict) else item\n if isinstance(media.get(\\"carousel_media\\"), list) and media[\\"carousel_media\\"]:\n items = media[\\"carousel_media\\"]\n else:\n sidecar = media.get(\\"edge_sidecar_to_children\\")\n edges = (sidecar.get(\\"edges\\") or []) if isinstance(sidecar, dict) else []\n items = [edge.get(\\"node\\") for edge in edges if isinstance(edge, dict)] if edges else [media]\n assets = []\n for child in items:\n if not isinstance(child, dict):\n continue\n videos = child.get(\\"video_versions\\") or []\n is_video = videos or child.get(\\"is_video\\") or child.get(\\"media_type\\") == 2\n if is_video:\n candidates = [x for x in videos if isinstance(x, dict) and isinstance(x.get(\\"url\\"), str)]\n if candidates:\n def resolution(x):\n width, height = (x.get(k) for k in (\\"width\\", \\"height\\"))\n return width * height if isinstance(width, int) and isinstance(height, int) else 0\n assets.append((\\"video\\", max(candidates, key=resolution)[\\"url\\"]))\n elif isinstance(child.get(\\"video_url\\"), str):\n assets.append((\\"video\\", child[\\"video_url\\"]))\n else:\n image_versions = child.get(\\"image_versions2\\") or {}\n candidates = image_versions.get(\\"candidates\\", []) if isinstance(image_versions, dict) else []\n first_image = next(\n (x[\\"url\\"] for x in candidates or [] if isinstance(x, dict) and isinstance(x.get(\\"url\\"), str)), None\n )\n image_url = first_image or child.get(\\"display_url\\") or child.get(\\"display_src\\")\n if isinstance(image_url, str):\n assets.append((\\"image\\", image_url))\n if assets:\n return assets\n stack.extend(reversed(tuple(item.values())))\n return []\n\n\ndef single_gallery_link(platform, url):\n path = urlsplit(url).path\n if platform not in GALLERY_PLATFORMS or image_url_suffix(url):\n return False\n if platform == \\"Instagram\\":\n return bool(post_code(platform, url))\n if platform == \\"Pinterest\\":\n return \\"/pin/\\" in path\n if platform == \\"Reddit\\":\n return bool(re.search(r\\"/(?:comments|gallery)/[a-z0-9]+\\", path))\n if platform == \\"X\\":\n return bool(re.search(r\\"/status/\d+\\", path))\n if platform == \\"Bluesky\\":\n return \\"/post/\\" in path\n if platform == \\"Flickr\\":\n return bool(re.fullmatch(r\\"/photos/[^/]+/(?:\d+|albums/\d+)(?:/.*)?\\", path))\n if platform == \\"Imgur\\":\n return bool(re.fullmatch(r\\"/(?:(?:a|gallery)/)?[A-Za-z0-9]+/?\\", path))\n if platform == \\"Tumblr\\":\n return bool(re.search(r\\"/(?:post/)?\d+(?:/|$)\\", path))\n return False\n\n\ndef image_url_suffix(url):\n return Path(urlsplit(url).path).suffix.lower() in IMAGE_EXTENSIONS\n\n\ndef download_gallery(url, folder):\n from gallery_dl import config, exception, job\n\n folder.mkdir()\n config.set((), \\"base-directory\\", str(folder))\n config.set((), \\"directory\\", ())\n options = {\n \\"file-range\\": f\\"1-{MAX_IMAGES + 1}\\",\n \\"file-filter\\": \\"extension.lower() in ('jpg','jpeg','png','gif','webp','avif','heic','bmp','tiff')\\",\n \\"post-range\\": \\"1\\",\n \\"child-range\\": \\"1\\",\n \\"videos\\": False,\n \\"timeout\\": 25,\n \\"retries\\": 1,\n }\n for key, value in options.items():\n config.set((\\"extractor\\",), key, value)\n config.set((\\"output\\",), \\"mode\\", \\"null\\")\n config.set((\\"downloader\\", \\"http\\"), \\"filesize-max\\", IMAGE_SIZE_LIMIT)\n\n previous_level = logging.root.manager.disable\n try:\n logging.disable(logging.CRITICAL)\n status = job.DownloadJob(url).run()\n except exception.GalleryDLException:\n status = 1\n finally:\n logging.disable(previous_level)\n files = [item for item in folder.rglob(\\"*\\") if item.is_file() and not item.is_symlink()\n and item.suffix.lower() not in {\\".part\\", \\".tmp\\"} and image_format(item)]\n return sorted(files, key=lambda item: (item.stat().st_mtime_ns, item.name)), status\n\n\ndef download_images(platform, url, work):\n import requests\n\n if single_gallery_link(platform, url):\n files, gallery_status = download_gallery(url, work / \\"gallery\\")\n if files:\n notice = \\"Some images could not be downloaded. Continue with the images that were found?\\" if gallery_status else \\"\\"\n return files, platform, notice\n\n try:\n with public_get(requests, url) as page:\n final = page.url\n mime = page.headers.get(\\"Content-Type\\", \\"\\").lower()\n if mime.startswith(\\"image/\\") or (image_url_suffix(final) and \\"text/html\\" not in mime):\n return [save_image(page, work / \\"image.part\\")], platform, \\"\\"\n if not (mime.startswith((\\"text/html\\", \\"application/xhtml+xml\\")) or not mime):\n raise DownloadError(\\"This link did not return a page with images.\\")\n if \\"/accounts/login\\" in urlsplit(final).path.lower():\n raise DownloadError(f\\"{platform} requires a session to see these images.\\")\n # Threads and Instagram can also publish structured media for one public post.\n parsed = page_metadata(page, parse_post=platform in {\\"Instagram\\", \\"Threads\\"})\n if final != url and single_gallery_link(platform, final) and not single_gallery_link(platform, url):\n files, gallery_status = download_gallery(final, work / \\"redirected\\")\n if files:\n notice = \\"Some images could not be downloaded. Continue with the images that were found?\\" if gallery_status else \\"\\"\n return files, parsed.title or platform, notice\n\n images = [link for kind, link in post_assets(parsed, post_code(platform, final)) if kind == \\"image\\"]\n if images:\n files = []\n for index, link in enumerate(dict.fromkeys(images), 1):\n if index > MAX_IMAGES + 1:\n break\n try:\n with public_get(requests, link, domains=META_CDNS, referer=final) as image:\n files.append(save_image(image, work / f\\"image-{index:03}.part\\"))\n except (DownloadError, requests.RequestException):\n continue\n if files:\n notice = (\\"Some images could not be downloaded. Continue with the images that were found?\\"\n if len(files) < min(len(set(images)), MAX_IMAGES + 1) else \\"\\")\n return files, parsed.title or platform, notice\n\n if not parsed.image:\n raise DownloadError(f\\"No public images were available for this {platform} link.\\")\n with public_get(requests, urljoin(final, parsed.image), referer=final) as image:\n file = save_image(image, work / \\"preview.part\\")\n return [file], parsed.title or platform, \\"Only the link preview was available. Save that image?\\"\n except requests.RequestException as exc:\n raise DownloadError(f\\"Could not download images from {platform}. Try a public post.\\") from exc\n\n\ndef threads_video(url):\n import requests\n\n try:\n with public_get(requests, url, domains=(\\"threads.com\\", \\"threads.net\\")) as page:\n final = page.url\n parsed = page_metadata(page, parse_post=True)\n for kind, link in post_assets(parsed, post_code(\\"Threads\\", final)):\n if kind == \\"video\\":\n return public_http_url(link, META_CDNS), final, parsed.title\n except requests.RequestException as exc:\n raise DownloadError(\\"Threads could not open this public post.\\") from exc\n # Some public posts expose the video only through their page player.\n return url, None, None\n\n\ndef expand_short_link(platform, url):\n host = urlsplit(url).hostname\n if (platform, host) not in {(\\"Douyin\\", \\"v.douyin.com\\"), (\\"Bilibili\\", \\"b23.tv\\")}:\n return url\n import requests\n\n domains = (\\"douyin.com\\",) if platform == \\"Douyin\\" else (\\"b23.tv\\", \\"bilibili.com\\")\n try:\n with public_get(requests, url, domains=domains) as response:\n return response.url\n except requests.RequestException as exc:\n raise DownloadError(f\\"Could not open this {platform} share link. Try the full video link.\\") from exc\n\n\ndef download_media(downloader, platform, url, mode, work, referer=None):\n options = {\n \\"quiet\\": True, \\"noprogress\\": True, \\"logger\\": QuietLogger(),\n \\"noplaylist\\": True, \\"playlist_items\\": \\"1\\", \\"cachedir\\": False,\n \\"paths\\": {\\"home\\": str(work), \\"temp\\": str(work)},\n \\"outtmpl\\": {\\"default\\": \\"media.%(ext)s\\"},\n \\"socket_timeout\\": 25, \\"retries\\": 2, \\"fragment_retries\\": 2,\n \\"enable_file_urls\\": False, \\"js_runtimes\\": {},\n }\n if referer:\n options[\\"http_headers\\"] = {\\"Referer\\": referer}\n if mode == \\"audio\\":\n options.update(format=\\"ba[ext=m4a]/ba/b\\", postprocessors=[\n {\\"key\\": \\"FFmpegExtractAudio\\", \\"preferredcodec\\": \\"m4a\\"},\n ])\n else:\n options.update(format=VIDEO_FORMAT, merge_output_format=\\"mp4/mkv\\")\n\n try:\n with downloader.YoutubeDL(options) as ydl:\n info = ydl.extract_info(url, download=True)\n except downloader.utils.DownloadError as exc:\n raise DownloadError(explain_error(exc, platform)) from exc\n\n if info and info.get(\\"entries\\") is not None:\n info = next((item for item in info[\\"entries\\"] if item), None)\n media = sorted(path for path in work.iterdir()\n if path.is_file() and re.fullmatch(r\\"media\.[a-zA-Z0-9]{2,5}\\", path.name)\n and path.suffix.lower() not in {\\".part\\", \\".ytdl\\", \\".json\\", \\".temp\\"}\n and path.stat().st_size > 0)\n if len(media) != 1 or not info:\n raise DownloadError(\\"The download did not produce one complete file.\\")\n if mode == \\"audio\\" and media[0].suffix.lower() != \\".m4a\\":\n raise DownloadError(\\"Could not convert the audio to M4A.\\")\n selected = (info.get(\\"requested_downloads\\") or [info])[0]\n return media[0], info.get(\\"title\\") or platform, selected\n\n\ndef ffmpeg(*args, timeout=None):\n return subprocess.run([\\"ffmpeg\\", \\"-nostdin\\", \\"-hide_banner\\", *map(str, args)],\n stdout=subprocess.DEVNULL, stderr=subprocess.PIPE,\n text=True, errors=\\"replace\\", timeout=timeout)\n\n\ndef compatible_mp4(source, work, selected):\n vcodec = (selected.get(\\"vcodec\\") or \\"\\").lower()\n acodec = (selected.get(\\"acodec\\") or \\"\\").lower()\n if (source.suffix.lower() == \\".mp4\\" and vcodec.startswith((\\"avc\\", \\"h264\\"))\n and (acodec == \\"none\\" or acodec.startswith((\\"aac\\", \\"mp4a\\")))):\n return source\n\n print(\\"Preparing an MP4 for iPhone.\\", flush=True)\n try:\n streams = ffmpeg(\\"-i\\", source, timeout=20).stderr\n h264 = re.search(r\\"Stream[^\n]*Video: h264\b[^\n]*\byuv420p\b\\", streams) is not None\n audio_codecs = re.findall(r\\"Stream[^\n]*Audio: ([\w]+)\\", streams)\n aac = all(codec == \\"aac\\" for codec in audio_codecs)\n if source.suffix.lower() == \\".mp4\\" and h264 and aac:\n return source\n dest = work / \\"compatible.mp4\\"\n video_encoders = (\\"copy\\",) if h264 else (\\"h264_videotoolbox\\", \\"libx264\\")\n for encoder in video_encoders:\n video_args = [\\"-pix_fmt\\", \\"yuv420p\\"] if encoder != \\"copy\\" else []\n audio_args = [\\"-c:a\\", \\"copy\\"] if aac else [\\"-c:a\\", \\"aac\\", \\"-b:a\\", \\"160k\\"]\n result = ffmpeg(\\"-y\\", \\"-i\\", source, \\"-map\\", \\"0:v:0\\", \\"-map\\", \\"0:a:0?\\",\n \\"-c:v\\", encoder, *video_args, *audio_args,\n \\"-movflags\\", \\"+faststart\\", dest)\n if result.returncode == 0 and dest.is_file() and dest.stat().st_size:\n return dest\n dest.unlink(missing_ok=True)\n except (OSError, NotImplementedError, subprocess.SubprocessError):\n pass\n return None\n\n\ndef photos_format(source, target):\n suffix = image_format(source)\n if suffix in {\\".jpg\\", \\".png\\", \\".gif\\", \\".heic\\"}:\n return source\n try:\n result = ffmpeg(\\"-y\\", \\"-i\\", source, \\"-frames:v\\", \\"1\\", \\"-update\\", \\"1\\", target, timeout=60)\n except (OSError, NotImplementedError, subprocess.SubprocessError):\n return None\n if result.returncode == 0 and target.is_file() and image_format(target) == \\".png\\":\n return target\n target.unlink(missing_ok=True)\n return None\n\n\ndef filename_stem(title):\n name = unicodedata.normalize(\\"NFC\\", str(title))\n name = \\"\\".join(c if c.isalnum() or c in \\" -_()\\" else \\" \\" for c in name)\n return (\\" \\".join(name.split()).encode(\\"utf-8\\")[:100].decode(\\"utf-8\\", \\"ignore\\").strip() or \\"Media\\")\n\n\ndef unique_stem(title, job):\n return f\\"{filename_stem(title)} - {job}\\"\n\n\ndef publish(source, title, folder):\n name = f\\"{filename_stem(title)} - {uuid.uuid4().hex[:10]}{source.suffix.lower()}\\"\n path = folder / name\n source.replace(path)\n return path\n\n\ndef write_text(path, value):\n temp = path.with_suffix(\\".tmp\\")\n temp.write_text(value, encoding=\\"utf-8\\")\n temp.replace(path)\n\n\ndef stage_media(source, filename, run, documents):\n \\"\\"\\"Publish a result for Shortcuts, or leave a visible copy when transfer is too large.\\"\\"\\"\n if source.stat().st_size > TRANSFER_LIMIT:\n saved = publish(source, Path(filename).stem, documents)\n return f\\"Too large to transfer through Shortcuts. Saved in {OUTPUT_LABEL}.\n\n{saved.name}\\"\n staging = run / \\"media.part\\"\n try:\n shutil.copyfile(source, staging)\n staging.replace(run / filename)\n write_text(run / \\"filename.txt\\", filename)\n except OSError:\n staging.unlink(missing_ok=True)\n saved = publish(source, Path(filename).stem, documents)\n return f\\"Could not hand the download to Shortcuts. Saved in {OUTPUT_LABEL}.\n\n{saved.name}\\"\n return \\"\\"\n\n\ndef stage_images(files, title, notice, mode, work, run, documents):\n if len(files) > MAX_IMAGES:\n notice = f\\"The shortcut can transfer up to {MAX_IMAGES} images per run. Continue with the first {MAX_IMAGES}?\\"\n name = unique_stem(title, run.name)\n originals = []\n for index, source in enumerate(files[:MAX_IMAGES], 1):\n suffix = image_format(source)\n if suffix:\n originals.append((index, source, suffix))\n if not originals:\n raise DownloadError(\\"No readable images were downloaded.\\")\n\n compatible = []\n if mode == \\"image_photos\\":\n for index, source, suffix in originals:\n target = photos_format(source, work / f\\"converted-{index:03}.png\\")\n if target:\n compatible.append((index, target, image_format(target)))\n else:\n compatible = originals\n\n if len(compatible) != len(originals):\n fallback = documents / (name + \\" - Original Images\\")\n fallback.mkdir()\n for index, source, suffix in originals:\n shutil.copyfile(source, fallback / f\\"{index:03}{suffix}\\")\n detail = f\\"Some images could not be prepared for Photos. The originals are in {OUTPUT_LABEL} → {fallback.name}.\\"\n if not compatible:\n return detail\n notice = \\" \\".join(filter(None, (notice, detail, \\"Continue with the compatible images?\\")))\n\n archive = work / \\"images.zip\\"\n with ZipFile(archive, \\"w\\") as images:\n for index, source, suffix in compatible:\n images.write(source, arcname=f\\"{name} - {index:03}{suffix}\\")\n\n fallback = stage_media(archive, f\\"{name}.zip\\", run, documents)\n if fallback:\n return fallback\n if notice:\n write_text(run / \\"notice.txt\\", notice)\n count = len(compatible)\n return f\\"{count} {'image' if count == 1 else 'images'} ready to save.\\"\n\n\ndef acquire(mode, link, state, documents, run):\n platform, url = decode_link(link)\n with locked_packages(state):\n downloader = \\"gallery_dl\\" if mode in IMAGE_MODES else \\"yt_dlp\\"\n activate_packages(state, downloader, \\"requests\\")\n documents.mkdir(parents=True, exist_ok=True)\n with tempfile.TemporaryDirectory(dir=documents, prefix=\\".download-\\") as tmp:\n work = Path(tmp)\n print(f\\"Downloading from {platform}…\\", flush=True)\n if mode in IMAGE_MODES:\n files, title, notice = download_images(platform, url, work)\n return stage_images(files, title, notice, mode, work, run, documents)\n\n import yt_dlp\n\n referer = None\n post_title = None\n if platform == \\"Threads\\":\n url, referer, post_title = threads_video(url)\n else:\n url = expand_short_link(platform, url)\n source, title, selected = download_media(yt_dlp, platform, url, mode, work, referer)\n title = post_title or title\n if mode in VIDEO_MODES:\n ready = compatible_mp4(source, work, selected)\n if ready is None:\n original = publish(source, title, documents)\n return (f\\"Could not make an iPhone compatible MP4. The original is in {OUTPUT_LABEL}.\\"\n f\\"\n\n{original.name}\\")\n suffix = \\".mp4\\"\n else:\n ready, suffix = source, \\".m4a\\"\n\n fallback = stage_media(ready, unique_stem(title, run.name) + suffix, run, documents)\n return fallback or \\"Download ready to save.\\"\n\n\ndef run_job(mode, job, link, home, shared):\n if mode not in MODES or not JOB_PATTERN.fullmatch(job):\n raise ValueError(\\"Invalid arguments from Shortcuts.\\")\n jobs = shared / SHARED_FOLDER\n jobs.mkdir(parents=True, exist_ok=True)\n for previous in jobs.iterdir():\n try:\n if previous.is_dir() and JOB_PATTERN.fullmatch(previous.name) and time.time() - previous.stat().st_mtime > MAX_AGE:\n shutil.rmtree(previous, ignore_errors=True)\n except FileNotFoundError:\n pass\n\n run = jobs / job\n run.mkdir()\n state = home / \\"Library\\" / SHARED_FOLDER\n documents = home / \\"Documents\\" / NAME\n try:\n if mode == \\"setup\\":\n print(f\\"{NAME} {VERSION} setup\\", flush=True)\n install_runner(state, Path(__file__).read_bytes())\n message = install_packages(state)\n else:\n message = acquire(mode, link, state, documents, run)\n except DownloadError as exc:\n message = str(exc)\n except ImportError:\n message = f\\"The tools are incomplete. {INSTALL_HINT}\\"\n except (OSError, subprocess.SubprocessError) as exc:\n message = f\\"a-Shell mini could not finish the operation ({type(exc).__name__}). Check available storage.\\"\n write_text(run / \\"message.txt\\", message)\n print(message)\n\n\nif __name__ == \\"__main__\\":\n mode, job, link = sys.argv[1:]\n shared_path = os.environ.get(\\"SHORTCUTS\\")\n run_job(mode, job, link, Path.home(), Path(shared_path) if shared_path else Path.cwd())\n"
rawAction("AsheKube.app.a-Shell-mini.PutFileIntent", {
"ShowWhenRun": false,
"file": "Text",
"overwrite": true
})
rawAction("AsheKube.app.a-Shell-mini.ExecuteCommandIntent", {
"ShowWhenRun": false,
"command": "dash -c 'cd \\\"${SHORTCUTS:-.}\\\" || exit; j=\\\"{}-{}-{}\\\"; d=\\\"GetTheUltimate/$j\\\"; p=\\\"0x475455092.txt\\\"; if [ -s \\\"$p\\\" ]; then python3 \\\"$p\\\" setup \\\"$j\\\" \\\"\\\"; rm -f \\\"$p\\\"; fi; [ -f \\\"$d/message.txt\\\" ] || { mkdir -p \\\"$d\\\" \u0026\u0026 echo \\\"GetTheUltimate 0.9.2 setup could not start. Open a-Shell mini for details.\\\" \u003e \\\"$d/message.txt\\\"; }; open shortcuts://'",
"keepGoing": false,
"openWindow": "open"
})
waitToReturn()
rawAction("AsheKube.app.a-Shell-mini.GetFileIntent", {
"ShowWhenRun": false,
"copyFile": true,
"errorIfNotFound": false,
"fileName": "GetTheUltimate/{}-{}-{}/message.txt"
})
if !File17 {
alert("a-Shell mini did not return a result. Open a-Shell mini to see where it stopped.", "GetTheUltimate 0.9.2")
stop()
}
getText(File17)
alert(, "GetTheUltimate 0.9.2")
}
Ratings & Reviews
Write a ReviewNo reviews yet. Be the first to share what you think!