示例#1
0
 def StartLog(self):
     client = GetMPD()
     state = client.status()
     if (state['state'] == "play"):
         currentSong = client.currentsong()
         self.lastSong = currentSong['file']
         self.lastTime = state['elapsed']
         client.disconnect()
示例#2
0
文件: Logger.py 项目: C0DK/MPD-API
	def StartLog(self):
		client = GetMPD()
		state = client.status()
		if(state['state'] == "play"):
			currentSong = client.currentsong()
			self.lastSong = currentSong['file']
			self.lastTime = state['elapsed']
			client.disconnect();
示例#3
0
def Fix():
	client = GetMPD()
	
	state = client.status()
	if(state['state'] == "stop"): 
		client.disconnect()
		return
	
	while(client.currentsong()["pos"] != "0"):
		queue = client.playlistinfo()
		print queue
		songName = queue[0]["file"]
		songID = queue[0]["id"]
		client.deleteid(songID)
		client.add(songName)
	
	client.disconnect()
示例#4
0
    def AddLog(self):

        client = GetMPD()
        state = client.status()
        currentSong = client.currentsong()

        if (state['state'] != "play"):
            client.disconnect()
            return

        print "time= " + currentSong['time']

        if (currentSong['file'] == self.lastSong
                and state['elapsed'] >= self.lastTime):
            client.disconnect()
            return

        self.lastSong = currentSong['file']
        self.lastTime = state['elapsed']

        print self.lastSong

        conn = Database.GetConnection()
        c = conn.cursor()

        Exists = c.execute(
            "SELECT EXISTS(SELECT 1 FROM songPlays WHERE fileName=? LIMIT 1)",
            (self.lastSong, ))

        if (Exists.fetchone()[0] == 0):
            c.execute("INSERT INTO songPlays VALUES (?,1)", (self.lastSong, ))
        else:
            c.execute("UPDATE songPlays SET times=times+1 WHERE fileName=?",
                      (self.lastSong, ))

        conn.commit()

        conn.commit()
        conn.close()
        client.disconnect()
示例#5
0
文件: Logger.py 项目: C0DK/MPD-API
	def AddLog(self):

		client = GetMPD()
		state = client.status()
		currentSong = client.currentsong()
				
		if(state['state'] != "play"):
			client.disconnect()
			return
		
		print "time= "+currentSong['time']
		
		if(currentSong['file'] == self.lastSong and state['elapsed'] >= self.lastTime):
			client.disconnect()
			return
		
		self.lastSong = currentSong['file']
		self.lastTime = state['elapsed']
		
		print self.lastSong
		
		conn = Database.GetConnection()
		c = conn.cursor()
		
		Exists = c.execute("SELECT EXISTS(SELECT 1 FROM songPlays WHERE fileName=? LIMIT 1)",(self.lastSong,));
		
		if(Exists.fetchone()[0] == 0):
			c.execute("INSERT INTO songPlays VALUES (?,1)",(self.lastSong,))
		else:
			c.execute("UPDATE songPlays SET times=times+1 WHERE fileName=?",(self.lastSong,))	
		
		conn.commit()
		
		conn.commit()
		conn.close()
		client.disconnect();