Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
gcarrarom committed Mar 16, 2021
1 parent b233fa7 commit 6bc1495
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 2 deletions.
Binary file added CleanShot 2021-03-15 at [email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added CleanShot 2021-03-15 at 22.57.20.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 46 additions & 2 deletions README.md
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:)
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Click
cloudscraper
rich
19 changes: 19 additions & 0 deletions setup.py
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
''',
)
57 changes: 57 additions & 0 deletions turnipctl.py
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)

0 comments on commit 6bc1495

Please sign in to comment.