From 04abaeb1f8dc4be7c08e997d0d818e019024b0f9 Mon Sep 17 00:00:00 2001 From: Ilin Kirill Date: Mon, 4 Oct 2021 09:18:08 +0300 Subject: [PATCH 1/3] Added docker support --- Dockerfile | 7 +++++ README.md | 27 +++++++++++++++++++ .../classes/TwitchLogin.py | 7 ++++- 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..e4578fc7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM python:slim +WORKDIR /app +EXPOSE 5000 +COPY requirements.txt . +RUN pip install -r requirements.txt +COPY . . +ENTRYPOINT ["python3", "main.py"] diff --git a/README.md b/README.md index 33f26081..217cb542 100644 --- a/README.md +++ b/README.md @@ -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) @@ -283,6 +284,32 @@ 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 +``` + +>⚠️ 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 container to start automaticaly when docker starts, then change second command with the following: +``` +docker run -ti --name twitch_farmer --restart always twitch_farmer +``` + +After you 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. diff --git a/TwitchChannelPointsMiner/classes/TwitchLogin.py b/TwitchChannelPointsMiner/classes/TwitchLogin.py index d257a856..8a5577d9 100644 --- a/TwitchChannelPointsMiner/classes/TwitchLogin.py +++ b/TwitchChannelPointsMiner/classes/TwitchLogin.py @@ -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..." ) From b4334a32fce7bff41a6e28956d9e143677257b33 Mon Sep 17 00:00:00 2001 From: Ilin Kirill Date: Sat, 6 Nov 2021 20:21:10 +0300 Subject: [PATCH 2/3] Fixed mr changes --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index e4578fc7..6c2d7704 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ -FROM python:slim +FROM python WORKDIR /app EXPOSE 5000 COPY requirements.txt . RUN pip install -r requirements.txt COPY . . -ENTRYPOINT ["python3", "main.py"] +ENTRYPOINT ["python3", "run.py"] From b1b8ce8564ebb628b5b307ca80c6e3592965c0ae Mon Sep 17 00:00:00 2001 From: Ilin Kirill Date: Sat, 6 Nov 2021 21:47:59 +0300 Subject: [PATCH 3/3] Changed readme --- README.md | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 217cb542..e5d19f23 100644 --- a/README.md +++ b/README.md @@ -292,6 +292,11 @@ 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. @@ -303,13 +308,15 @@ docker run -ti --name twitch_farmer twitch_farmer > 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 +> ``` -If you want container to start automaticaly when docker starts, then change second command with the following: -``` -docker run -ti --name twitch_farmer --restart always twitch_farmer -``` -After you that you enter your 2FA token and could close the console; container will be going in background. +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.