-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.ps1
248 lines (248 loc) · 11.3 KB
/
run.ps1
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
Import-Module -Name .\modules\testforwt.ps1
Import-Module -Name .\modules\variables.ps1
function DownloadAll {
Clear-Host
$host.UI.RawUI.WindowTitle = "Starting All Downloads"
Write-Host "-- Starting All Downloads --" -ForegroundColor DarkGreen
BlueskyDL
DeviantartDL
e621DL
FurAffinityDL
PatreonDL
PinterestDL
ToyhouseDL
TumblrDL
TwitterDL
Clear-Host
Write-Host "-- Finished All Downloads --" -ForegroundColor DarkGreen
Write-Host "Press any key to continue."
$host.UI.RawUI.ReadKey()
StartMainMenu
}
function BlueskyDL {
Clear-Host
$host.UI.RawUI.WindowTitle = "Starting Bluesky Downloads"
Write-Host "-- Starting Bluesky Downloads --" -ForegroundColor DarkGreen
Start-Process $gallerydl -ArgumentList "$($configloc) $($extraconfig) -i .\bluesky\urls.txt" -WorkingDirectory $wd -NoNewWindow -Wait
Write-Host "-- Finished Bluesky Downloads --" -ForegroundColor DarkGreen
$host.UI.RawUI.WindowTitle = "Finished Bluesky Downloads"
}
function DeviantartDL {
Clear-Host
$host.UI.RawUI.WindowTitle = "Starting Deviantart Downloads"
Write-Host "-- Starting Deviantart Downloads --" -ForegroundColor DarkGreen
Start-Process $gallerydl -ArgumentList "$($configloc) $($extraconfig) -i .\deviantart\urls.txt" -WorkingDirectory $wd -NoNewWindow -Wait
Write-Host "-- Finished Deviantart Downloads --" -ForegroundColor DarkGreen
$host.UI.RawUI.WindowTitle = "Finished Deviantart Downloads"
}
function e621DL {
Clear-Host
$host.UI.RawUI.WindowTitle = "Starting e621 Downloads"
Write-Host "-- Starting e621 Downloads --" -ForegroundColor DarkGreen
Start-Process $gallerydl -ArgumentList "$($configloc) $($extraconfig) -i .\e621\urls.txt" -WorkingDirectory $wd -NoNewWindow -Wait
Write-Host "-- Finished e621 Downloads --" -ForegroundColor DarkGreen
$host.UI.RawUI.WindowTitle = "Finished e621 Downloads"
}
function FurAffinityDL {
Clear-Host
$host.UI.RawUI.WindowTitle = "Starting FurAffinity Downloads"
Write-Host "-- Starting FurAffinity Downloads --" -ForegroundColor DarkGreen
Start-Process $gallerydl -ArgumentList "$($configloc) $($extraconfig) -i .\furaffinity\urls.txt" -WorkingDirectory $wd -NoNewWindow -Wait
Write-Host "-- Finished FurAffinity Downloads --" -ForegroundColor DarkGreen
$host.UI.RawUI.WindowTitle = "Finished FurAffinity Downloads"
}
function PatreonDL {
Clear-Host
$host.UI.RawUI.WindowTitle = "Starting Patreon Downloads"
Write-Host "-- Starting Patreon Downloads --" -ForegroundColor DarkGreen
Start-Process $gallerydl -ArgumentList "$($configloc) $($extraconfig) -i .\patreon\urls.txt" -WorkingDirectory $wd -NoNewWindow -Wait
Write-Host "-- Finished Patreon Downloads --" -ForegroundColor DarkGreen
$host.UI.RawUI.WindowTitle = "Finished Patreon Downloads"
}
function PinterestDL {
Clear-Host
$host.UI.RawUI.WindowTitle = "Starting Pinterest Downloads"
Write-Host "-- Starting Pinterest Downloads --" -ForegroundColor DarkGreen
Start-Process $gallerydl -ArgumentList "$($configloc) $($extraconfig) $($pinterestfix) -i .\pinterest\urls.txt" -WorkingDirectory $wd -NoNewWindow -Wait
Write-Host "-- Finished Pinterest Downloads --" -ForegroundColor DarkGreen
$host.UI.RawUI.WindowTitle = "Finished Pinterest Downloads"
}
function ToyhouseDL {
Clear-Host
$host.UI.RawUI.WindowTitle = "Starting Toyhouse Downloads"
Write-Host "-- Starting Toyhouse Downloads --" -ForegroundColor DarkGreen
Start-Process $gallerydl -ArgumentList "$($configloc) $($extraconfig) $($toyhousefix) -i .\toyhouse\urls.txt" -WorkingDirectory $wd -NoNewWindow -Wait
Write-Host "-- Finished Toyhouse Downloads --" -ForegroundColor DarkGreen
$host.UI.RawUI.WindowTitle = "Finished Toyhouse Downloads"
}
function TumblrDL {
Clear-Host
$host.UI.RawUI.WindowTitle = "Starting Tumblr Downloads"
Write-Host "-- Starting Tumblr Downloads --" -ForegroundColor DarkGreen
Start-Process $gallerydl -ArgumentList "$($configloc) $($extraconfig) -i .\tumblr\urls.txt" -WorkingDirectory $wd -NoNewWindow -Wait
Write-Host "-- Finished Tumblr Downloads --" -ForegroundColor DarkGreen
$host.UI.RawUI.WindowTitle = "Finished Tumblr Downloads"
}
function TwitterDL {
Clear-Host
$host.UI.RawUI.WindowTitle = "Starting Twitter Downloads"
Write-Host "-- Starting Twitter Downloads --" -ForegroundColor DarkGreen
Start-Process $gallerydl -ArgumentList "$($configloc) $($extraconfig) -i .\twitter\urls.txt" -WorkingDirectory $wd -NoNewWindow -Wait
Write-Host "-- Finished Twitter Downloads --" -ForegroundColor DarkGreen
$host.UI.RawUI.WindowTitle = "Finished Twitter Downloads"
}
function ExitScript {
Clear-Host
Write-Output "Closing..."
Exit-PSHostProcess
Exit-PSSession
Exit
}
function CheckForUpdates {
Clear-Host
$host.UI.RawUI.WindowTitle = "Starting gallery-dl Update"
Write-Host "-- Starting gallery-dl Update --" -ForegroundColor DarkGreen
Write-Host "Opening elevated PowerShell window..."
Start-Process powershell 'winget.exe upgrade mikf.gallery-dl' -Verb runAs -Wait
Write-Host "Opening elevated PowerShell window..."
Start-Process powershell 'gallery-dl.exe --update' -Verb runAs -Wait
Clear-Host
Write-Host "-- Finished gallery-dl Update --" -ForegroundColor DarkGreen
$host.UI.RawUI.WindowTitle = "Finished gallery-dl Update"
Write-Host "Press any key to continue."
$host.UI.RawUI.ReadKey()
StartMainMenu
}
function FixModTime {
Clear-Host
$host.UI.RawUI.WindowTitle = "Starting Fixing Downloads"
Write-Host "-- Starting Fixing Downloads --" -ForegroundColor DarkGreen
Start-Process $gallerydl -ArgumentList "--no-download --mtime-from-date -o skip=false -i .\bluesky\urls.txt" -WorkingDirectory $wd -NoNewWindow -Wait
Start-Process $gallerydl -ArgumentList "--no-download --mtime-from-date -o skip=false -i .\deviantart\urls.txt" -WorkingDirectory $wd -NoNewWindow -Wait
Start-Process $gallerydl -ArgumentList "--no-download --mtime-from-date -o skip=false -i .\e621\urls.txt" -WorkingDirectory $wd -NoNewWindow -Wait
Start-Process $gallerydl -ArgumentList "--no-download --mtime-from-date -o skip=false -i .\furaffinity\urls.txt" -WorkingDirectory $wd -NoNewWindow -Wait
Start-Process $gallerydl -ArgumentList "--no-download --mtime-from-date -o skip=false -i .\patreon\urls.txt" -WorkingDirectory $wd -NoNewWindow -Wait
Start-Process $gallerydl -ArgumentList "--no-download --mtime-from-date -o skip=false $($pinterestfix) -i .\pinterest\urls.txt" -WorkingDirectory $wd -NoNewWindow -Wait
Start-Process $gallerydl -ArgumentList "--no-download --mtime-from-date -o skip=false $($toyhousefix) -i .\toyhouse\urls.txt" -WorkingDirectory $wd -NoNewWindow -Wait
Start-Process $gallerydl -ArgumentList "--no-download --mtime-from-date -o skip=false -i .\tumblr\urls.txt" -WorkingDirectory $wd -NoNewWindow -Wait
Start-Process $gallerydl -ArgumentList "--no-download --mtime-from-date -o skip=false -i .\twitter\urls.txt" -WorkingDirectory $wd -NoNewWindow -Wait
Write-Host "-- Finished Fixing Downloads --" -ForegroundColor DarkGreen
$host.UI.RawUI.WindowTitle = "Finished Fixing Downloads"
Pause
Clear-Host
StartMainMenu
}
function DownloadOther {
$MainDirResults = Get-ChildItem -Path $wd -Filter "urls.txt" -File
$SubDirResults = Get-ChildItem -Path $wd -Directory |
ForEach-Object {
Get-ChildItem -Path $_.FullName -Filter "urls.txt" -File
}
$AllResults = $MainDirResults + $subDirResults
if ($AllResults) {
while ($true) {
Clear-Host
Write-Host "Enter a number listed below then press 'Enter'`n" -ForegroundColor DarkGreen
# Display numbered menu
for ($i = 0; $i -lt $AllResults.Count; $i++) {
Write-Host ("[{0}] {1}" -f ($i + 1), $AllResults[$i].FullName) -ForegroundColor White
}
Write-Host "`[Q] Go Back" -ForegroundColor Red
$selection = Read-Host "`nMake a Selection"
if ($selection -eq 'Q' -or $selection -eq 'q') {
StartMainMenu
}
try {
$number = [int]$selection
if ($number -ge 1 -and $number -le $AllResults.Count) {
Clear-Host
$host.UI.RawUI.WindowTitle = "Starting Other Downloads"
Write-Host "-- Starting Other Downloads --" -ForegroundColor DarkGreen
Start-Process $gallerydl -ArgumentList "$($configloc) $($extraconfig) -i $($AllResults[$number - 1])" -WorkingDirectory $wd -NoNewWindow -Wait
Write-Host "-- Finished Other Downloads --" -ForegroundColor DarkGreen
$host.UI.RawUI.WindowTitle = "Finished Other Downloads"
Write-Host "Press any key to continue."
$host.UI.RawUI.ReadKey()
DownloadOther
} else {
Clear-Host
Write-Host "Invaild Option" -ForegroundColor Red
Write-Host "Press any key to continue."
$host.UI.RawUI.ReadKey()
Clear-Host
}
} catch {
Clear-Host
Write-Host "Invaild Option" -ForegroundColor Red
Write-Host "Press any key to continue."
$host.UI.RawUI.ReadKey()
Clear-Host
}
}
} else {
Clear-Host
Write-Host "`nNo 'urls.txt' files found in the current directory or subdirectories." -ForegroundColor Red
Write-Host "Press any key to continue."
$host.UI.RawUI.ReadKey()
Clear-Host
}
}
function InstallGalleryDL {
Clear-Host
$host.UI.RawUI.WindowTitle = "Starting gallery-dl Install"
Write-Host "-- Starting gallery-dl Install --" -ForegroundColor DarkGreen
Write-Host "Opening elevated PowerShell window..."
Start-Process powershell 'winget install mikf.gallery-dl' -Verb runAs -Wait
Write-Host "Opening elevated PowerShell window..."
Start-Process powershell 'gallery-dl --update' -Verb runAs -Wait
Clear-Host
Write-Host "-- Finished gallery-dl Install --" -ForegroundColor DarkGreen
$host.UI.RawUI.WindowTitle = "Finished gallery-dl Install"
Write-Host "Press any key to continue."
$host.UI.RawUI.ReadKey()
StartMainMenu
}
function MainMenuText {
Clear-Host
$host.UI.RawUI.WindowTitle = "Main Menu - gallery-dl"
Write-Host '==================================='
Write-Host ' gallery-dl ' -ForegroundColor Cyan
Write-Host ' PowerShell Script '
Write-Host ''
Write-Host ' By McAlec ' -ForegroundColor Blue
Write-Host '==================================='
Write-Host ''
Write-Host ' [1] Download All ' -ForegroundColor DarkGreen
Write-Host ' [2] Download Other ' -ForegroundColor DarkGreen
Write-Host ' [3] Check for Updates ' -ForegroundColor White
Write-Host ' [4] Fix Modified Time on All ' -ForegroundColor White
Write-Host ' [0] Install gallery-dl ' -ForegroundColor Magenta
Write-Host ' [?] Help ' -ForegroundColor Cyan
Write-Host ' [Q] Exit ' -ForegroundColor Red
Write-Host "`ngallery-dl $($version) "
Write-Host ''
}
function StartMainMenu {
do {
Clear-Host
MainMenuText
$key = [System.Console]::ReadKey($true).KeyChar
switch ($key) {
"1" { Clear-Host;DownloadAll }
"2" { Clear-Host;DownloadOther }
"3" { Clear-Host;CheckForUpdates }
"4" { Clear-Host;FixModTime }
"0" { Clear-Host;InstallGalleryDL }
"q" { Clear-Host;ExitScript }
default {
Clear-Host
Write-Host "Invaild Option" -ForegroundColor Red
Write-Host "Press any key to continue."
$host.UI.RawUI.ReadKey()
Clear-Host
StartMainMenu
}
}
} while ($key -ne $keyargs)
}
StartMainMenu