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.2k stars 651 forks source link

question about the number of followers #294

Closed Assaf21 closed 2 years ago

Assaf21 commented 2 years ago

i have more than 100 followers and i need to load more than 100

can i ?? , if i can how

image

Tkd-Alex commented 2 years ago

Probably with the latest update we lost the ability to load more than 100 followers. Someone knows a page on Twitch where It's possible to find all the followers?

Assaf21 commented 2 years ago

that mean i cant load more than 100 in the current time

LordAsperheim commented 2 years ago

Probably with the latest update we lost the ability to load more than 100 followers. Someone knows a page on Twitch where It's possible to find all the followers?

This website "https://twitchinsights.net/followlist" show's all followers (i think), it's atleast over 100, i can confirm

Sorrow81 commented 2 years ago

The offeset are limited to 100 channel : image

The solution would be to make the first call on the first 100 items. Then look at the _total value to see if you should continue to query the next 100 items.

The solut image

Tkd-Alex commented 2 years ago

The offeset are limited to 100 channel : image

The solution would be to make the first call on the first 100 items. Then look at the _total value to see if you should continue to query the next 100 items.

The solut image

:thinking: uhm here we don't use the kraken api

Sorrow81 commented 2 years ago

Ah shame. With the twitchinsights client_id, I managed to get the users. By not forgetting to add the twitch api in the constant and replacing your client_id with theirs.

And add value to header : "Accept: application/vnd.twitchtv.v5+json"

image

Edit: I'm on "wout-helix-api" branch

Tkd-Alex commented 2 years ago

PR are welcome ^^

Rakambda commented 2 years ago

while 1 woo...

Maybe a better approach to this would be something like:

def get_followers(self, limit=100, offset=0):
    followers = {}
    json_response = <make query>
    followers += [<process response>]
    if <has next page (maybe can be when len(followers) == limit)>:
        followers += get_followers(limit, offset + limit)
    return followers

This way this is way more flexible as the limit can be changed, and doesn't have kinda "tricky" loops like while 1.

Also just something that can be investigated, but I think would be nice to have a different sort order. Like by name for example. Like that the ordering is constant and gives a sense of progression (we know that if we're at names starting by z, we're near the end).

Sorrow81 commented 2 years ago

It works. I try to do a PR during the day.

    def __do_kraken_request(self, query, response_as_json=True):
        url = f"{API}/{query.strip('/')}"
        response = self.twitch_login.session.get(url)
        logger.debug(
            f"Query: {query}, Status code: {response.status_code}, Content: {response.json()}"
        )
        return response.json() if response_as_json is True else response

    def get_followers(self, limit=100, offset=0):
        followers = []
        query = f"/kraken/users/{self.twitch_login.get_user_id()}/follows/channels?limit={limit}&direction=asc&sortby=login&offset={offset}"
        json_response = self.__do_kraken_request(query)
        followers += [i["channel"]["name"] for i in json_response["follows"]]
        if len(followers) == limit:
            followers += self.get_followers(limit, offset + limit)
        return followers

image

Users are sorted for those who are not personalised.

Tkd-Alex commented 2 years ago

i have more than 100 followers and i need to load more than 100

can i ?? , if i can how

image

Have you any chance to test this PR #341 ?