-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPicture.psm1
More file actions
47 lines (35 loc) · 1.46 KB
/
Picture.psm1
File metadata and controls
47 lines (35 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
Function Save-InstagramPicture {
<#
.SYNOPSIS
Save-InstagramPictures is a PowerShell function that saves pictures displayed on the Instgram Profile from Instagram onto the file system.
.PARAMETER ID
The Instagram ID e.g. github
.PARAMETER Index
Index of the photo displayed on the Instagram Profile Page
.PARAMETER File
Name of the downloaded picture. If this parameter is not set, a random file name will be generated.
.EXAMPLE
Save-InstagramPicture -URI github -Index 1
#>
param (
[parameter (Mandatory=$true)]
[string]$ID,
[parameter (Mandatory=$false)]
[int]$Index = 0,
[parameter (Mandatory=$false)]
[string]$File = [System.IO.Path]::GetRandomFileName() + '.jpg'
)
Write-Host 'Welcome to the instagram picture downloader!'
$WebContent = Invoke-RestMethod -Uri "https://www.instagram.com/$($ID)/?__a=1"
$imageURI = $WebContent.graphql.user.edge_owner_to_timeline_media.edges[$index].node.display_url
# Download Picture
$directory = 'C:\Users\' + $Env:UserName + '\Pictures\'
if(!(Test-Path -Path $directory )){
Write-Error 'The Pictures directory does not exist!' $directory
exit
}
Invoke-WebRequest -Uri $imageURI -OutFile $directory$File
Write-Host 'Image has been successfully saved to the Pictures folder with the name' $File
Invoke-Item $directory
}
Export-ModuleMember -Function Save-InstagramPicture -Alias 'Insta'