OGSegu / Twitch-View-Bot

First open-source really working view bot for Twitch
MIT License
65 stars 40 forks source link

Not working. #9

Closed vitalya420 closed 3 years ago

vitalya420 commented 3 years ago

If i trying to display a content of sequence, i have sequense "Commercial break in progress"

youtubeLiveStreamBot commented 3 years ago

If i trying to display a content of sequence, i have sequense "Commercial break in progress"

how do you run the code in windows bro ? pls help me

vitalya420 commented 3 years ago

If i trying to display a content of sequence, i have sequense "Commercial break in progress"

how do you run the code in windows bro ? pls help me

i rewrited in python

OGSegu commented 3 years ago

Could you give me more information, please?

kemalzeybek commented 3 years ago

@vitalya420 can you share your code?

vitalya420 commented 3 years ago

Could you give me more information, please?

  • What request do you use to get the sequence?

My python function:

    def get_video_sequence(self) -> str:
        info = self.get_info()
        response = requests.get(
            f"https://usher.ttvnw.net/api/channel/hls/{self._target_channel}.m3u8?"
            f"allow_source=true&baking_bread=true&baking_brownies=true&baking_brownies_timeout=1050&"
            f"fast_bread=true&p={random.randint(1, int(1E7))}&player_backend=mediaplayer&"
            f"playlist_include_framerate=true&reassignments_supported=false&rtqos=business_logic_reverse&cdm=wv&sig={info[1]}&token={info[0]}",
            headers={
                "User-Agent": self._user_agent,
                "Accept": "application/x-mpegURL, application/vnd.apple.mpegurl, application/json, text/plain",
                }
            ).text
        return response.split('\n')[-1]

returns something like https://video-weaver.waw01.hls.ttvnw.net/v1/playlist/CvID_E2wMSWek8Mk9oOnIfX_Wq9BhmsAFMMkEpVDytz9mR7SQtaIczgWdxvebwkfZsD7PGttuT5KvOg-IrLfDKsBwwcM2Q14N5EGTIFiuNP_394DIs9K80brk36eQmAUDMP1r-Egs02DxaGmU9EcQ6QVT4CcjZO2p5tiWbFxo8IftS1LwUKYd0lu4N0qnyyRb5KfPkmxQOw-IqJ9VfUOgE0gMkXDYUFCJDmO0vM21V4HTnVnJuhvjNhf-sP8EfySE2d7x3H3t3YKPBjD8nvwrjxktc9FQrjN2VhbjdZDOHb6nUMqg2RI_lLOBSCGy7v_i3LPgt_qRgkk7PrY5liWWXyE-Brt1JpqUYGbzTic7eO-0R8HHdcFGqXquM4QFgQfzqd3RyRe9Z2W_9J4QZTML1p2EkRnhpuSx3_h3QYE9eeH6Jnv61NXn53HnQj6COMOIDik1Hz0ITbbTqkWJT5Sr0wQA7Y0vReAc8_JISzPdIoFtenZUyghQyBGqe4CBw3-ZDbDfSlq-HcIw8tZDUXO0DnnMn-UhEmwWAZ5hxxe1gLnIayzNL48onuQxuIZrltg_MbpKbov-a7I9zdj8CEJ-UiZxm3IuunazLrf5RVTvemG5wkZretP85uzjEGiwAXyPscykSe5utjbLwBTPhsq_3gJwvoAEhCw6hjBBNs5DxQWeWKRBvq9GgxV7sfxpzzbVKVigRA.m3u8

If i download and open this sometime it will shows "Commercial break in progress" image

vitalya420 commented 3 years ago

@vitalya420 can you share your code?


import time
from fake_useragent import UserAgent
import requests
import random
from threading import Thread

class ViewBot(Thread): def init(self, client_id, target_channel, proxy=None): super().init() self._client_id = client_id self._target_channel = target_channel self._user_agent = UserAgent().safari self._proxy = { "http": f"socks4://{proxy}", "https": f"socks4://{proxy}" } def get_info(self) -> tuple: response = requests.get( f"https://api.twitch.tv/api/channels/{self._target_channel}/access_token?" f"client_id={self._client_id}", headers={ "User-Agent": self._user_agent, "Accept": "application/vnd.twitchtv.v5+json; charset=UTF-8", "Content-Type": "application/json; charset=UTF-8", "Accept-Language": "en-us", "Referer": "https://www.twitch.tv/" + self._target_channel },

proxies=self._proxy

    ).json()
    return response["token"], response["sig"]

def get_video_sequence(self) -> str:
    info = self.get_info()
    response = requests.get(
        f"https://usher.ttvnw.net/api/channel/hls/{self._target_channel}.m3u8?"
        f"allow_source=true&baking_bread=true&baking_brownies=true&baking_brownies_timeout=1050&"
        f"fast_bread=true&p={random.randint(1, int(1E7))}&player_backend=mediaplayer&"
        f"playlist_include_framerate=true&reassignments_supported=false&rtqos=business_logic_reverse&cdm=wv&sig={info[1]}&token={info[0]}",
        headers={
            "User-Agent": self._user_agent,
            "Accept": "application/x-mpegURL, application/vnd.apple.mpegurl, application/json, text/plain",
            }
        ).text
    return response.split('\n')[-1]

