Ok thanks everyone for help. I've second problem. I want chat when I watch stream and it's possible with irc. Server is irc.twitch.tv
and channel is same as livestreamer name. When I tried this code, it gives me error.
# -*- coding: latin-1 -*-
import subprocess
print(35*"+")
name = raw_input("Livestreamer name\n")
hostVideo = subprocess.Popen(['livestreamer', 'twitch.tv/'+name, 'best'], stdout = subprocess.PIPE).communicate()[0]
hostIrssi = subprocess.Popen(['irssi --connect=irc.twitch.tv --password=oauth:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx --nick=nickname'], stdout = subprocess.PIPE).communicate()[0]
print hostVideo
print hostIrssi
This is error what I got
Traceback (most recent call last):
File "Livestreamer.py", line 7, in <module>
hostIrssi = subprocess.Popen(['irssi --connect=irc.twitch.tv --password=oauth:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx --nick=nickname'], stdout = subprocess.PIPE).communicate()[0]
File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
Also if possible, tell me how to make it join automatically right channel.
MY older post
I love watching twitch livestreams and I wanted to do script which asks livestreamer name and then send commands to terminal. Livestreamer command is like
livestreamer twitch.tv/user best
So script must add "twitch.tv/" after livestreamer command and "best" after user. My code looks like:
# -*- coding: latin-1 -*-
import subprocess
user = raw_input("Livestreamers name:\n")
livestreamer = "livestreamer twitch.tv/"
host = subprocess.Popen(['livestreamer', 'twitch.tv/', user, 'best'], stdout = subprocess.PIPE).communicate()[0]
print host
Output is
livestreamer: error: unrecognized arguments: best
If someone know whats wrong, Im so glad that. Also sorry my bad english. :)
You need to concatenate "twitch.tv/"
with the username, so your final line should be
host = subprocess.Popen(['livestreamer', 'twitch.tv/'+user, 'best'], stdout=subprocess.PIPE).communicate()[0]
Also note that keyword ( name=value
) arguments shouldn't really have spaces around the equals sign for best conformance to the Python style guide in PEP 8
Your subprocess line is sending this command:
livestreamer twitch.tv/ user best
This would start a process in the form of your example:
subprocess.Popen(['livestreamer', 'twitch.tv/%s' % user, 'best'], stdout = subprocess.PIPE).communicate()[0]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.