Tkd-Alex / Twitch-Channel-Points-Miner-v2

A simple script that will watch a stream for you and earn the channel points.
GNU General Public License v3.0
1.22k stars 679 forks source link

Analytics don't load sometimes #468

Open aVitomin opened 2 years ago

aVitomin commented 2 years ago

Analytics don't load sometimes, need refresh around 5-10 times for init it correctly

cfg

# -*- coding: utf-8 -*-

import logging
from colorama import Fore
from TwitchChannelPointsMiner import TwitchChannelPointsMiner
from TwitchChannelPointsMiner.logger import LoggerSettings, ColorPalette
from TwitchChannelPointsMiner.classes.Chat import ChatPresence
from TwitchChannelPointsMiner.classes.Settings import Priority, Events, FollowersOrder
from TwitchChannelPointsMiner.classes.entities.Bet import Strategy, BetSettings, Condition, OutcomeKeys, FilterCondition, DelayMode
from TwitchChannelPointsMiner.classes.entities.Streamer import Streamer, StreamerSettings

twitch_miner = TwitchChannelPointsMiner(
    username="***",
    password="***",                        # If no password will be provided, the script will ask interactively
    claim_drops_startup=True,                       # If you want to auto claim all drops from Twitch inventory on the startup
    priority=[                                      # Custom priority in this case for example:
        Priority.STREAK,                            # - We want first of all to catch all watch streak from all streamers
        Priority.DROPS,                             # - When we don't have anymore watch streak to catch, wait until all drops are collected over the streamers
        Priority.SUBSCRIBED,                        # - Prioritize streamers you're subscribed to (higher subscription tiers are mined first)
        Priority.ORDER                              # - When we have all of the drops claimed and no watch-streak available, use the order priority (POINTS_ASCENDING, POINTS_DESCEDING)
    ],
    logger_settings=LoggerSettings(
        save=True,                                  # If you want to save logs in a file (suggested)
        console_level=logging.INFO,                 # Level of logs - use logging.DEBUG for more info
        file_level=logging.DEBUG,                   # Level of logs - If you think the log file it's too big, use logging.INFO
        emoji=False,                                # On Windows, we have a problem printing emoji. Set to false if you have a problem
        less=True,                                  # If you think that the logs are too verbose, set this to True
        colored=True,                               # If you want to print colored text
        color_palette=ColorPalette(                 # You can also create a custom palette color (for the common message).
            TREAMER_ONLINE = Fore.GREEN,            # Don't worry about lower/upper case. The script will parse all the values.
            STREAMER_OFFLINE = Fore.RED,            # Read more in README.md
            GAIN_FOR_RAID = Fore.YELLOW,            # Color allowed are: [BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, RESET].
            GAIN_FOR_CLAIM = Fore.YELLOW,           # Color allowed are: [BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, RESET].
            GAIN_FOR_WATCH = Fore.YELLOW,           # Color allowed are: [BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, RESET].
            GAIN_FOR_WATCH_STREAK = Fore.YELLOW,    # Color allowed are: [BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, RESET].
            BET_WIN = Fore.GREEN,                   # Color allowed are: [BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, RESET].
            BET_LOSE = Fore.RED,                    # Color allowed are: [BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, RESET].
            BET_REFUND = Fore.RESET,                # Color allowed are: [BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, RESET].
            BET_FILTERS = Fore.MAGENTA,             # Color allowed are: [BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, RESET].
            BET_GENERAL = Fore.BLUE,                # Color allowed are: [BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, RESET].
            BET_FAILED = Fore.RED                   # Color allowed are: [BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, RESET].
        )
    ),
    streamer_settings=StreamerSettings(
        make_predictions=True,                      # If you want to Bet / Make prediction
        follow_raid=True,                           # Follow raid to obtain more points
        claim_drops=True,                           # We can't filter rewards base on stream. Set to False for skip viewing counter increase and you will never obtain a drop reward from this script. Issue #21
        watch_streak=True,                          # If a streamer go online change the priority of streamers array and catch the watch screak. Issue #11
        chat=ChatPresence.ONLINE,                   # Join irc chat to increase watch-time [ALWAYS, NEVER, ONLINE, OFFLINE]
        bet=BetSettings(
            strategy=Strategy.SMART,                # Choose you strategy!
            percentage=2,                           # Place the x% of your channel points
            percentage_gap=20,                      # Gap difference between outcomesA and outcomesB (for SMART strategy)
            max_points=50000,                       # If the x percentage of your channel points is gt bet_max_points set this value
            stealth_mode=True,                      # If the calculated amount of channel points is GT the highest bet, place the highest value minus 1-2 points Issue #33
            delay_mode=DelayMode.FROM_END,          # When placing a bet, we will wait until `delay` seconds before the end of the timer
            delay=6
        )
    )
)

# You can customize the settings for each streamer. If not settings were provided, the script would use the streamer_settings from TwitchChannelPointsMiner.
# If no streamer_settings are provided in TwitchChannelPointsMiner the script will use default settings.
# The streamers array can be a String -> username or Streamer instance.

# The settings priority are: settings in mine function, settings in TwitchChannelPointsMiner instance, default settings.
# For example, if in the mine function you don't provide any value for 'make_prediction' but you have set it on TwitchChannelPointsMiner instance, the script will take the value from here.
# If you haven't set any value even in the instance the default one will be used

twitch_miner.analytics(                             # Analytics web-server
    host="0.0.0.0",                                 # Web-server host IP
    port=5000,                                      # Web-server port
    refresh=1,                                      # Analytics logs refresh rate
    days_ago=7                                      # Analytics graph days show
)

twitch_miner.mine(
    followers=True,                                 # Automatic download the list of your followers
    followers_order=FollowersOrder.ASC              # Sort the followers list by follow date. ASC or DESC
)

screenshots: image image

OVH vps Ubuntu 21 Python 3.9.7 Startup with pm2 sudo pm2 start run.py --interpreter=python3 --name twitch

Any way to fix it ?

Zaffaci commented 2 years ago

From the network tab on the web developer tools i found an error 404 for /assets/script.js that contains the analytics script for the graph. I tried to replace it with a new one from the repository but at the second execution again the same problem

aVitomin commented 2 years ago

From the network tab on the web developer tools i found an error 404 for /assets/script.js that contains the analytics script for the graph. I tried to replace it with a new one from the repository but at the second execution again the same problem

image yeah, same

4x10m commented 2 years ago

Temporary solution is to clear cache ?!

Tkd-Alex commented 2 years ago

Never had this issue :thinking: