ShareShortcuts

Instagram Download

lulu
Fork “Instagram Download”

Built something new on top of this Shortcut? Share it as a fork: it becomes a Shortcut of your own, which you manage, and both pages link to each other so lulu gets credit.

  1. 1Get the Shortcut and change it in the Shortcuts app. Give it a name of its own.
  2. 2Share it from the Shortcuts app and copy the iCloud link.
  3. 3Come back here, paste the link and describe what is different, e.g. “Added a step that uses Apple Intelligence to personalise the text.”
Downloads
53K
Saved
1
Actions
138
Category
Calculations
Version
1.0
Language
EN

jnjknk

What's New

Version 1.0

First release

Version History
1.0 Apr 19, 2021

First release

What it does

138 actions
  1. Comment
    Downloads photos and videos from posts, stories, igtv or reels—public or private—in Instagram or Safari on iPhone or iPad. 2021-04-16 v1.1 u/gluebyte https://routinehub.co/shortcut/7823
  2. Dictionary
  3. Get Dictionary Value
  4. List
  5. Set Variable
    mainDict
  6. Random Number
  7. If
  8. Get Contents of URL
    https://updatecheck.gluebyte.workers.dev/?id=DF1910A2
  9. If
  10. Choose from Menu
    ✴️ New Version Available ✴️…
  11. Choose from Menu
    Go to RoutineHub
  12. Open URLs
  13. Stop This Shortcut
  14. Choose from Menu
    Download Update
  15. Get Contents of URL
    https://routinehub.co/api/v1/shortcuts/7823/versions/latest
  16. URL
    https://routinehub.co/download/…
  17. Open URLs
  18. Stop This Shortcut
  19. Choose from Menu
    Not Now
  20. Replace Text
  21. If
  22. Show Result
  23. Stop This Shortcut
  24. Get Type
  25. Get Type
  26. If
  27. If
  28. If
  29. Get Contents of URL
    …
  30. Make HTML from Rich Text
  31. Replace Text
  32. If
  33. Get Variable
  34. If
  35. Text
  36. Make Rich Text from Markdown
  37. Make HTML from Rich Text
  38. Replace Text
  39. Replace Text
  40. URL
    ……
  41. If
  42. URL
    data:text/html,<body onload="location='…'"/>
  43. Open URLs
  44. Stop This Shortcut
  45. Replace Text
  46. Get Contents of URL
    …
  47. If
  48. If
  49. If
  50. Text
  51. If
  52. Get Contents of URL
    …
  53. Make HTML from Rich Text
  54. If
  55. Make HTML from Rich Text
  56. If
  57. Replace Text
  58. If
  59. Replace Text
  60. If
  61. Nothing
  62. Replace Text
  63. If
  64. Replace Text
  65. If
  66. If
  67. If
  68. Make Rich Text from Markdown
  69. Make HTML from Rich Text
  70. Replace Text
  71. Replace Text
  72. Replace Text
  73. URL
    ……
  74. If
  75. URL
    data:text/html,<body onload="location='…'"/>
  76. Open URLs
  77. Stop This Shortcut
  78. If
  79. Number
  80. If
  81. If
  82. If
  83. Number
  84. If
  85. Show Result
  86. Run JavaScript on Web Page
  87. Stop This Shortcut
  88. Replace Text
  89. If
  90. Replace Text
  91. If
  92. Replace Text
  93. If
  94. Nothing
  95. If
  96. Replace Text
  97. Text
  98. Replace Text
  99. Replace Text
  100. If
  101. Replace Text
  102. If
  103. Replace Text
  104. Replace Text
  105. Replace Text
  106. Count
  107. If
  108. If
  109. If
  110. Make Rich Text from Markdown
  111. Make HTML from Rich Text
  112. Replace Text
  113. Replace Text
  114. Replace Text
  115. URL
    ……
  116. If
  117. URL
    data:text/html,<body onload="location='…'"/>
  118. Open URLs
  119. If
  120. Show Alert
  121. Stop This Shortcut
  122. Get Contents of URL
    …
  123. If
  124. Choose from List
  125. Count
  126. Replace Text
  127. If
  128. Replace Text
  129. If
  130. Text
  131. If
  132. Text
  133. Set Name
  134. If
  135. Repeat with Each
  136. Text
  137. Set Name
  138. Save to Photo Album

View as code
Beta

