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

Valid main code #63

Open
NjProVk opened this issue Jan 9, 2022 · 23 comments
Open

Valid main code #63

NjProVk opened this issue Jan 9, 2022 · 23 comments

Comments

@NjProVk
Copy link

NjProVk commented Jan 9, 2022

"""
   Update from NjProVk
"""

import requests
from streamlink import Streamlink
import sys
import time
import random
from random import shuffle
from fake_useragent import UserAgent
import linecache

from threading import Thread

channel_urls = f"https://www.twitch.tv/{sys.argv[1]}"
proxies_file = "Proxies_txt/good_proxy.txt"
processes = []
max_nb_of_threads = int(sys.argv[2])

all_proxies = []
nb_of_proxies = 0

# Session creating for request
ua = UserAgent()
session = Streamlink()
session.set_option("http-headers", {'User-Agent': ua.random, "Client-ID": "ewvlchtxgqq88ru9gmfp1gmyt6h2b93"})

class ViewerBot:
    def print_exception(self):
        exc_type, exc_obj, tb = sys.exc_info()
        f = tb.tb_frame
        lineno = tb.tb_lineno
        filename = f.f_code.co_filename
        linecache.checkcache(filename)
        line = linecache.getline(filename, lineno, f.f_globals)
        print('EXCEPTION IN ({}, LINE {} "{}"): {}'.format(filename, lineno, line.strip(), exc_obj))



    def get_proxies(self):
        # Reading the list of proxies
        global nb_of_proxies
        try:
            lines = [line.rstrip("\n") for line in open(proxies_file)]
        except IOError as e:
            print("An error has occurred while trying to read the list of proxies: %s" % e.strerror)
            sys.exit(1)

        nb_of_proxies = len(lines)
        return lines


    def get_url(self):
        url = ""
        try:
            streams = session.streams(self.channel_url)
            try:
                url = streams['audio_only'].url
                print(f"URL : {url[:30]}...\n")
            except:
                url = streams['worst'].url
                print(f"URL : {url[:30]}...\n")

        except:
            pass
        return url

    def open_url(self,proxy_data):
        try:
            global all_proxies
            headers = {'User-Agent': ua.random}
            current_index = all_proxies.index(proxy_data)

            if proxy_data['url'] == "":
                proxy_data['url'] = self.get_url()
            current_url = proxy_data['url']
            try:
                if time.time() - proxy_data['time'] >= random.randint(1, 5):
                    current_proxy = {"http": f"https://{proxy_data['proxy']}", "https": f"http://{proxy_data['proxy']}"}
                    with requests.Session() as s:
                        response = s.head(current_url, proxies=current_proxy, headers=headers)
                    print(f"Sent HEAD request with {current_proxy['http']} | {response.status_code} | {response.request} | {response}")
                    proxy_data['time'] = time.time()
                    all_proxies[current_index] = proxy_data
            except:
                print("Connection Error!")

        except (KeyboardInterrupt, SystemExit):
            sys.exit()


    def mainmain(self):
        self.channel_url = channel_urls
        proxies = self.get_proxies()

        for p in proxies:
            all_proxies.append({'proxy': p, 'time': time.time(), 'url': ""})

        shuffle(all_proxies)
        list_of_all_proxies = all_proxies
        current_proxy_index = 0

        while True:
            try:
                for i in range(0, max_nb_of_threads):
                    threaded = Thread(target=self.open_url, args=(all_proxies[random.randint(0, len(all_proxies))],))
                    threaded.daemon = True  # This thread dies when main thread (only non-daemon thread) exits.
                    threaded.start()
            except:
                self.print_exception()
            shuffle(all_proxies)
            time.sleep(5)


ViewerBot = ViewerBot()
ViewerBot.mainmain()

image

@NjProVk
Copy link
Author

NjProVk commented Jan 9, 2022

It cod worked on 100%

Example: python3 threads_viewer.py CHANELNAME COUNT

@NjProVk NjProVk changed the title Valid Main cod Valid main code Jan 9, 2022
@zerodoxxx
Copy link

zerodoxxx commented Jan 19, 2022

Not able to install requirements fully, getting some error related to streamlink. Can you share a step-by-step guide on how to use it. Thanks in advance! getting this error
image

@NjProVk
Copy link
Author

NjProVk commented Jan 26, 2022

Not able to install requirements fully, getting some error related to streamlink. Can you share a step-by-step guide on how to use it. Thanks in advance! getting this error image

fake-useragent==0.1.11
requests>=2.21.0
streamlink==1.0.0

Use command in console:
pip install fake-useragent==0.1.11
pip install requests>=2.21.0
pip install streamlink==1.0.0

Or install:
pip3 install fake-useragent==0.1.11
pip3 install requests>=2.21.0
pip3 install streamlink==1.0.0

The error field says that you do not have python installed!

@zoptein
Copy link

zoptein commented Jan 28, 2022

"""
   Update from NjProVk
"""

import requests
from streamlink import Streamlink
import sys
import time
import random
from random import shuffle
from fake_useragent import UserAgent
import linecache

from threading import Thread

channel_urls = f"https://www.twitch.tv/{sys.argv[1]}"
proxies_file = "Proxies_txt/good_proxy.txt"
processes = []
max_nb_of_threads = int(sys.argv[2])

all_proxies = []
nb_of_proxies = 0

# Session creating for request
ua = UserAgent()
session = Streamlink()
session.set_option("http-headers", {'User-Agent': ua.random, "Client-ID": "ewvlchtxgqq88ru9gmfp1gmyt6h2b93"})

class ViewerBot:
    def print_exception(self):
        exc_type, exc_obj, tb = sys.exc_info()
        f = tb.tb_frame
        lineno = tb.tb_lineno
        filename = f.f_code.co_filename
        linecache.checkcache(filename)
        line = linecache.getline(filename, lineno, f.f_globals)
        print('EXCEPTION IN ({}, LINE {} "{}"): {}'.format(filename, lineno, line.strip(), exc_obj))



    def get_proxies(self):
        # Reading the list of proxies
        global nb_of_proxies
        try:
            lines = [line.rstrip("\n") for line in open(proxies_file)]
        except IOError as e:
            print("An error has occurred while trying to read the list of proxies: %s" % e.strerror)
            sys.exit(1)

        nb_of_proxies = len(lines)
        return lines


    def get_url(self):
        url = ""
        try:
            streams = session.streams(self.channel_url)
            try:
                url = streams['audio_only'].url
                print(f"URL : {url[:30]}...\n")
            except:
                url = streams['worst'].url
                print(f"URL : {url[:30]}...\n")

        except:
            pass
        return url

    def open_url(self,proxy_data):
        try:
            global all_proxies
            headers = {'User-Agent': ua.random}
            current_index = all_proxies.index(proxy_data)

            if proxy_data['url'] == "":
                proxy_data['url'] = self.get_url()
            current_url = proxy_data['url']
            try:
                if time.time() - proxy_data['time'] >= random.randint(1, 5):
                    current_proxy = {"http": f"https://{proxy_data['proxy']}", "https": f"http://{proxy_data['proxy']}"}
                    with requests.Session() as s:
                        response = s.head(current_url, proxies=current_proxy, headers=headers)
                    print(f"Sent HEAD request with {current_proxy['http']} | {response.status_code} | {response.request} | {response}")
                    proxy_data['time'] = time.time()
                    all_proxies[current_index] = proxy_data
            except:
                print("Connection Error!")

        except (KeyboardInterrupt, SystemExit):
            sys.exit()


    def mainmain(self):
        self.channel_url = channel_urls
        proxies = self.get_proxies()

        for p in proxies:
            all_proxies.append({'proxy': p, 'time': time.time(), 'url': ""})

        shuffle(all_proxies)
        list_of_all_proxies = all_proxies
        current_proxy_index = 0

        while True:
            try:
                for i in range(0, max_nb_of_threads):
                    threaded = Thread(target=self.open_url, args=(all_proxies[random.randint(0, len(all_proxies))],))
                    threaded.daemon = True  # This thread dies when main thread (only non-daemon thread) exits.
                    threaded.start()
            except:
                self.print_exception()
            shuffle(all_proxies)
            time.sleep(5)


ViewerBot = ViewerBot()
ViewerBot.mainmain()

image

teach me how to use it

@zoptein
Copy link

zoptein commented Jan 28, 2022

teach me how to use it bro pls

@zoptein
Copy link

zoptein commented Jan 28, 2022

who makes a video please my head hurts I already did everything it doesn't work for me please

@zerodoxxx
Copy link

zerodoxxx commented Jan 28, 2022

Not able to install requirements fully, getting some error related to streamlink. Can you share a step-by-step guide on how to use it. Thanks in advance! getting this error image

fake-useragent==0.1.11 requests>=2.21.0 streamlink==1.0.0

Use command in console: pip install fake-useragent==0.1.11 pip install requests>=2.21.0 pip install streamlink==1.0.0

Or install: pip3 install fake-useragent==0.1.11 pip3 install requests>=2.21.0 pip3 install streamlink==1.0.0

The error field says that you do not have python installed!

I ran it using Anaconda command prompt, python should be considered installed i guess? Let me try what you've mentioned. Thanks!

@NjProVk
Copy link
Author

NjProVk commented Jan 28, 2022

teach me how to use it bro pls

Copy cod and paste in file threads_viewer.py and run!

@zerodoxxx
Copy link

Not able to install requirements fully, getting some error related to streamlink. Can you share a step-by-step guide on how to use it. Thanks in advance! getting this error image

fake-useragent==0.1.11 requests>=2.21.0 streamlink==1.0.0

Use command in console: pip install fake-useragent==0.1.11 pip install requests>=2.21.0 pip install streamlink==1.0.0

Or install: pip3 install fake-useragent==0.1.11 pip3 install requests>=2.21.0 pip3 install streamlink==1.0.0

The error field says that you do not have python installed!

Getting "Connection error" now, any idea why?
image

@NjProVk
Copy link
Author

NjProVk commented Jan 28, 2022

What proxies are you using?
The code I posted uses http(s)

@zoptein
Copy link

zoptein commented Jan 28, 2022

What proxies are you using?
The code I posted uses http(s)

whenever it executed the normal code it redirects me what do i do

@zoptein
Copy link

zoptein commented Jan 28, 2022

teach me how to use it bro pls

Copy cod and paste in file threads_viewer.py and run!

I already did everything I downloaded all the libraries everything at the time of executing it in its folder it executed it and it redirects me to a program I don't know what to do there

@zerodoxxx
Copy link

What proxies are you using? The code I posted uses http(s)

Tried changing the proxies to working proxies in India, now i am getting this:
image

@zoptein
Copy link

zoptein commented Jan 28, 2022

What proxies are you using? The code I posted uses http(s)

Tried changing the proxies to working proxies in India, now i am getting this:
image

you explain to me how to use it better it is not well explained I have all the requirements and VLC I do not know what I am missing it ran and sends me a link to open with a program

@zoptein
Copy link

zoptein commented Jan 28, 2022

I already learned a lot, thank you, only the proxies are missing, I recommend that we make this use cookies so that the proxies are not railings, and thank you very much for your attention

@zoptein
Copy link

zoptein commented Jan 28, 2022

"""
   Update from NjProVk
"""

import requests
from streamlink import Streamlink
import sys
import time
import random
from random import shuffle
from fake_useragent import UserAgent
import linecache

from threading import Thread

channel_urls = f"https://www.twitch.tv/{sys.argv[1]}"
proxies_file = "Proxies_txt/good_proxy.txt"
processes = []
max_nb_of_threads = int(sys.argv[2])

all_proxies = []
nb_of_proxies = 0

# Session creating for request
ua = UserAgent()
session = Streamlink()
session.set_option("http-headers", {'User-Agent': ua.random, "Client-ID": "ewvlchtxgqq88ru9gmfp1gmyt6h2b93"})

class ViewerBot:
    def print_exception(self):
        exc_type, exc_obj, tb = sys.exc_info()
        f = tb.tb_frame
        lineno = tb.tb_lineno
        filename = f.f_code.co_filename
        linecache.checkcache(filename)
        line = linecache.getline(filename, lineno, f.f_globals)
        print('EXCEPTION IN ({}, LINE {} "{}"): {}'.format(filename, lineno, line.strip(), exc_obj))



    def get_proxies(self):
        # Reading the list of proxies
        global nb_of_proxies
        try:
            lines = [line.rstrip("\n") for line in open(proxies_file)]
        except IOError as e:
            print("An error has occurred while trying to read the list of proxies: %s" % e.strerror)
            sys.exit(1)

        nb_of_proxies = len(lines)
        return lines


    def get_url(self):
        url = ""
        try:
            streams = session.streams(self.channel_url)
            try:
                url = streams['audio_only'].url
                print(f"URL : {url[:30]}...\n")
            except:
                url = streams['worst'].url
                print(f"URL : {url[:30]}...\n")

        except:
            pass
        return url

    def open_url(self,proxy_data):
        try:
            global all_proxies
            headers = {'User-Agent': ua.random}
            current_index = all_proxies.index(proxy_data)

            if proxy_data['url'] == "":
                proxy_data['url'] = self.get_url()
            current_url = proxy_data['url']
            try:
                if time.time() - proxy_data['time'] >= random.randint(1, 5):
                    current_proxy = {"http": f"https://{proxy_data['proxy']}", "https": f"http://{proxy_data['proxy']}"}
                    with requests.Session() as s:
                        response = s.head(current_url, proxies=current_proxy, headers=headers)
                    print(f"Sent HEAD request with {current_proxy['http']} | {response.status_code} | {response.request} | {response}")
                    proxy_data['time'] = time.time()
                    all_proxies[current_index] = proxy_data
            except:
                print("Connection Error!")

        except (KeyboardInterrupt, SystemExit):
            sys.exit()


    def mainmain(self):
        self.channel_url = channel_urls
        proxies = self.get_proxies()

        for p in proxies:
            all_proxies.append({'proxy': p, 'time': time.time(), 'url': ""})

        shuffle(all_proxies)
        list_of_all_proxies = all_proxies
        current_proxy_index = 0

        while True:
            try:
                for i in range(0, max_nb_of_threads):
                    threaded = Thread(target=self.open_url, args=(all_proxies[random.randint(0, len(all_proxies))],))
                    threaded.daemon = True  # This thread dies when main thread (only non-daemon thread) exits.
                    threaded.start()
            except:
                self.print_exception()
            shuffle(all_proxies)
            time.sleep(5)


ViewerBot = ViewerBot()
ViewerBot.mainmain()

image

Bro line 107 of threader is problem

@zaeboba
Copy link

zaeboba commented Jan 29, 2022

"""
   Update from NjProVk
"""

import requests
from streamlink import Streamlink
import sys
import time
import random
from random import shuffle
from fake_useragent import UserAgent
import linecache

from threading import Thread

channel_urls = f"https://www.twitch.tv/{sys.argv[1]}"
proxies_file = "Proxies_txt/good_proxy.txt"
processes = []
max_nb_of_threads = int(sys.argv[2])

all_proxies = []
nb_of_proxies = 0

# Session creating for request
ua = UserAgent()
session = Streamlink()
session.set_option("http-headers", {'User-Agent': ua.random, "Client-ID": "ewvlchtxgqq88ru9gmfp1gmyt6h2b93"})

class ViewerBot:
    def print_exception(self):
        exc_type, exc_obj, tb = sys.exc_info()
        f = tb.tb_frame
        lineno = tb.tb_lineno
        filename = f.f_code.co_filename
        linecache.checkcache(filename)
        line = linecache.getline(filename, lineno, f.f_globals)
        print('EXCEPTION IN ({}, LINE {} "{}"): {}'.format(filename, lineno, line.strip(), exc_obj))



    def get_proxies(self):
        # Reading the list of proxies
        global nb_of_proxies
        try:
            lines = [line.rstrip("\n") for line in open(proxies_file)]
        except IOError as e:
            print("An error has occurred while trying to read the list of proxies: %s" % e.strerror)
            sys.exit(1)

        nb_of_proxies = len(lines)
        return lines


    def get_url(self):
        url = ""
        try:
            streams = session.streams(self.channel_url)
            try:
                url = streams['audio_only'].url
                print(f"URL : {url[:30]}...\n")
            except:
                url = streams['worst'].url
                print(f"URL : {url[:30]}...\n")

        except:
            pass
        return url

    def open_url(self,proxy_data):
        try:
            global all_proxies
            headers = {'User-Agent': ua.random}
            current_index = all_proxies.index(proxy_data)

            if proxy_data['url'] == "":
                proxy_data['url'] = self.get_url()
            current_url = proxy_data['url']
            try:
                if time.time() - proxy_data['time'] >= random.randint(1, 5):
                    current_proxy = {"http": f"https://{proxy_data['proxy']}", "https": f"http://{proxy_data['proxy']}"}
                    with requests.Session() as s:
                        response = s.head(current_url, proxies=current_proxy, headers=headers)
                    print(f"Sent HEAD request with {current_proxy['http']} | {response.status_code} | {response.request} | {response}")
                    proxy_data['time'] = time.time()
                    all_proxies[current_index] = proxy_data
            except:
                print("Connection Error!")

        except (KeyboardInterrupt, SystemExit):
            sys.exit()


    def mainmain(self):
        self.channel_url = channel_urls
        proxies = self.get_proxies()

        for p in proxies:
            all_proxies.append({'proxy': p, 'time': time.time(), 'url': ""})

        shuffle(all_proxies)
        list_of_all_proxies = all_proxies
        current_proxy_index = 0

        while True:
            try:
                for i in range(0, max_nb_of_threads):
                    threaded = Thread(target=self.open_url, args=(all_proxies[random.randint(0, len(all_proxies))],))
                    threaded.daemon = True  # This thread dies when main thread (only non-daemon thread) exits.
                    threaded.start()
            except:
                self.print_exception()
            shuffle(all_proxies)
            time.sleep(5)


ViewerBot = ViewerBot()
ViewerBot.mainmain()

изображение

Connection Error!
Connection Error!
Connection Error!
Connection Error!
Connection Error!
Connection Error!
Connection Error!
Connection Error!
Connection Error!
Connection Error!
Connection Error!
Connection Error!
Connection Error!
^CTraceback (most recent call last):
File "threads_viewer.py", line 113, in
ViewerBot.mainmain()
File "threads_viewer.py", line 109, in mainmain
time.sleep(5)
KeyboardInterrupt

???

@NjProVk
Copy link
Author

NjProVk commented Feb 2, 2022

"""
   Update from NjProVk
"""

import requests
from streamlink import Streamlink
import sys
import time
import random
from random import shuffle
from fake_useragent import UserAgent
import linecache

from threading import Thread

channel_urls = f"https://www.twitch.tv/{sys.argv[1]}"
proxies_file = "Proxies_txt/good_proxy.txt"
processes = []
max_nb_of_threads = int(sys.argv[2])

all_proxies = []
nb_of_proxies = 0

# Session creating for request
ua = UserAgent()
session = Streamlink()
session.set_option("http-headers", {'User-Agent': ua.random, "Client-ID": "ewvlchtxgqq88ru9gmfp1gmyt6h2b93"})

