-
Notifications
You must be signed in to change notification settings - Fork 8
Support non-Windows systems, don't delete files by default #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
timothymctim
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your pull request! I’ve reformatted the code in another commit so that your contributions won’t be cluttered by formatting. I hope you can address the few questions I have before merging your code.
| } | ||
| [string]$hostname = "https://www.bing.com" | ||
| [string]$uri = "$hostname/HPImageArchive.aspx?format=xml&idx=0&n=$maxItemCount$market" | ||
| [string]$uri = "$hostname/HPImageArchive.aspx?format=xml$market&pid=hp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sadly, I cannot get this URL to work for me, the n parameter really seems required for me and the pid=hp parameter and value does not seem to add anything for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can repro. Sorry. Looks like the bare URL just needs the n path parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I yanked this when using the non-official URL. My experiments on this path indicate that only n= is honored.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also the URL gets added to below in the request paging logic.
bing-wallpapers.ps1
Outdated
| $null, $items = $items | ||
| if ($files -gt 0) { | ||
| if ($useJsonSource) { | ||
| $jsonImgs = ConvertFrom-Json -InputObject $(Invoke-WebRequest -Uri 'https://api45gabs.azurewebsites.net/api/sample/bingphotos') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I’m not mistaken, this endpoint is not an official one. I’m therefore hesitant to include it in this script. If you can find an ‘official’ endpoint that we could use, that would be perfect!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't see one and the history on the "official" endpoint is short.
Completely your call if you want to add this.
| $resolution = '1920x1200' | ||
| } | ||
| } | ||
| else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m not that familiar with PowerShell on non-Windows systems, but don’t they have a way to get the screen resolution either?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not using Windows specific classes. I will add a way for determining this for MacOS in a seperate PR
|
|
||
| # Download the latest $files wallpapers | ||
| # Download the latest $files wallpapers. | ||
| [ValidateRange("Positive")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| [ValidateRange("Positive")] | |
| [ValidateRange("NonNegative")] |
files could also be set to 0, NonNegative is required. From the PowerShell 7.4 documentation:
Positive- A number greater than zero.
NonNegative- A number greater than or equal to zero.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would someone want to download 0 wallpapers? That doesn't make much sense to me.
Here's some changes to support
Use it for parts if you wish.