Example #1
0
 def initTreadDict(self):
     for star in self.hotStarData:
         threadAdd = PandaTV(star['roomid'])
         threadAdd.setDaemon(True)
         #print('检测',star['roomid'],type(star),type(star['roomid']))
         time.sleep(1)
         threadAdd.start()
         self.threadDict[threadAdd.getName()] = threadAdd
         print(self.roomiddict[threadAdd.getName()[6:]], '线程初始化')
         #panda thread name = "panda&" + roomid
     print(len(self.hotStarData), '个弹幕记录线程初始化')
Example #2
0
 def initTreadDict(self):
     for star in self.hotStarData:
         threadAdd = PandaTV(star['roomid'])
         threadAdd.setDaemon(True)
         #print('检测',star['roomid'],type(star),type(star['roomid']))
         time.sleep(1)
         threadAdd.start()
         self.threadDict[threadAdd.getName()] = threadAdd
         print(self.roomiddict[threadAdd.getName()[6:]],'线程初始化')
         #panda thread name = "panda&" + roomid
     print(len(self.hotStarData),'个弹幕记录线程初始化')
Example #3
0
File: main.py Project: 5ace/pandatv
import sys
from pandaTV import PandaTV


if __name__ == '__main__':
    idolid= sys.argv[1] if len(sys.argv)>1 else '66666'
    panda=PandaTV(idolid)
    panda.getChatInfo()
    #python3 pandaTVDanmu.py 10091
Example #4
0
    def newThreadCreate(self):
        newThreadDict = dict()
        killTread = list()
        reThreadDict = dict()
        for star in self.hotStarData:
            newThreadDict[star['roomid']] = star['number']
        # old thread checker
        for threadName, threadAdd in self.threadDict.items():
            roomid = threadName[6:]
            #restart Dead thread
            if newThreadDict.pop(roomid, False) is not False:

                if threadAdd.isAlive() is False:
                    print('need to recreat:', self.roomiddict[roomid], '线程状态为',
                          threadAdd.isAlive())
                    # time.sleep(1)
                    reThreadAdd = PandaTV(roomid)
                    reThreadAdd.setDaemon(True)
                    reThreadAdd.start()
                    print('recreat:', self.roomiddict[roomid], '线程状态变为',
                          reThreadAdd.isAlive())
                    reThreadDict[roomid] = reThreadAdd
            else:
                #kill down hot room
                threadAdd.exit()
                killTread.append(threadName)
                print('kill:', self.roomiddict[roomid], '线程状态变为',
                      threadAdd.isAlive())

        print('newthreaddict:', len(newThreadDict))

        # del dead thread in self.threadict
        for deltread in killTread:
            self.threadDict.pop(deltread)
        # reload thread in self.threaddict
        for k, v in reThreadDict.items():
            if self.threadDict.get(k):
                self.threadDict[k] = v
        # new thread creater
        if newThreadDict:
            for newName, hotNumber in newThreadDict.items():
                threadAdd = PandaTV(newName)
                threadAdd.setDaemon(True)
                if self.threadDict.get('panda&' + str(newName),
                                       False) is False:
                    # time.sleep(1)
                    threadAdd.start()
                    self.threadDict[threadAdd.getName()] = threadAdd
                    print('creat:', self.roomiddict[newName], '新线程启动状态为',
                          threadAdd.isAlive())
Example #5
0
# from mulpro import God
# from pandaspider import PandaSpider
from pandaTV import PandaTV

# from douyuspider import DouyuSpider
from douyuTV import DouyuTV

from singler import DouyuGuard, PandaGuard, God

import sys

if __name__ == '__main__':
    cmd = sys.argv[1] if len(sys.argv) > 1 else 'None'
    rid = sys.argv[1] if len(sys.argv) > 1 else None
    if cmd == 'douyuGuard':
        God(DouyuGuard()).run()
    elif cmd == 'pandaGuard':
        God(PandaGuard()).run()
    elif cmd == 'douyuDanmu':
        roomid = rid if len(rid) > 1 else '48699'
        DouyuTV(roomid, show=True).start()
    elif cmd == 'pandaDanmu':
        roomid = rid if len(rid) > 1 else '66666'
        PandaTV(roomid, show=True).start()
    elif cmd == 'douyuNoGuard':
        DouyuGuard.run()
    elif cmd == 'pandaNoGuard':
        PandaGuard.run()
    else:
        print('Command is not found')
Example #6
0
    def newThreadCreate(self):
        newThreadDict = dict()
        killTread = list()
        reThreadDict = dict()
        for star in self.hotStarData:
            newThreadDict[star['roomid']] = star['number']
        # old thread checker
        for threadName,threadAdd in self.threadDict.items():
            roomid = threadName[6:]
            #restart Dead thread
            if newThreadDict.pop(roomid,False) is not False:

                if threadAdd.isAlive() is False:
                    print('need to recreat:',self.roomiddict[roomid],'线程状态为',threadAdd.isAlive())
                    # time.sleep(1)
                    reThreadAdd = PandaTV(roomid)
                    reThreadAdd.setDaemon(True)
                    reThreadAdd.start()
                    print('recreat:',self.roomiddict[roomid],'线程状态变为',
                        reThreadAdd.isAlive())
                    reThreadDict[roomid] = reThreadAdd
            else:
                #kill down hot room
                threadAdd.exit()
                killTread.append(threadName)
                print('kill:',self.roomiddict[roomid],'线程状态变为',
                    threadAdd.isAlive())

        print('newthreaddict:',len(newThreadDict))

        # del dead thread in self.threadict
        for deltread in killTread:
            self.threadDict.pop(deltread)
        # reload thread in self.threaddict
        for k,v in reThreadDict.items():
            if self.threadDict.get(k):
                self.threadDict[k] = v
        # new thread creater
        if newThreadDict:
            for newName,hotNumber in newThreadDict.items():
                threadAdd = PandaTV(newName)
                threadAdd.setDaemon(True)
                if self.threadDict.get(self.platform+'&'+str(newName),False) is False:
                    # time.sleep(1)
                    threadAdd.start()
                    self.threadDict[threadAdd.getName()] = threadAdd
                    print('creat:',self.roomiddict[newName],'新线程启动状态为',
                        threadAdd.isAlive())