diff --git a/rebuild_db.py b/rebuild_db.py index ca0bc8f..34bd8cb 100755 --- a/rebuild_db.py +++ b/rebuild_db.py @@ -13,13 +13,12 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -__title__ = "KeyJ's iPod shuffle Database Builder" -__version__ = "1.0" -__author__ = "Martin Fiedler" -__email__ = "martin.fiedler@gmx.net" +__version__ = "2.0-pre1" """ VERSION HISTORY +2.0-pre1 (2025-06-20) + * updated to python 3 + * removed --nochdir flag 1.0-rc1 (2006-04-26) * finally(!) added the often-requested auto-rename feature (-r option) 0.7-pre1 (2005-06-09) @@ -277,8 +276,7 @@ def file_entry(path, name, prefix=""): if os.path.splitext(name)[1].lower() in (".mp3", ".m4a", ".m4b", ".m4p", ".aa", ".wav"): if may_rename: name = rename_safely(path, name) return 1, make_key(name), prefix + name - except OSError: - pass + except OSError: pass return None @@ -287,7 +285,7 @@ def browse(path: string, interactive: bool): if path[-1] == "/": path = path[:-1] displaypath = path[1:] - if not displaypath: displaypath = "/" + if not displaypath: displaypath = "" while interactive: choice = input(f"include '{displaypath}'? [(Y)es, (N)o, (A)ll] ")[:1].lower() @@ -452,7 +450,7 @@ def write_shuffle(count): def main(dirs): global header, iTunesSD_file, total_count, KnownEntries, Rules - log("Welcome to %s, version %s" % (__title__, __version__)) + log(f"Welcome to ShuffleDB, version {__version__}") log() try: @@ -512,7 +510,7 @@ Please make sure that: log("Searching for files on your iPod.") try: for dir in dirs: - browse("./" + dir, args.interactive) + browse(dir, args.interactive) log(f"{total_count} playable files were found on your iPod.") log() log("Fixing iTunesSD header.") @@ -541,11 +539,12 @@ Please make sure that: if __name__ == "__main__": import argparse - parser = argparse.ArgumentParser(description="Rebuild iPod shuffle database.") + parser = argparse.ArgumentParser( + description="Rebuild iPod shuffle database. Updated fork of Martin Fiedler's rebuild_db (https://shuffle-db.sourceforge.net/)", + ) parser.add_argument('directories', nargs='*', default=["."]) parser.add_argument("-i", "--interactive", action="store_true", help = "prompt before browsing each directory") parser.add_argument("-s", "--nosmart", action="store_true", help = "do not use smart shuffle") - parser.add_argument("-n", "--nochdir", action="store_true", help = "do not change directory to this scripts directory first") parser.add_argument("-l", "--nolog", action="store_true", help = "do not create a log file") parser.add_argument("-f", "--force", action="store_true", help = "always rebuild database entries, do not re-use old ones") parser.add_argument("-L", "--logfile", action="store", default="rebuild_db.log.txt", help = "set log file name") @@ -554,10 +553,6 @@ if __name__ == "__main__": args = parser.parse_args() - if not args.nochdir: - try: os.chdir(os.path.abspath(__file__)) - except OSError: pass - open_log() try: main(args.directories)