Skip to content

Commit

Permalink
Add ATH and ATL
Browse files Browse the repository at this point in the history
  • Loading branch information
fedecalendino committed Oct 13, 2022
1 parent b1b929a commit 8d9f605
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 22 deletions.
30 changes: 16 additions & 14 deletions info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<array>
<dict>
<key>destinationuid</key>
<string>808B9B88-6980-4FA1-844D-E46135557FE1</string>
<string>82A09523-8EB2-4E80-9377-D39E096E7341</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
Expand All @@ -25,7 +25,7 @@
<array>
<dict>
<key>destinationuid</key>
<string>808B9B88-6980-4FA1-844D-E46135557FE1</string>
<string>82A09523-8EB2-4E80-9377-D39E096E7341</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
Expand Down Expand Up @@ -97,21 +97,23 @@
<dict>
<key>config</key>
<dict>
<key>autopaste</key>
<false/>
<key>clipboardtext</key>
<string>{query}</string>
<key>ignoredynamicplaceholders</key>
<key>browser</key>
<string></string>
<key>skipqueryencode</key>
<false/>
<key>transient</key>
<key>skipvarencode</key>
<false/>
<key>spaces</key>
<string></string>
<key>url</key>
<string>{query}</string>
</dict>
<key>type</key>
<string>alfred.workflow.output.clipboard</string>
<string>alfred.workflow.action.openurl</string>
<key>uid</key>
<string>808B9B88-6980-4FA1-844D-E46135557FE1</string>
<string>82A09523-8EB2-4E80-9377-D39E096E7341</string>
<key>version</key>
<integer>3</integer>
<integer>1</integer>
</dict>
<dict>
<key>config</key>
Expand Down Expand Up @@ -189,10 +191,10 @@ For example:
<key>ypos</key>
<real>15</real>
</dict>
<key>808B9B88-6980-4FA1-844D-E46135557FE1</key>
<key>82A09523-8EB2-4E80-9377-D39E096E7341</key>
<dict>
<key>xpos</key>
<real>280</real>
<real>270</real>
<key>ypos</key>
<real>115</real>
</dict>
Expand Down Expand Up @@ -229,7 +231,7 @@ For example:
</dict>
</array>
<key>version</key>
<string>1.6.0</string>
<string>1.7.0</string>
<key>webaddress</key>
<string>https://github.com/fedecalendino/alfred-crypto-prices</string>
</dict>
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "Crypto Prices"
version = "1.6.0"
version = "1.7.0"
description = "Get current prices for cryptocurrencies"
documentation = "https://github.com/fedecalendino/alfred-crypto-prices/blob/main/README.md"
homepage = "https://github.com/fedecalendino/alfred-crypto-prices"
Expand Down
5 changes: 4 additions & 1 deletion src/coingecko.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ def get_coins(*ids):
"img": coin["image"],
"url": f'https://www.coingecko.com/en/coins/{coin["id"]}',
"price": coin["current_price"],
"change": coin["price_change_percentage_24h"],
"price_change": coin["price_change_percentage_24h"],
"atl": coin["atl"],
"atl_change": coin["atl_change_percentage"],
"ath": coin["ath"],
"ath_change": coin["ath_change_percentage"],
}


Expand Down
20 changes: 14 additions & 6 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def main(workflow):
if not args:
ids = workflow.env.get("FAVORITES", "").split("\n")
coins = coingecko.get_coins(*ids)
sort_by = "change"
sort_by = "price_change"
sort_dir = "desc"
elif args == ["marketcap"]:
coins = coingecko.get_coins()
Expand All @@ -28,17 +28,15 @@ def main(workflow):
)

for coin in coins:
price = coin["price"]

title = "{rank} 路 {symbol} [{price} USD]".format(
rank=coin["rank"],
symbol=coin["symbol"].upper(),
name=coin["name"],
price=formatters.price(price),
price=formatters.price(coin["price"]),
)

subtitle = "24h change: {change}".format(
change=formatters.percent(coin["change"]),
subtitle = "24H: {change}".format(
change=formatters.percent(coin["price_change"]),
)

workflow.new_item(
Expand All @@ -49,6 +47,16 @@ def main(workflow):
).set_icon_url(
url=coin["img"],
filename=f"{coin['name']}.png".lower(),
).set_alt_mod(
subtitle="ATL: {price} / {change}".format(
price=formatters.price(coin["atl"]),
change=formatters.percent(coin["atl_change"]),
),
).set_cmd_mod(
subtitle="ATH: {price} / {change}".format(
price=formatters.price(coin["ath"]),
change=formatters.percent(coin["ath_change"]),
),
)


Expand Down

0 comments on commit 8d9f605

Please sign in to comment.