Every action of this Shortcut written out as Cherri, a programming language for Shortcuts. Great for learning how it works.

#include 'actions/web'
#define color green
#define glyph cameraViewFinder

/*
Downloads photos and videos from posts, stories, igtv or reels—public or private—in Instagram or Safari on iPhone or iPad.
2021-04-16 	v1.1 	u/gluebyte
https://routinehub.co/shortcut/7823
*/
const Dictionary = {
	"Show Safari Instructions": true
}
const ShowInstructions = getValue(Dictionary, "")
list()
@mainDict
const RandomNumber = randomNumber(1, 3)

if RandomNumber == 1 {
	const ContentsOfURL = downloadURL("https://updatecheck.gluebyte.workers.dev/?id=DF1910A2")
	if ContentsOfURL !contains @mainDict['version'] {
		menu "✴️ New Version Available ✴️{ContentsOfURL}" {
		item "Go to RoutineHub":
			openURL("https://routinehub.co/shortcut/7823/")
			stop()
		item "Download Update":
			downloadURL("https://routinehub.co/api/v1/shortcuts/7823/versions/latest")
			const URL = url("https://routinehub.co/download/{['id']}")
			openURL(URL)
			stop()
		item "Not Now":
		}
	}
}
const Shortcode = replaceText("^.*instagram.com/(?:p|s|stories|tv|reel)/.*?([^/]+)[/?][^/]*$", "$1", "ㅁ{ShortcutInput}", true)

if Shortcode beginsWith "ㅁ" {
	show("Please share post or stories.\n{ShortcutInput}")
	stop()
}
const URLType = typeOf(ShortcutInput)
const Type = typeOf(ShortcutInput)

if Type == URLType {
	if ShortcutInput contains "instagram.com/s" {
		if ShortcutInput contains "instagram.com/s/" {
			const ContentsOfURL1 = downloadURL(ShortcutInput)
			makeHTML(ContentsOfURL1)
			replaceText("(?s)^.+\"username\":\"([^\"]+).+$", "https://instagram.com/$1", true)
		} else {
			// TODO: Get Variable not supported: Assign variable here to 'ShortcutInput'.
		}
		if ShowInstructions ==  {
			const Text = "## Download Story\n\nYou can download story after logging in using Safari.\n\n1. Tap the **Open Story** link below.\n2. Pause the story with the ⏸ button on the top right side of the story or the **···** button at the bottom next to *Send Message*.\n\t* You can ignore whatever appears on screen as long as story does not progress to the next one.\n3. Run **Instagram Download** by tapping {@mainDict['share']} in Safari.\n4. Close this tab."
			const RichTextFromMarkdown = getRichTextFromMarkdown(Text)
			makeHTML(RichTextFromMarkdown)
			replaceText("❰URL❱", "{}{@mainDict['footer']}")
			replaceText("❰TYPE❱", "Story")
			url("{@mainDict['header']}{}")
		} else {
			url("data:text/html,<body onload=\"location='{}'\"/>")
		}
		openURL(IfResult)
		stop()
	}
	replaceText("\?.*$", "?__a=1", "{ShortcutInput}?", true)
	const ContentsOfURL2 = downloadURL()
	if ContentsOfURL2 beginsWith "{\"graphql\":" {
	} else {
		if ContentsOfURL2 == "{}" {
		} else {
			const ContentsOfURL3 = downloadURL(ShortcutInput)
			makeHTML(ContentsOfURL3)
		}
	}
} else {
	makeHTML(ShortcutInput)
}

if ShortcutInput contains "instagram.com/stories/" {
	const UpdatedText = replaceText("(?s)^.+src=\"(https[^\"]+instagram[^\"]+\.mp4[^\"]*).+$", "$1", "ㅁ{FullHTML}", true)
	if UpdatedText beginsWith "ㅁ" {
		const UpdatedText1 = replaceText("^[\s\S]+?src(?:set)?=\"(https[^\" ]+?instagram((?!/[ps]\d{3,4}x\d{3,4}/)[^\" ])+?\.jpg[^\" ]*)[\s\S]+$", "$1", "ㅁ{FullHTML}", true)
		if UpdatedText1 beginsWith "ㅁ" {
		}
	}
	replaceText("&amp;", "&")
} else {
	const html = replaceText("(?s)^.+\"graphql\":([^\n]+).+$", "$1", "ㅁ{FullHTML}", true)
	if Type == URLType {
		if FullHTML contains "\"is_private\":true" {
			if ShowInstructions ==  {
				const RichTextFromMarkdown1 = getRichTextFromMarkdown(@mainDict)
				makeHTML(RichTextFromMarkdown1)
				replaceText("❰SHARE❱", @mainDict['share'])
				replaceText("❰URL❱", ShortcutInput, "{}{@mainDict['footer']}")
				replaceText("❰TYPE❱", "Private Post")
				url("{@mainDict['header']}{}")
			} else {
				url("data:text/html,<body onload=\"location='{ShortcutInput}'\"/>")
			}
			openURL(IfResult1)
			stop()
		}
	} else {
		if html beginsWith "ㅁ" {
		} else {
			if html contains "\"shortcode\":\"{Shortcode}\"" {
			}
		}
		if IfResult2 == "" {
			show("Webpage needs to be reloaded. Please run the shortcut again.")
			runJavaScriptOnWebpage("location.reload();\ncompletion();")
			stop()
		}
	}
	const UpdatedText2 = replaceText("^.+\"edge_sidecar_to_children\":", "", "ㅁ{html}", true)
	if UpdatedText2 beginsWith "ㅁ" {
		const UpdatedText3 = replaceText("^.+\"video_url\":\"([^\"]+instagram[^\"]+\.(jpg|mp4)[^\"]*).+$", "$1", UpdatedText2, true)
		if UpdatedText3 beginsWith "ㅁ" {
			const UpdatedText4 = replaceText("^.+\"display_url\":\"([^\"]+instagram[^\"]+\.(jpg|mp4)[^\"]*).+$", "$1", UpdatedText3, true)
			if UpdatedText4 beginsWith "ㅁ" {
			}
		}
	} else {
		replaceText("\"edge_related_profiles\":.+$", "", UpdatedText2, true)
		const n = "\n"
		replaceText(".*?\"(?:display|video)_url\":\"([^\"]+instagram[^\"]+\.(jpg|mp4)[^\"]*)", "$1{n}", true)
		replaceText("\n\".*$", "", true)
		if ContentsOfURL2 beginsWith "{\"graphql\":" {
			replaceText("(.+\.mp4.*)\n.+\.jpg.*", "$1", true)
		} else {
			replaceText(".+\.jpg.*\n(.+\.mp4.*)", "$1", true)
		}
	}
	replaceText("\u0026", "&")
	replaceText("\/", "/")
}
const Count = count(IfResult3, "Lines")

if !IfResult3 {
	if Type == URLType {
		if ShowInstructions ==  {
			const RichTextFromMarkdown2 = getRichTextFromMarkdown(@mainDict)
			makeHTML(RichTextFromMarkdown2)
			replaceText("❰SHARE❱", @mainDict['share'])
			replaceText("❰URL❱", ShortcutInput, "{}{@mainDict['footer']}")
			replaceText("❰TYPE❱", "Post")
			url("{@mainDict['header']}{}")
		} else {
			url("data:text/html,<body onload=\"location='{ShortcutInput}'\"/>")
		}
		openURL(IfResult4)
	} else {
		confirm("Media not found. Please report to developer if problem persists.")
	}
	stop()
}
const ContentsOfURL4 = downloadURL(IfResult3)

if Count > 1 {
	chooseFromList(ContentsOfURL4, true, true)
}
const Count1 = count(IfResult5)
const UpdatedText5 = replaceText("(?s)^.*\"username\":\"([^\"]+)\",\"(?:is_private|blocked_by_viewer)\".*$", "$1", "ㅁ{FullHTML}", true)

if UpdatedText5 beginsWith "ㅁ" {
	const UpdatedText6 = replaceText("(?s)^.*?<img alt=\"([^'\"]+)['\"].*$", "$1", "ㅁ{FullHTML}", true)
	if UpdatedText6 beginsWith "ㅁ" {
	}
}

if Count1 == 1 {
	setName(IfResult5)
} else {
	for _ in IfResult5 {
		setName(@RepeatItem)
	}
}
savePhoto(IfResult6)
Decompiled with cherri 2.3.0 (GPL-2.0). May need small fixes before it compiles.

Ratings & Reviews

Write a Review
–
out of 5
★★★★★
★★★★
★★★
★★
★
0 ratings

No reviews yet. Be the first to share what you think!

Advertisement

More by lulu

See All

You Might Also Like

See All
Advertisement