def changeChannel(self,num): self.url = "http://douban.fm/j/mine/playlist?type=n&sid=&pt=0.0&channel="+ num + "&from=mainsite" self.cnum = num self.songlist = getSongInfo(self.url) self.s = next(self.songlist) song = self.s["url"] self.songprocess.write("loadfile {0}\n".format(song)) self.song()
def initUi(self): self.setupUi(self) # http.client.HTTPConnection.debuglevel = 1 url = '1' cookiefile = "cookies.txt" collectChannel = {} self.tochannel() #QSignalMapper self.get = 0 if os.path.isfile(cookiefile): #cookie文件是否存在 self.likeButton.setEnabled(True) self.notlikeButton.setEnabled(True) self.redheartChannel.setEnabled(True) self.privateChannel.setEnabled(True) self.collectChannel.setEnabled(True) self.install_opener(cookiefile) collectChannel=self.getcollect() self.tocollect(collectChannel) url = '0' if url == '0': self.current_channel.setText("私人兆赫") else: self.current_channel.setText("华语HMz") self.url = "http://douban.fm/j/mine/playlist?type=n&channel="+url+"&from=mainsite" self.sDialog = None self.songprocess = QtCore.QProcess() self.songprocess.setProcessChannelMode(QtCore.QProcess.MergedChannels) self.songprocess.started.connect(self.info) self.songprocess.finished[int].connect(self.finish) self.nextButton.clicked.connect(self.next) #下一首 self.stopButton.toggled.connect(self.stop) #暂停 self.volumnSlider.valueChanged.connect(self.changeVolumn) #改变音量 self.volumn.clicked.connect(self.mute) #改变音量 self.setting.clicked.connect(self.changeSetting) self.likeButton.clicked.connect(self.like) self.notlikeButton.clicked.connect(self.notlike) self.channel.mousemove.connect(self.showChannel) self.quitLabel.clicked.connect(self.clearCookie) if url == "1": self.cnum = 1 else: self.cnum = -3 self.songlist = getSongInfo(self.url) self.s = next(self.songlist) song = self.s["url"] self.songprocess.start('mplayer',['-slave','-quiet',song]) self.vnum = 50 self.volumnSlider.setValue(self.vnum)
def nextsong(self): try: self.s = next(self.songlist) except StopIteration: self.songlist = getSongInfo(self.url) self.s = next(self.songlist)