def send_view(self, sequence_url: str) -> bool:
    try:
        response = requests.head(
            sequence_url,
            headers={
                "User-Agent": self._user_agent,
                "Accept": "application/x-mpegURL, application/vnd.apple.mpegurl, application/json, text/plain",
            }
        )
    except requests.exceptions.ConnectionError as exc:
        return False
    return response.status_code == 200

def run(self):
    while True:
        sequence = self.get_video_sequence()
        if sequence == "":
            break
        print(self.send_view(sequence))
        time.sleep(0.1)
OGSegu commented 3 years ago

Could you give me more information, please?

  • What request do you use to get the sequence?

My python function:

    def get_video_sequence(self) -> str:
        info = self.get_info()
        response = requests.get(
            f"https://usher.ttvnw.net/api/channel/hls/{self._target_channel}.m3u8?"
            f"allow_source=true&baking_bread=true&baking_brownies=true&baking_brownies_timeout=1050&"
            f"fast_bread=true&p={random.randint(1, int(1E7))}&player_backend=mediaplayer&"
            f"playlist_include_framerate=true&reassignments_supported=false&rtqos=business_logic_reverse&cdm=wv&sig={info[1]}&token={info[0]}",
            headers={
                "User-Agent": self._user_agent,
                "Accept": "application/x-mpegURL, application/vnd.apple.mpegurl, application/json, text/plain",
                }
            ).text
        return response.split('\n')[-1]

returns something like https://video-weaver.waw01.hls.ttvnw.net/v1/playlist/CvID_E2wMSWek8Mk9oOnIfX_Wq9BhmsAFMMkEpVDytz9mR7SQtaIczgWdxvebwkfZsD7PGttuT5KvOg-IrLfDKsBwwcM2Q14N5EGTIFiuNP_394DIs9K80brk36eQmAUDMP1r-Egs02DxaGmU9EcQ6QVT4CcjZO2p5tiWbFxo8IftS1LwUKYd0lu4N0qnyyRb5KfPkmxQOw-IqJ9VfUOgE0gMkXDYUFCJDmO0vM21V4HTnVnJuhvjNhf-sP8EfySE2d7x3H3t3YKPBjD8nvwrjxktc9FQrjN2VhbjdZDOHb6nUMqg2RI_lLOBSCGy7v_i3LPgt_qRgkk7PrY5liWWXyE-Brt1JpqUYGbzTic7eO-0R8HHdcFGqXquM4QFgQfzqd3RyRe9Z2W_9J4QZTML1p2EkRnhpuSx3_h3QYE9eeH6Jnv61NXn53HnQj6COMOIDik1Hz0ITbbTqkWJT5Sr0wQA7Y0vReAc8_JISzPdIoFtenZUyghQyBGqe4CBw3-ZDbDfSlq-HcIw8tZDUXO0DnnMn-UhEmwWAZ5hxxe1gLnIayzNL48onuQxuIZrltg_MbpKbov-a7I9zdj8CEJ-UiZxm3IuunazLrf5RVTvemG5wkZretP85uzjEGiwAXyPscykSe5utjbLwBTPhsq_3gJwvoAEhCw6hjBBNs5DxQWeWKRBvq9GgxV7sfxpzzbVKVigRA.m3u8

If i download and open this sometime it will shows "Commercial break in progress" image

I don't think this is a problem. Every "real" viewer gets adverts and we are not an exception.

vitalya420 commented 3 years ago

I don't think this is a problem. Every "real" viewer gets adverts and we are not an exception.

Sure, they gets, but i don't get my fake viewers from head requests, because i'm still getting an ad sequense, maybe i should skip an ad, how to make this. I made my python script using your Java code, for building open source web app in future.

OGSegu commented 3 years ago

I think we can try to figure out how we can bypass the ads. Thanks for your contribution. Probably need to do some researchs to check if ads really interfere with the bot work

kamuran21 commented 3 years ago

on some stream, there are no ads but still view count did not increse.

kamuran21 commented 3 years ago

a new info. Twitch blocks ips. i tried with private proxies it works. but twitch blocked ips in 15 munites.

OGSegu commented 3 years ago

a new info. Twitch blocks ips. i tried with private proxies it works. but twitch blocked ips in 15 munites.

Seems like it's true. The very first usage of proxies gives a good amount of viewers but after 10-15 minutes, they don't work at all. Probably they also block Client-ID activity for some time, if they find it suspicious.

nick0zer commented 3 years ago

Only residential or mobile(very expensive) proxies work for stable viewers for twitch. For datacenter proxies to work, you need a big list of proxies and a small number of threads on your bot. If your bot sends too many requests very fast, all proxies will get flagged down and won't count as viewers for some time. You still can make 300-500 viewers stable with datacenter proxies but you need the correct setup(viewbot) and around 20k datacenter proxies. All tested

nick0zer commented 3 years ago

Maybe a solution is to build up viewers slowly, for example for every 5 minutes the bot adds 50 viewers to the stream.