Skip to content
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

Added docker support #300

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM python
WORKDIR /app
EXPOSE 5000
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
ENTRYPOINT ["python3", "run.py"]
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Currently, we have a lot of PRs requests opened, but the time to test and improv
- [Final report](#final-report)
4. 🧐 [How to use](#how-to-use)
- [Limits](#limits)
- [With Docker (advanced)](#docker)
5. 🔧 [Settings](#settings)
- [LoggerSettings](#loggersettings)
- [StreamerSettings](#streamersettings)
Expand Down Expand Up @@ -283,6 +284,39 @@ twitch_miner.mine(followers=True, blacklist=["user1", "user2"]) # Blacklist exa

Make sure to write the streamers array in order of priority from left to right. If you use `followers=True` Twitch return the streamers order by followed_at. So your last follow has the highest priority.

### With Docker (advanced)
***You have to have docker installed and configured.***
You can start miner in docker container with these commands from the root project folder:
```
docker build -t=twitch_farmer .
docker run -ti --name twitch_farmer twitch_farmer
```

If you want container to start automaticaly when docker starts, then add `--restart always` to the command:
```
docker run -ti --name twitch_farmer --restart always twitch_farmer
```

>⚠️ Warning
>
> If you are using analytics server you have to configure it on `5000` port and `"0.0.0.0"` ip address.
> ```python
> twitch_miner.analytics(host="0.0.0.0", port=5000, refresh=5)
> ```
> If you want to use another port on your computer, you should bind it in `docker run` command via `p` argument.
> ```
> docker run -ti -p1234:5000 --name twitch_farmer twitch_farmer
> ```
> Analytics server will be available on computer at `1234` port in this example.
>
> If you want to persist your analytics data you should mount analytics directory. For example: `-v /opt/twitch_farmer/analytics:/app/analytics`.
> Your full command will look something like that:
> ```
> docker run -p5004:5000 -ti --name twitch_farmer -v /opt/twitch_farmer/analytics:/app/analytics --restart always twitch_farmer
> ```


After that you enter your 2FA token and could close the console; container will be going in background.
## Settings
Most of the settings are self-explained and are commented on in the example.
You can watch only two streamers per time. With `priority` settings, you can select which streamers watch by use priority. You can use an array of priority or single item. I suggest using at least one priority from `ORDER`, `POINTS_ASCENDING`, `POINTS_DESCEDING` because, for example, If you set only `STREAK` after catch all watch streak, the script will stop to watch streamers.
Expand Down
7 changes: 6 additions & 1 deletion TwitchChannelPointsMiner/classes/TwitchLogin.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,15 @@ def login_flow_backup(self):
browser = input(
"What browser do you use? Chrome (1), Firefox (2), Other (3): "
).strip()
if browser not in ("1", "2"):
if browser not in ("1", "2", "3"):
logger.info("Your browser is unsupported, sorry.")
return None

if browser == "3":
logger.info("Login through your browser and enter cookie values manually")
self.username = input("login: ").strip()
return input("auth-token: ").strip()

input(
"Please login inside your browser of choice (NOT incognito mode) and press Enter..."
)
Expand Down