def anaysisURL(self): url = self.nameLine.text() self.downloadButton.setEnabled(False) self.comicNameLabel.setText("暂无") self.comicIntro.setText("暂无") self.chapterListView.clear() self.chapterListView.setEnabled(False) try: if getComic.isLegelUrl(url): self.id = getComic.getId(url) self.comicName, self.comicIntrd, self.count, self.contentList = getComic.getContent( self.id) self.contentNameList = [] for item in self.contentList: for k in item: self.contentNameList.append(item[k]['t']) self.comicNameLabel.setText(self.comicName) self.comicIntro.setText(self.comicIntrd) self.chapterListView.setEnabled(True) self.downloadButton.setEnabled(True) self.chapterListView.setFocus() self.statusLabel.setText('选择要下载的章节后点击右侧按钮') for i in range(len(self.contentNameList)): self.chapterListView.addItem('第{0:0>4}话-{1}'.format( i + 1, self.contentNameList[i])) self.chapterListView.item(i).setSelected(True) self.downloadButton.setEnabled(True) else: self.statusLabel.setText( '<font color="red">错误的URL格式!请输入正确的漫画首页地址!</font>') except getComic.ErrorCode as e: if e.code == 2: self.statusLabel.setText( '<font color="red">无法跳转为移动端URL,请使用http://m.ac.qq.com</font>' ) except KeyError: self.statusLabel.setText('<font color="red">不存在的地址</font>')
def anaysisURL(self): url = self.nameLine.text() self.downloadButton.setEnabled(False) self.comicNameLabel.setText("暂无") self.comicIntro.setText("暂无") self.chapterListView.clear() self.chapterListView.setEnabled(False) try: if getComic.isLegelUrl(url): self.id = getComic.getId(url) self.comicName,self.comicIntrd,self.count,self.contentList = getComic.getContent(self.id) self.contentNameList = [] for item in self.contentList: for k in item: self.contentNameList.append(item[k]['t']) self.comicNameLabel.setText(self.comicName) self.comicIntro.setText(self.comicIntrd) self.chapterListView.setEnabled(True) self.downloadButton.setEnabled(True) self.chapterListView.setFocus() self.statusLabel.setText('选择要下载的章节后点击右侧按钮') for i in range(len(self.contentNameList)): self.chapterListView.addItem('第{0:0>4}话-{1}'.format(i+1, self.contentNameList[i])) self.chapterListView.item(i).setSelected(True) self.downloadButton.setEnabled(True) else: self.statusLabel.setText('<font color="red">错误的URL格式!请输入正确的漫画首页地址!</font>') except getComic.ErrorCode as e: if e.code == 2: self.statusLabel.setText('<font color="red">无法跳转为移动端URL,请进入http://m.ac.qq.com找到该漫画地址</font>') except KeyError: self.statusLabel.setText('<font color="red">不存在的地址</font>') except Exception as e: self.statusLabel.setText('<font color="red">{}</font>'.format(e))