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

Show analytics of your points mining #96

Merged
merged 48 commits into from
Mar 12, 2021
Merged

Show analytics of your points mining #96

merged 48 commits into from
Mar 12, 2021

Conversation

Tkd-Alex
Copy link
Owner

@Tkd-Alex Tkd-Alex commented Feb 26, 2021

Description

You can navigate to localhost:5000 and see a chart with your points history.
We collect every update like watch, claim, prediction, etc.

The following screenshot are just an example.

Screenshot

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented on my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (README.md)
  • My changes generate no new warnings
  • Any dependent changes have been updated in requirements.txt

@dmunozv04
Copy link
Contributor

Could you add variables for the server port and listening address?

@Tkd-Alex
Copy link
Owner Author

Of course, I'll do :)

@dmunozv04
Copy link
Contributor

Of course, I'll do :)

Thanks!!

@Rakambda
Copy link
Contributor

Rakambda commented Feb 27, 2021

This doesn't work on Windows.

Traceback (most recent call last):
  File "D:\Documents\Programming\PyCharm\Twitch-Channel-Points-Miner-v2\main.py", line 33, in <module>
    twitch_miner.analytics(host="127.0.0.1", port=5000)
  File "D:\Documents\Programming\PyCharm\Twitch-Channel-Points-Miner-v2\TwitchChannelPointsMiner\TwitchChannelPointsMiner.py", line 113, in analytics
    http_server.start()
  File "C:\Python39\lib\multiprocessing\process.py", line 121, in start
    self._popen = self._Popen(self)
  File "C:\Python39\lib\multiprocessing\context.py", line 224, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "C:\Python39\lib\multiprocessing\context.py", line 327, in _Popen
    return Popen(process_obj)
  File "C:\Python39\lib\multiprocessing\popen_spawn_win32.py", line 93, in __init__
    reduction.dump(process_obj, to_child)
  File "C:\Python39\lib\multiprocessing\reduction.py", line 60, in dump
    ForkingPickler(file, protocol).dump(obj)
TypeError: cannot pickle '_thread.lock' object

Googling that error, it doesn't seem that uncommon. I don't know much about multithreading and Python, but from what I understood the problem comes from the fact that you build the app variable before starting the new thread. This then causes a problem when the new process is created as it can't serialize that variable.
Now this probably doesn't happen on UNIX systems as the way processes are forked is different?

Making that change seemed to make it work for Windows too, but I don't really know what does it imply/changes:

Index: TwitchChannelPointsMiner/classes/AnalyticsServer.py
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/TwitchChannelPointsMiner/classes/AnalyticsServer.py b/TwitchChannelPointsMiner/classes/AnalyticsServer.py
--- a/TwitchChannelPointsMiner/classes/AnalyticsServer.py	(revision acb9267c02e675f3df592d11f79882b3cf7a784e)
+++ b/TwitchChannelPointsMiner/classes/AnalyticsServer.py	(date 1614434499050)
@@ -1,5 +1,6 @@
 import logging
 import os
+import threading
 from multiprocessing import Process
 from pathlib import Path
 
@@ -34,7 +35,7 @@
     return render_template("charts.html", streamers=",".join(streamers_available()))
 
 
-class AnalyticsServer(Process):
+class AnalyticsServer(threading.Thread):
     def __init__(self, host="127.0.0.1", port=5000):
         super(AnalyticsServer, self).__init__()

@Tkd-Alex
Copy link
Owner Author

This doesn't work on Windows.

Before acb9267 , works? Or not?

@Rakambda
Copy link
Contributor

For the texts, yeah looks goo like that, it's readable.


For the apexcharts issue, seems like the solution offered here is to add

xaxis: {
    type: "datetime",
    labels: {
      datetimeUTC: false
    }
  },

They gave an example with https://codepen.io/drpuur/pen/ExaQWGx . Here the first timestamp is Sun Jan 05 2020 23:00:00 GMT+0000 and to me is rendered well as Mon Jan 06 2020 00:00:00 GMT+0100 in the browser.

I guess that this field datetimeUTC forces a date to be rendered as UTC if it is true (default?), and converts the date into the local TZ if set to false.

@Tkd-Alex
Copy link
Owner Author

https://apexcharts.com/docs/options/xaxis/
Yes datetimeUTC: true - It's the default value.

When turned on, local datetime is converted into UTC. Turn it off if you supply date with timezone info and want to preserve it.

The best solution for us, It's to use datetimeUTC: false and leave the text showed in #96 (comment)

@mrcsdl
Copy link

mrcsdl commented Mar 10, 2021

do i need to setup a apache web server or something like this? I cant get to the webpanel "ERR_CONNECTION_REFUSED"

Can someone give me a short tip how to set this up?

@Jarsa132
Copy link

Jarsa132 commented Mar 10, 2021

do i need to setup a apache web server or something like this? I cant get to the webpanel "ERR_CONNECTION_REFUSED"

Can someone give me a short tip how to set this up?

Any other webserver is not required because this project uses flask.
If you want to connect from one to second machine that have that webpanel you have to use 0.0.0.0 instead of 127.0.0.1
Make sure you gave correct port in URL (for example localhost:5000)

@Tkd-Alex
Copy link
Owner Author

Seems to be stable.
I'll merge asap, anyone has founded problems?

@Signko
Copy link
Contributor

