def AddBookFromURL(self): # Create Resized Input Dialog dlg = QInputDialog() dlg.setInputMode(QInputDialog.TextInput) dlg.setLabelText('Enter URL:') dlg.setTextValue('https://www.readlightnovel.org/only-i-level-up') dlg.setWindowTitle('Add Novel') dlg.resize(500, 100) # If Cancelled if dlg.exec_() == 0: return # Get URL url = dlg.textValue() # Check URL if self.settings['MainURL'] not in url: print('{0} not in {1}'.format(self.settings['MainURL'], url)) return # Dump Info try: info = Utils.dumpInfo(url, self.settings) except AttributeError: print('Incorrect URL') return # Dump Cover Utils.dumpCover(info, self.settings) self.UpdateList()
def annotate_state(self, id): dialog = QInputDialog() dialog.setInputMode(QInputDialog.TextInput) dialog.setLabelText("Annotation:") dialog.resize(400, 100) if dialog.exec_(): self.store_annotation(id, dialog.textValue()) self.redraw_graph()
def edit_watcher(self): index = self.watcherlist.currentRow() addr = self.workspace.cartprograph.watchers[index][0] dialog = QInputDialog() dialog.setInputMode(QInputDialog.TextInput) dialog.setLabelText("Edit watcher @ " + hex(addr) + ":") dialog.setTextValue(", ".join( self.workspace.cartprograph.watchers[index][1])) dialog.resize(500, 100) if dialog.exec_(): self.workspace.cartprograph.watchers[index][ 1] = self._process_registers(dialog.textValue()) self.update_watcherlist()
def connectStream(self): dlg = QInputDialog(self) dlg.setInputMode(QInputDialog.TextInput) dlg.setLabelText("URL:") dlg.setTextEchoMode(QLineEdit.Normal) dlg.setTextValue(self.current_stream) dlg.resize(400, 100) dlg.exec() if dlg.result() and validators.url( dlg.textValue()) and dlg.textValue() != self.current_stream: self.current_stream = dlg.textValue() self.player.setMedia(QUrl(self.current_stream)) elif dlg.result() and not validators.url(dlg.textValue()): msg_box = QMessageBox() msg_box.setText("Error URL. Please try again") msg_box.setWindowTitle("Error URL") msg_box.exec() self.connectStream()
def GenerateBook(self): wdgList = self.ui.wdgList # Get Selected List selected = [ item.text().split(' | ') for item in wdgList.selectedItems() ] if len(selected) <= 0: return # Dump not downloaded chapters notDumped = [x for x in selected if x[1][-1] != ']'] # Download chapters if not self.downloadChapters(notDumped): self.UpdateList() # If canceled stop epub generation return self.UpdateList() # Update selected list selected = [[x[0][1:], x[1][:-1]] for x in selected if x[1][-1] == ']'] selected += notDumped # Get dicts from Info dictionary chapters = [ chp for chp in self.info['chapters'] for volume, name in selected if name == chp['name'] and volume == chp['volume'] ] # Generate Title for book volume = chapters[0]['volume'] for chapter in chapters: if chapter['volume'] != volume or 'chapters' in volume.lower(): volume = 'Chapters:' title = self.info['title'] + ' ' + volume try: # If chapters are not from the same volume if volume == 'Chapters:': numbers = [ int( float(''.join(s for s in name if s.isdigit() or s == '.' or s == '-'))) for name in selected ] numbers = list(set(numbers)) # Generate ranges for number list ranges = Utils.ranges(numbers) for r in ranges: if r[0] == r[1]: title += ' {0},'.format(r[0]) else: title += ' {0} - {1},'.format(r[0], r[1]) if title[-1] == ',': title = title[:-1] except ValueError: pass # Show Title Input Dialog dlg = QInputDialog() dlg.setInputMode(QInputDialog.TextInput) dlg.setLabelText('Enter Title:') dlg.setWindowTitle('Select Book Title') dlg.setTextValue(title) dlg.resize(500, 100) # If Cancelled if dlg.exec_() == 0: return # Get URL title = dlg.textValue() # Show File Dialog ans = QFileDialog.getSaveFileName(caption='Save ePUB', filter='ePUB (*.epub)', dir=title + '.epub') filename = ans[0] # Add file format if not present if filename[-5:] != '.epub': filename += '.epub' # Generate ePUB file Utils.generateEPUB(filename, title, self.info, chapters, self.settings)