-
Notifications
You must be signed in to change notification settings - Fork 80
feat: new app steamsales #476
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
Open
noahpodgurski
wants to merge
6
commits into
tronbyt:main
Choose a base branch
from
noahpodgurski:steamsales
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+153
−0
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a372745
feat: new app steamsales
noahpodgurski 8e108b0
update author
noahpodgurski d9d64c1
lint fixes
noahpodgurski dd1bc50
Update apps/steamsales/steamsales.star
noahpodgurski 8663604
addr comments
noahpodgurski 48399c9
format
noahpodgurski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| --- | ||
| id: steamsales | ||
| name: Steam Sales | ||
| summary: Displays Steam sales | ||
| desc: Shows your steam's app sales, and wishlists. Requires steam api key and app id. | ||
| author: noahpodgurski | ||
| fileName: steamsales.star | ||
| packageName: steamsales | ||
| recommended_interval: 5 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,144 @@ | ||
| load("http.star", "http") | ||
| load("render.star", "render") | ||
| load("schema.star", "schema") | ||
| load("time.star", "time") | ||
|
|
||
| # Your specific Game Info | ||
| DATES_URL = "https://partner.steam-api.com/IPartnerFinancialsService/GetChangedDatesForPartner/v001/" | ||
| SALES_URL = "https://partner.steam-api.com/IPartnerFinancialsService/GetDetailedSales/v001/" | ||
| WISHLIST_URL = "https://partner.steam-api.com/IPartnerFinancialsService/GetAppWishlistReporting/v001/" | ||
|
|
||
| def main(config): | ||
| salesData = [] | ||
| wishlistData = [] | ||
|
|
||
| today = time.now().format("2006-01-02") | ||
|
|
||
| game_name = config.get("game_name", "Your Game") | ||
| api_key = config.get("api_key") | ||
| app_id = config.get("app_id") | ||
| if not api_key: | ||
| return render.Root( | ||
| child = render.Column( | ||
| expanded = True, | ||
| main_align = "space_around", | ||
| cross_align = "center", | ||
| children = [ | ||
| render.Text("set api key", color = "#ffaa00", font = "6x10"), | ||
| render.Row( | ||
| children = [ | ||
| render.Text("Sales: ", color = "#fff"), | ||
| render.Text(str(0), color = "#00ff00"), | ||
| ], | ||
| ), | ||
| render.Row( | ||
| children = [ | ||
| render.Text("Wishlists: ", color = "#fff"), | ||
| render.Text(str(0), color = "#00aaff"), | ||
| ], | ||
| ), | ||
| ], | ||
| ), | ||
| ) | ||
| if not app_id: | ||
| return render.Root( | ||
| child = render.Column( | ||
| expanded = True, | ||
| main_align = "space_around", | ||
| cross_align = "center", | ||
| children = [ | ||
| render.Text("set app id", color = "#ffaa00", font = "6x10"), | ||
| render.Row( | ||
| children = [ | ||
| render.Text("Sales: ", color = "#fff"), | ||
| render.Text(str(0), color = "#00ff00"), | ||
| ], | ||
| ), | ||
| render.Row( | ||
| children = [ | ||
| render.Text("Wishlists: ", color = "#fff"), | ||
| render.Text(str(0), color = "#00aaff"), | ||
| ], | ||
| ), | ||
| ], | ||
| ), | ||
| ) | ||
|
|
||
| params = { | ||
| "key": api_key, | ||
| "appid": app_id, | ||
| "date": today, | ||
| "highwatermark_id": "0", | ||
| } | ||
| res = http.get(SALES_URL, params = params, ttl_seconds = 300) | ||
| if res.status_code == 200: | ||
| data = res.json()["response"] | ||
| for result in data.get("results", []): | ||
| salesData.append(result) | ||
|
|
||
| params = { | ||
| "key": api_key, | ||
| "appid": app_id, | ||
| "date": today, | ||
| } | ||
| res = http.get(WISHLIST_URL, params = params, ttl_seconds = 300) | ||
| if res.status_code == 200: | ||
| data = res.json()["response"] | ||
| for result in data.get("results", []): | ||
| wishlistData.append(result) | ||
|
|
||
| sales = 0 | ||
| wishlistAdds = 0 | ||
| for sale in salesData: | ||
| sales += sale.get("gross_units_sold", 0) | ||
| for wishlist in wishlistData: | ||
| wishlistAdds += wishlist.get("wishlist_summary", {}).get("wishlist_adds", 0) | ||
|
|
||
| return render.Root( | ||
| child = render.Column( | ||
| expanded = True, | ||
| main_align = "space_around", | ||
| cross_align = "center", | ||
| children = [ | ||
| render.Text(game_name, color = "#ffaa00", font = "6x10"), | ||
| render.Row( | ||
| children = [ | ||
| render.Text("Sales: ", color = "#fff"), | ||
| render.Text(str(sales), color = "#00ff00"), | ||
| ], | ||
| ), | ||
| render.Row( | ||
| children = [ | ||
| render.Text("Wishlists: ", color = "#fff"), | ||
| render.Text(str(wishlistAdds), color = "#00aaff"), | ||
| ], | ||
| ), | ||
| ], | ||
| ), | ||
| ) | ||
|
|
||
| def get_schema(): | ||
| return schema.Schema( | ||
| version = "1", | ||
| fields = [ | ||
| schema.Text( | ||
| id = "game_name", | ||
| name = "Game Name", | ||
| desc = "The name of your game", | ||
| icon = "gamepad", | ||
| ), | ||
| schema.Text( | ||
| id = "api_key", | ||
| name = "Steam Partner API Key", | ||
| desc = "Your IPartnerFinancialsService compatible key", | ||
| icon = "key", | ||
| secret = True, | ||
| ), | ||
| schema.Text( | ||
| id = "app_id", | ||
| name = "Steam App ID", | ||
| desc = "The App ID of your game on Steam", | ||
| icon = "gamepad", | ||
| ), | ||
| ], | ||
| ) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.