forked from spiffomatic64/SpiffBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
twitch_bot_intro.py
35 lines (28 loc) · 888 Bytes
/
twitch_bot_intro.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#! python2
import threading
import subprocess
import logging
import Queue
class intro_thread:
def __init__(self):
self.queue = Queue.Queue()
self.alive = False
def thread_loop(self):
while self.alive:
try:
intro_url = self.queue.get(True,1)
logging.log(logging.INFO, "Playing intro: %s",intro_url)
p = subprocess.Popen(["py", "twitch_vlc_player.py", intro_url])
p.wait()
except Queue.Empty:
pass
def run(self):
self.alive = True
self.running = threading.Thread(target=self.thread_loop)
self.running.daemon = True
self.running.start()
logging.log(logging.INFO,"Started Intro Video Queue Thread")
def stop(self):
self.alive = False
def addIntro(self,intro):
self.queue.put(intro)