-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Badge Request: PSGallery profile total downloads #10593
Comments
Hi. Happy to look at a PR for this the information is available via the API. We don't take new badges that rely on scraping. Keeping them working is too high-maintenance. From https://github.com/badges/shields/blob/master/CONTRIBUTING.md#badge-guidelines
|
Unfortunately the people at psgallery takes about half a year to respond. It seems like they don't really monitor their support mail. Anyways, here's the answer I got from them.
I would interpret this as that they can provide me with the number when I ask for it, but no automation. Is it possible to run scripts when fetching the badge numbers? Here are the different implementations I've thought of:
I'm not sure if the badge/shields usually do this many calculations, but it's atleast an option. If none of the options described are wanted, then it'll probably be best to use the 2nd option implementation through something like a GitHub action, and have a static badge/shield to show the value. The problem with this implementation is that the GitHub action would make an insane amount of commits for each time the module downloads update. This could make it difficult to find your last non-automated commit. It also inflates the number of commits you've done per day on your GitHub profile. |
There have been some recent updates in the XML parsing library we use for the dynamic XML badge that improve the handling of HTML. So if you want to do it yourself, you could use the dynamic XML badge to do this. For example:
I think that is the best solution here if the only way to get the number is by scraping or making a lot of API calls. Using a GitHub action to write out a static badge can be a great approach, but I think it works best when the metric changes (or might change) every time there is a commit to the repo or every time there is a release or whatever, rather than when the thing you're measuring changes independently of activity on the repo. |
Thanks! :) the dynamic badge is perfect for my use-case, as the psgallery devs most likely won't add an "all downloads" endpoint any time soon. |
📋 Description
This badge would dynamically get the "Total downloads of packages", which is displayed on a PSGallery profile. I'd want it to look something like this static badge mockup, together with a link to the profile when you press the badge:
![](https://camo.githubusercontent.com/c5b494074a93e0f0176dafab1e4fc38672cf5b37f7e3e148bf242ff3aa0d537a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f505347616c6c657279253230646f776e6c6f6164732d333138352d626c75653f7374796c653d666c61742d737175617265266c696e6b3d68747470732533412532462532467777772e706f7765727368656c6c67616c6c6572792e636f6d25324670726f66696c65732532464e6f72736b4e6f6f62696e67)
You can see the total downloads value on any PSGallery profile, but here's a link to mine for reference:
https://www.powershellgallery.com/profiles/NorskNoobing
🔗 Data
There's already another badge called
PowerShell Gallery Downloads
, but it seems to be limited to only a single package, and therefore can't fetch the downloads of all your packages combined. It seems to be using the following API:https://www.powershellgallery.com/api/v2
Alternatively you could also scrape the profile website i.e. my profile on the following XPaths:
or
🎤 Motivation
I'd want this to display the total downloads across all my PSGallery modules/packages on my GitHub profile README.
The text was updated successfully, but these errors were encountered: