def main(): try: o=OParser(susage, soptions) except optparse.OptionError: print "! invalid option" sys.exit(1) options, args=o.parse() um=UserMessaging(sname, False, prepend="#") files=[] if options.webhelp: import webbrowser webbrowser.open(webhelp_url) sys.exit(0) if len(args) < 1: um.error(messages["args"]) sys.exit(1) try: path=os.path.expanduser(args[0]) except: path=None try: ## is 'path' a directory or a file? is_dir=os.path.isdir(path) is_file=os.path.isfile(path) except: um.error(messages["error_path"]) sys.exit(1) ## if the user specified a directory, get all the .mp3 files then if is_dir: files=get_dir_files(path) if is_file: files=[].append(path) if files is None: um.error(messages["error_path"]) sys.exit(1) if len(files) == 0: um.info(messages["zero_file"]) sys.exit(0) um.info(messages["some_files"] % len(files)) process(files, options) sys.exit(0)
def main(): o=OParser(susage, soptions) options, args=o.parse() um=UserMessaging(sname, options.quiet) if len(args) < 2: um.error(messages["args"]) sys.exit(1) try: m3ufile=os.path.expanduser(args[0]) except: m3ufile=None try: targetdir=os.path.expanduser(args[1]) except: targetdir=None if not os.path.isfile(m3ufile): um.error(messages["m3ufile_notfound"]) sys.exit(1) ## Create $targetdir directory hierarchy (if needed) if not os.path.isdir(targetdir): um.info(messages["targetdir_create"]) try: os.mkdir(targetdir) um.info(messages["targetdir_success"]) except: try: os.makedirs(targetdir) um.info(messages["targetdir_success"]) except: um.error(messages["targetdir_createfailed"]) sys.exit(1) try: import mutagen #@UnusedImport except: um.error(messages["mutagen_missing"]) sys.exit(1) ## ================================================================== try: _create_top_level_dirs(targetdir) except: um.error(messages["top_fail"]) sys.exit(1) ## ================================================================== m3u=M3uFile(m3ufile) try: m3u.refresh() except: um.error(messages["m3u_readfailed"]) sys.exit(1) music, unknown, dups=_process(m3u.files, verbose=options.verbose) if music is None or unknown is None or dups is None: return #print "*** music: ", music #print "*** unknown: ", unknown #print "*** dups: ", dups try: _gen_music_dir(options.verbose, um, targetdir, music, options.refresh) except Exception, e: um.error(messages["error_genmusic"] % e)
try: o=OParser(susage, soptions) except optparse.OptionError, e: print "! invalid option: %s" % e sys.exit(1) options, args=o.parse() um=UserMessaging(sname, False, prepend="#") if options.webhelp: import webbrowser webbrowser.open(webhelp_url) sys.exit(0) if len(args) != 1: um.error(messages["args"]) sys.exit(1) """ -p and -f : download all from 'page' onwards -p : download only 'page' -f : download all from page 1 *no options* : download all from page 1 """ all_pages=True page=1 if options.page: try: page=int(options.page) except: