From: <te...@us...> - 2004-03-05 01:19:00
|
Update of /cvsroot/quickrip/ng/cli In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30870/cli Modified Files: cli.py Log Message: CLI now fully implemented Index: cli.py =================================================================== RCS file: /cvsroot/quickrip/ng/cli/cli.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** cli.py 5 Mar 2004 00:12:28 -0000 1.4 --- cli.py 5 Mar 2004 00:57:18 -0000 1.5 *************** *** 52,55 **** --- 52,58 ---- self.level = 'configure' self.configure() + elif mode == 'rip': + self.level = 'ripping' + self.ripScreen() *************** *** 103,108 **** print "(a) Audio bitrate: \t%skbps" % (str(int(title['abr']))) print "" ! print "(l) Audio language: \t%s" % (title['alang']) ! print "(s) Subtitles: \t%s" % (title['slang']) print "" print output.bold("Enter letter to change information, or 'b' to go back to the title listing") --- 106,111 ---- print "(a) Audio bitrate: \t%skbps" % (str(int(title['abr']))) print "" ! print "(l) Audio language: \t%s" % (config.langs[title['alang']]) ! print "(s) Subtitles: \t%s" % (config.langs[title['slang']]) print "" print output.bold("Enter letter to change information, or 'b' to go back to the title listing") *************** *** 218,221 **** --- 221,256 ---- self.askLevelOrQuestion() + + def ripScreen(self): + print output.bold("QuickRip will now rip the following tracks:") + numtitles_to_rip = 0 + for t in self.titles: + if t['rip'] == 'yes': + numtitles_to_rip += 1 + print "- Track %2s (%s/%s.avi) at %skbps" % (t['id'], \ + self.config['outputdir'], t['name'], t['vbr']) + # Have they selected any titles? + if numtitles_to_rip is 0: + print "" + print output.red("You don't seem to have selected any tracks to rip!") + print output.red("Hit enter to return to the main menu") + null = raw_input() + del null + self.switch("toplevel") + # Ok, rip DVD + print output.bold("Hit enter to begin ripping, or 'b' to return to the main menu") + null = raw_input("> ") + if null == 'b': + self.switch("toplevel") + del null + print "" + self.ripDVD() + print "" + print output.bold("Ripping complete. Hit enter to return to the main menu") + null = raw_input("") + del null + self.switch("toplevel") + + def askLevelOrQuestion(self): *************** *** 232,241 **** print output.bold("Goodbye") sys.exit(2) - elif self.choice == 'b' and self.level != 'toplevel': - self.switch('toplevel') elif self.choice == 'c' and self.level == 'toplevel': self.switch('configure') elif self.choice not in self.choices.keys(): ! print output.bold("You chose '%s', which isn't a valid choice. Try again." % (self.choice)) self.askLevelOrQuestion() else: --- 267,278 ---- print output.bold("Goodbye") sys.exit(2) elif self.choice == 'c' and self.level == 'toplevel': self.switch('configure') + elif self.choice == 'r' and self.level == 'toplevel': + self.switch('rip') + elif self.choice == 'b' and self.level != 'toplevel': + self.switch('toplevel') elif self.choice not in self.choices.keys(): ! print output.red("You chose '%s', which isn't a valid choice. Try again." % (self.choice)) self.askLevelOrQuestion() else: *************** *** 260,269 **** if isinstance(self.choices[self.choice]['options'], type([])): if self.option_choice not in self.choices[self.choice]['options']: ! print output.bold("You chose '%s', which isn't a valid choice. Try again." % \ (self.option_choice)) self.askOption() else: if not re.search(self.choices[self.choice]['options'], self.option_choice): ! print output.bold("You chose '%s', which isn't a valid choice. Try again." % (self.option_choice)) self.askOption() # Maybe check the path is valid? --- 297,306 ---- if isinstance(self.choices[self.choice]['options'], type([])): if self.option_choice not in self.choices[self.choice]['options']: ! print output.red("You chose '%s', which isn't a valid choice. Try again." % \ (self.option_choice)) self.askOption() else: if not re.search(self.choices[self.choice]['options'], self.option_choice): ! print output.red("You chose '%s', which isn't a valid choice. Try again." % (self.option_choice)) self.askOption() # Maybe check the path is valid? *************** *** 273,277 **** msg = "You chose '%s', which isn't a valid choice. Try again." \ % (self.option_choice) ! print output.bold(msg) self.askOption() # Change the option --- 310,314 ---- msg = "You chose '%s', which isn't a valid choice. Try again." \ % (self.option_choice) ! print output.red(msg) self.askOption() # Change the option *************** *** 305,325 **** print output.bold("ERROR: %s" % (message)) sys.exit(2) ! ! def notify_startScanning(self): sys.stdout.write("* Scanning\n") ! ! def notify_dispDVD(self, label, numtitles): print "DVD label: %s" % (label) print "Titles: " + str(numtitles) def notify_dispTitle(self, title): print "%s: %s" % (title['id'], title['timelabel']) def notify_finishScanning(self): print "* Finished scanning" def main(): #print "QuickRip v0.6, (C) Tom Chance, 2003" --- 342,418 ---- print output.bold("ERROR: %s" % (message)) sys.exit(2) ! ! def notify_startScanning(self): sys.stdout.write("* Scanning\n") ! ! ! def notify_noTitles(self): ! print """ ! *** ERROR: No DVD tracks found *** ! *** Check: ! *** - You can play DVDs on your computer ! *** (libdvdread and libdvdcss must be installed) ! *** - There is a DVD in the drive ! """ ! sys.exit(2) ! ! def notify_dispDVD(self, label, numtitles): print "DVD label: %s" % (label) print "Titles: " + str(numtitles) + def notify_dispTitle(self, title): print "%s: %s" % (title['id'], title['timelabel']) + def notify_finishScanning(self): print "* Finished scanning" + def int_newTitle(self, name, number, total, vbr): + #print "" + print "* Ripping title %2s (%s of %s)" % (name, number, total) + + + def int_newPass(self, passtype): + slashn = "" + # Finish off last pass' line + if passtype != "audio": + sys.stdout.write(" 100% ") + for i in range(self.n): + sys.stdout.write("=") + sys.stdout.write("|\n") + sys.stdout.write(slashn + passtype + " |") + # (Re)set progress meter for new pass + self.spinner = "\|/-\|/-" + self.spinpos = 0 + width = os.popen("tput cols").read() + width = float(width) + self.jumper = 100 / (width - 20) + self.n = 0 + + + def int_updateProgress(self, perc, trem, tpass): + # Auto-resize UI? + for opt in sys.argv: + if opt in ['-a', '--autoresize']: + width = os.popen("tput cols").read() + width = float(width) + self.jumper = 100 / (width - 20) + n = int(int(perc) / self.jumper) + # Rewrite percentage + if int(perc) <= 9: + sys.stdout.write(" " + str(int(perc)) + "% |") + else: + sys.stdout.write(" " + str(int(perc)) + "% |") + # Rewrite bar + sys.stdout.write("=" * n) + # Rewrite spinner + sys.stdout.write(self.spinner[self.spinpos]) + self.spinpos=(self.spinpos+1)%8 + sys.stdout.flush() + def main(): #print "QuickRip v0.6, (C) Tom Chance, 2003" |