class ViewerBot:
    def print_exception(self):
        exc_type, exc_obj, tb = sys.exc_info()
        f = tb.tb_frame
        lineno = tb.tb_lineno
        filename = f.f_code.co_filename
        linecache.checkcache(filename)
        line = linecache.getline(filename, lineno, f.f_globals)
        print('EXCEPTION IN ({}, LINE {} "{}"): {}'.format(filename, lineno, line.strip(), exc_obj))



    def get_proxies(self):
        # Reading the list of proxies
        global nb_of_proxies
        try:
            lines = [line.rstrip("\n") for line in open(proxies_file)]
        except IOError as e:
            print("An error has occurred while trying to read the list of proxies: %s" % e.strerror)
            sys.exit(1)

        nb_of_proxies = len(lines)
        return lines


    def get_url(self):
        url = ""
        try:
            streams = session.streams(self.channel_url)
            try:
                url = streams['audio_only'].url
                print(f"URL : {url[:30]}...\n")
            except:
                url = streams['worst'].url
                print(f"URL : {url[:30]}...\n")

        except:
            pass
        return url

    def open_url(self,proxy_data):
        try:
            global all_proxies
            headers = {'User-Agent': ua.random}
            current_index = all_proxies.index(proxy_data)

            if proxy_data['url'] == "":
                proxy_data['url'] = self.get_url()
            current_url = proxy_data['url']
            try:
                if time.time() - proxy_data['time'] >= random.randint(1, 5):
                    current_proxy = {"http": f"https://{proxy_data['proxy']}", "https": f"http://{proxy_data['proxy']}"}
                    with requests.Session() as s:
                        response = s.head(current_url, proxies=current_proxy, headers=headers)
                    print(f"Sent HEAD request with {current_proxy['http']} | {response.status_code} | {response.request} | {response}")
                    proxy_data['time'] = time.time()
                    all_proxies[current_index] = proxy_data
            except:
                print("Connection Error!")

        except (KeyboardInterrupt, SystemExit):
            sys.exit()


    def mainmain(self):
        self.channel_url = channel_urls
        proxies = self.get_proxies()

        for p in proxies:
            all_proxies.append({'proxy': p, 'time': time.time(), 'url': ""})

        shuffle(all_proxies)
        list_of_all_proxies = all_proxies
        current_proxy_index = 0

        while True:
            try:
                for i in range(0, max_nb_of_threads):
                    threaded = Thread(target=self.open_url, args=(all_proxies[random.randint(0, len(all_proxies))],))
                    threaded.daemon = True  # This thread dies when main thread (only non-daemon thread) exits.
                    threaded.start()
            except:
                self.print_exception()
            shuffle(all_proxies)
            time.sleep(5)


ViewerBot = ViewerBot()
ViewerBot.mainmain()

изображение

Connection Error!
Connection Error!
Connection Error!
Connection Error!
Connection Error!
Connection Error!
Connection Error!
Connection Error!
Connection Error!
Connection Error!
Connection Error!
Connection Error!
Connection Error!
^CTraceback (most recent call last):
File "threads_viewer.py", line 113, in
ViewerBot.mainmain()
File "threads_viewer.py", line 109, in mainmain
time.sleep(5)
KeyboardInterrupt

???

Proxy http(s)?

@NjProVk
Copy link
Author

NjProVk commented Feb 2, 2022

I already learned a lot, thank you, only the proxies are missing, I recommend that we make this use cookies so that the proxies are not railings, and thank you very much for your attention

This proxy http(s), cookies can be completed!

@NjProVk
Copy link
Author

NjProVk commented Feb 2, 2022

What proxies are you using? The code I posted uses http(s)

Tried changing the proxies to working proxies in India, now i am getting this:
image

you explain to me how to use it better it is not well explained I have all the requirements and VLC I do not know what I am missing it ran and sends me a link to open with a program

You have a file in which you will need to have a proxy like http (s), with line separation!

@NjProVk
Copy link
Author

NjProVk commented Feb 2, 2022

What proxies are you using? The code I posted uses http(s)

Tried changing the proxies to working proxies in India, now i am getting this:
image

Proxies must be separated by a new line:
ip:port
ip:port
ip:port

@zaeboba
Copy link

zaeboba commented Feb 2, 2022

Proxy http(s)?

Yes, http
I also tried socks4\socks5 from the address
https://github.com/monosans/proxy-list

@RiRaNerd
Copy link

I have the same Problem with the Proxys. Connection error with all seperat Proxys. Any idea?

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

No branches or pull requests

5 participants