Could somebody help me because i saw some scripts and dont know how to use it and how to paste it in python...
http://www.ericzhang.me/faking-views-on-twitch-tv/
As I'm sure most people are going to say, learn python and then we'll help you.
Jan 10, 2014 08:37 AM
(This post was last modified: Jan 10, 2014 08:37 AM by Das Swag.)
You literally have the source code there, learn a little bit of python and copy and paste it.
DO NOT DEAL WITH THIS MEMBER
The source code IMO isn't fairly difficult to understand. If you have any specific questions regarding it, then you should post that here.
hello i just copy past the code and change channel name
but i have an error when i launche the code with the idle
inconsistent uf of tabs and spaces in indentation....
i try many things but it fail ...
Okay so I solved the indentation errors (That was easy)
But, the script need a bunch of modules and livestreamer to work and I'm not ready to install all this crap.
Here's the indented code:
Code import requests
import subprocess
import json
import sys
import threading
import time
from Queue import Queue
numberOfViewers = int(sys.argv[1])
builderThreads = int(sys.argv[2])
startTime = time.time()
numberOfSockets = 0
concurrent = 25
urls = []
urlsUsed = []
def getURL(): # Get tokens
output = subprocess.Popen(["livestreamer", "twitch.tv/spaskygoranov", "-j"], stdout=subprocess.PIPE).communicate()[0]
return json.loads(output)['streams']['worst']['url'] # Parse json and return the URL parameter
def build(): # Builds a set of tokens, aka viewers
global numberOfSockets
global numberOfViewers
while True:
if numberOfSockets < numberOfViewers:
numberOfSockets += 1
print "Building viewers " + str(numberOfSockets) + "/" + str(numberOfViewers)
urls.append(getURL())
def view(): # Opens connections to send views
global numberOfSockets
while True:
url=q.get()
requests.head(url)
if (url in urlsUsed):
urls.remove(url)
urlsUsed.remove(url)
numberOfSockets -= 1
else:
urlsUsed.append(url)
q.task_done()
if __name__ == '__main__':
for i in range(0, builderThreads):
threading.Thread(target = build).start()
while True:
while (numberOfViewers != numberOfSockets): # Wait until sockets are built
time.sleep(1)
q=Queue(concurrent*2)
for i in range(concurrent):
try:
t=threading.Thread(target=view)
t.daemon=True
t.start()
except:
print 'thread error'
try:
for url in urls:
print url
q.put(url.strip())
q.join()
except KeyboardInterrupt:
sys.exit(1)
(May 19, 2014 10:06 AM)feltron Wrote: hello i just copy past the code and change channel name
but i have an error when i launche the code with the idle
inconsistent uf of tabs and spaces in indentation....
i try many things but it fail ...
Indents in python are like brackets in most code
an if statement in python is written as
Code if this == true:
then do this
where as most languages are
Code if this == true
{
do this
}
also you probably have to install modules that the code is trying to import
(May 19, 2014 03:05 PM)Kankroc Wrote: Okay so I solved the indentation errors (That was easy)
But, the script need a bunch of modules and livestreamer to work and I'm not ready to install all this crap.
Here's the indented code:
Code import requests
import subprocess
import json
import sys
import threading
import time
from Queue import Queue
numberOfViewers = int(sys.argv[1])
builderThreads = int(sys.argv[2])
startTime = time.time()
numberOfSockets = 0
concurrent = 25
urls = []
urlsUsed = []
def getURL(): # Get tokens
output = subprocess.Popen(["livestreamer", "twitch.tv/spaskygoranov", "-j"], stdout=subprocess.PIPE).communicate()[0]
return json.loads(output)['streams']['worst']['url'] # Parse json and return the URL parameter
def build(): # Builds a set of tokens, aka viewers
global numberOfSockets
global numberOfViewers
while True:
if numberOfSockets < numberOfViewers:
numberOfSockets += 1
print "Building viewers " + str(numberOfSockets) + "/" + str(numberOfViewers)
urls.append(getURL())
def view(): # Opens connections to send views
global numberOfSockets
while True:
url=q.get()
requests.head(url)
if (url in urlsUsed):
urls.remove(url)
urlsUsed.remove(url)
numberOfSockets -= 1
else:
urlsUsed.append(url)
q.task_done()
if __name__ == '__main__':
for i in range(0, builderThreads):
threading.Thread(target = build).start()
while True:
while (numberOfViewers != numberOfSockets): # Wait until sockets are built
time.sleep(1)
q=Queue(concurrent*2)
for i in range(concurrent):
try:
t=threading.Thread(target=view)
t.daemon=True
t.start()
except:
print 'thread error'
try:
for url in urls:
print url
q.put(url.strip())
q.join()
except KeyboardInterrupt:
sys.exit(1)
Indentation is still off, for example, the final try/except statement.
(May 20, 2014 01:01 PM)Silkie Wrote: Indentation is still off, for example, the final try/except statement.
Just to also point out the indentation is off for the for loop in the try statement as well.
(May 20, 2014 01:03 PM)Pillows Wrote: Just to also point out the indentation is off for the for loop in the try statement as well.
Just to point out, it's HF's formatting messing it up.
Messed up my perfectly indented code.
DO NOT DEAL WITH THIS MEMBER
I remember this code... You can't run it from IDLE if you want it to work properly. Run it from command prompt/terminal, with two arguments (number of threads and builder of threads)
DO NOT DEAL WITH THIS MEMBER
Bump
Help trying to execute but dont know the proper Perimeters?
Maybe someone could spoon feed me the proper knowledge for this script?
For as I know, twitch changed view counting algorithm so this python script will not work. You have to simulate real viewer behavior.
|