-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
125 additions
and
2 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 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 |
---|---|---|
@@ -1,2 +1,46 @@ | ||
# turnip-exchange-automator | ||
Animal Crossing turnip.exchange watcher | ||
# Introduction | ||
![](CleanShot%202021-03-15%20at%2022.57.20.gif) | ||
Animal Crossing turnip.exchange CLI, because why not?! | ||
|
||
# Description | ||
This is a CLI to search for open islands in Animal Crossing - New Horizons that are open for you to join! | ||
|
||
# Installation | ||
This package is not yet published anywhere; To install this package you'd need to clone this repository first and setup from source: | ||
|
||
``` | ||
git clone https://github.com/gcarrarom/turnip-exchange-automator.git | ||
cd turnip-exchange-automator | ||
pip install . | ||
``` | ||
|
||
After installed, you will have now the new `turnip` command in your terminal `$PATH`. | ||
|
||
## Requirements | ||
The requirements of this CLI are suppposed to be installed automatically by the installation process, but the list of packages necessary are available in the [requirements](requirements.txt) file. | ||
|
||
# Usage | ||
To get started, all you need to do is run `turnip` from the command line and that shall give you a list of islands available and their turnip prices: | ||
![](CleanShot%202021-03-15%20at%[email protected]) | ||
|
||
For more capabilities, you can always run `turnip --help`: | ||
``` | ||
turnip-exchange-automator at ☸️ docker-desktop () | ||
⌁ turnip --help | ||
Usage: turnip [OPTIONS] | ||
Options: | ||
--minimum INTEGER Minimum tulip price to show | ||
--threshold INTEGER Threshold where the price is green | ||
--watch Whether or not to watch for the islands constantly | ||
--help Show this message and exit. | ||
``` | ||
|
||
# Roadmap | ||
1. Console printout visual revamp | ||
2. Multiple output types | ||
3. Support for island notification | ||
4. Support for joining islands' queues automatically | ||
5. Support for abstracting the queueing interface completely - No more heavy page-loads | ||
6. Querying for fees (that's going to be tricky) | ||
7. Make it easier to install (Could be prioritized if someone else is using it :laugh:) |
This file contains 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,3 @@ | ||
Click | ||
cloudscraper | ||
rich |
This file contains 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,19 @@ | ||
from setuptools import setup, find_packages | ||
|
||
setup( | ||
name='turnipctl', | ||
version='0.0.1', | ||
author='Gui Martins', | ||
packages=find_packages(), | ||
include_package_data=True, | ||
py_modules=['turnipctl'], | ||
install_requires=[ | ||
'Click', | ||
'cloudscraper', | ||
'rich' | ||
], | ||
entry_points=''' | ||
[console_scripts] | ||
turnip=turnipctl:turnips | ||
''', | ||
) |
This file contains 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,57 @@ | ||
import click | ||
|
||
import cloudscraper | ||
import time | ||
from rich.table import Table | ||
from rich.console import Console | ||
|
||
@click.command() | ||
@click.option('--minimum', help="Minimum tulip price to show", default=0) | ||
@click.option('--threshold', help="Threshold where the price is green", default=300) | ||
@click.option('--watch', help="Whether or not to watch for the islands constantly", is_flag=True) | ||
def turnips(minimum, threshold, watch): | ||
scraper = cloudscraper.create_scraper() | ||
console = Console() | ||
table = Table(show_header=True, header_style="bold green") | ||
table.add_column("Name", style="dim") | ||
table.add_column("Price") | ||
table.add_column("Description") | ||
table.add_column("URL") | ||
req = scraper.post('https://api.turnip.exchange/islands/') | ||
test = req.json() | ||
prices = [[ | ||
island['turnipPrice'], | ||
island['turnipPrice'].__str__(), | ||
island['name'], | ||
island['description'], | ||
'https://turnip.exchange/island/'+island['turnipCode'] | ||
] for island in test['islands'] if island['turnipPrice'] > minimum] | ||
prices.sort(key=lambda x:x[0], reverse=True) | ||
for price in prices: | ||
table.add_row("[bold green]"+price[1]+"[/bold green]" if price[0] > threshold else "[bold red]"+price[1]+"[/bold red]", | ||
*price[2:]) | ||
console.print(table) | ||
if watch: | ||
time.sleep(10) | ||
while watch: | ||
table = Table(show_header=True, header_style="bold green") | ||
table.add_column("Name", style="dim") | ||
table.add_column("Price") | ||
table.add_column("Description") | ||
table.add_column("URL") | ||
req = scraper.post('https://api.turnip.exchange/islands/') | ||
test = req.json() | ||
prices = [[ | ||
island['turnipPrice'], | ||
island['turnipPrice'].__str__(), | ||
island['name'], | ||
island['description'], | ||
'https://turnip.exchange/island/'+island['turnipCode'] | ||
] for island in test['islands'] if island['turnipPrice'] > minimum] | ||
prices.sort(key=lambda x:x[0], reverse=True) | ||
for price in prices: | ||
table.add_row("[bold green]"+price[1]+"[/bold green]" if price[0] > threshold else "[bold red]"+price[1]+"[/bold red]", | ||
*price[2:]) | ||
console.clear() | ||
console.print(table) | ||
time.sleep(10) |