Skip to content

Commit b8a7dc4

Browse files
committed
Adding a verbose messages, fix of dump folder name
1 parent 2a60a8d commit b8a7dc4

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

GoogleImageSearch/GoogleImageSearch.psm1

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
$ImagePath
99
)
1010

11-
# extract the image file name, without path
11+
# Extract the image file name, without path.
1212
$fileName = Split-Path $imagePath -Leaf
13+
Write-Verbose -Message "The image name for search: $fileName"
1314

14-
# the request body has some boilerplate before the raw image bytes (part1) and some after (part2)
15+
# The request body has some boilerplate before the raw image bytes (part1) and some after (part2)
1516
# note that $filename is included in part1
1617
$part1 = @"
1718
-----------------------------7dd2db3297c2202
@@ -54,15 +55,15 @@ Content-Disposition: form-data; name="image_content"
5455
$respStream = $request.GetResponse().GetResponseStream()
5556

5657
# pluck out the results page link that you would otherwise be redirected to
57-
(New-Object Io.StreamReader $respStream).ReadToEnd() -match 'HREF\="([^"]+)"' | Out-Null
58+
(New-Object Io.StreamReader $respStream).ReadToEnd() -match 'HREF\="([^"]+)"' | Write-Verbose
5859
$matches[1]
5960
}
6061

6162
function Get-Image
6263
{
6364
begin
6465
{
65-
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
66+
[System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") | Write-Verbose
6667
}
6768
process
6869
{
@@ -145,7 +146,7 @@ function Search-WindowsLockScreenWallpapers
145146
####################################################
146147
if ((Test-Path $DumpPath) -eq $false -and $DumpFiles -ne $null)
147148
{
148-
New-Item -Path $DumpPath -ItemType Directory -Name Temp | Write-Verbose
149+
New-Item -Path $DumpPath -ItemType Directory | Write-Verbose
149150
}
150151
####################################################
151152

@@ -164,7 +165,8 @@ function Search-WindowsLockScreenWallpapers
164165
####################################################
165166
if ($DumpFiles)
166167
{
167-
$Images | ForEach-Object { Copy-Item $_.FullName -Destination ("C:\Temp\$($_.Name).jpg") -ErrorAction Continue }
168+
Write-Verbose -Message "Dumping $($Images.Length) into $DumpPath"
169+
$Images | ForEach-Object { Copy-Item $_.FullName -Destination ("$DumpPath\$($_.Name).jpg") -ErrorAction Continue }
168170
}
169171
$Images | ForEach-Object { Search-Image -ImagePath $_.FullName }
170172
####################################################

0 commit comments

Comments
 (0)