Signko commented Mar 12, 2021

Seems to be stable.
I'll merge asap, anyone has founded problems?

I was using it for more than 4 days non-stop, no issues have been found

@Tkd-Alex Tkd-Alex merged commit 2fd04ac into master Mar 12, 2021
@diogoribeirodev
Copy link

Seems to be stable.
I'll merge asap, anyone has founded problems?

I was using it for more than 4 days non-stop, no issues have been found

you used the bot for 24 hours straight during 4 days or with intervals?

@Signko
Copy link
Contributor

Signko commented Jun 20, 2021

Seems to be stable.
I'll merge asap, anyone has founded problems?

I was using it for more than 4 days non-stop, no issues have been found

you used the bot for 24 hours straight during 4 days or with intervals?

For 24 hours straight. What's the issue?

@diogoribeirodev
Copy link

No issue at all, i just thought twitch would have some limits where it would maybe idk block your account or something.

@darkboy245
Copy link

How do you enable this on a Linux VPS?

@Tkd-Alex
Copy link
Owner Author

Tkd-Alex commented Aug 1, 2021

How do you enable this on a Linux VPS?

https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner-v2#analytics

@darkboy245
Copy link

darkboy245 commented Aug 1, 2021

How do you enable this on a Linux VPS?

https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner-v2#analytics

Yea figured it out, thanks, any way on restricting port 5000? seems a bit tricky because this is without using Apache so I can't create an htaccess file, since my VPS is public and my IP is exposed, anyone who hits my IP with port 5000 can access it.

@Tkd-Alex Tkd-Alex deleted the analytics branch March 8, 2022 16:58
@Glass47
Copy link

Glass47 commented May 27, 2022

image

@Glass47
Copy link

Glass47 commented May 27, 2022

When i add this code it just gets stuck here, can you tell me where i need to put this code, this is frustrating because I HAVE no one to talk to nor i am knowledgeable enough to google this. This is driving me crazy..

What does "For use this feature just call the analytics method before start mining" mean?

@ColinShark
Copy link
Contributor

@Glass47 Please create a new issue instead of trying to revive a long merged PR.

@invahak
Copy link

invahak commented Aug 26, 2022

help) when I added the analytics code, everything went wrong for me.
image
image

@Hotman75
Copy link

@invahak you already use the TwitchChannelPointsMiner method below the code you added.
If I am correct, you just copied the example, so you use the mine method too.
So what you need to do is just add the line twitch_miner.analytics(host="127.0.0.1", port=5000, refresh=5, days_ago=7) between the TwitchChannelPointsMiner and mine methods.

@tmaarcxs
Copy link

I can`t find how to enable the analysis panel, I have added all the code and configured everything but the log still gives me this outuput:
"[analytics]: Can't start analytics(), please set enable_analytics=True "

I don't know where to enable the flag, please help

@rdavydov
Copy link

@tmaarcxs I guess this is about my fork https://github.com/rdavydov/Twitch-Channel-Points-Miner-v2/

See the README regarding Analytics: https://github.com/rdavydov/Twitch-Channel-Points-Miner-v2/#analytics

You should set enable_analytics = True in your runner file (usually run.py).

You can use example.py from my fork as an example, or copy the contents of https://github.com/rdavydov/Twitch-Channel-Points-Miner-v2/#how-to-use

@tmaarcxs
Copy link

Thanks for your response @rdavydov, thanks to what you have told me, now it notifies that the web has been opened in the configuration that I have set, localhost:5000.
But it seems that although everything seems to be correct, when I try to enter with the browser there is no response :(

I attach the dockerfile and the file run.py
// I changed to .txt to allow github to upload it

Thanks in advance.

run.txt
docker-compose.txt

@rdavydov
Copy link

@tmaarcxs rdavydov#60

1v pushed a commit to 1v/Twitch-Channel-Points-Miner-v2 that referenced this pull request Feb 9, 2023
Add release tag on docker image
@justejules
Copy link

😣😭😭😭😭😭

25/09/23 21:06:45 - ERROR - [error]: error from callback <function WebSocketsPool.on_message at 0x7f9f8c68b0>: Error while trying to listen for a topic: {'type': 'RESPONSE', 'error': 'ERR_BADAUTH', 'nonce': 'rBaN0W0NMupQXUhf1dMoXRYzeoFe2G'} 25/09/23 21:06:45 - ERROR - [on_error]: #0 - WebSocket error: Error while trying to listen for a topic: {'type': 'RESPONSE', 'error': 'ERR_BADAUTH', 'nonce': 'rBaN0W0NMupQXUhf1dMoXRYzeoFe2G'} 25/09/23 21:06:45 - ERROR - [error]: error from callback <function WebSocketsPool.on_message at 0x7f9f8c68b0>: Error while trying to listen for a topic: {'type': 'RESPONSE', 'error': 'ERR_BADAUTH', 'nonce': '9AzIQQBHyUGvyFJzJndWCNB0Zt30hq'} 25/09/23 21:06:45 - ERROR - [on_error]: #0 - WebSocket error: Error while trying to listen for a topic: {'type': 'RESPONSE', 'error': 'ERR_BADAUTH', 'nonce': '9AzIQQBHyUGvyFJzJndWCNB0Zt30hq'}

@blacktownlad
Copy link

can somebody make a video on this for windows setup please and thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet