remove --nochdir and bump version

This commit is contained in:
lynxize 2025-06-20 17:00:45 -06:00
parent 5047f729eb
commit 3e70280cc4
Signed by: lynxize
GPG key ID: 8615849B8532CD77

View file

@ -13,13 +13,12 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
__version__ = "2.0-pre1"
__title__ = "KeyJ's iPod shuffle Database Builder"
__version__ = "1.0"
__author__ = "Martin Fiedler"
__email__ = "martin.fiedler@gmx.net"
""" VERSION HISTORY """ VERSION HISTORY
2.0-pre1 (2025-06-20)
* updated to python 3
* removed --nochdir flag
1.0-rc1 (2006-04-26) 1.0-rc1 (2006-04-26)
* finally(!) added the often-requested auto-rename feature (-r option) * finally(!) added the often-requested auto-rename feature (-r option)
0.7-pre1 (2005-06-09) 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 os.path.splitext(name)[1].lower() in (".mp3", ".m4a", ".m4b", ".m4p", ".aa", ".wav"):
if may_rename: name = rename_safely(path, name) if may_rename: name = rename_safely(path, name)
return 1, make_key(name), prefix + name return 1, make_key(name), prefix + name
except OSError: except OSError: pass
pass
return None return None
@ -287,7 +285,7 @@ def browse(path: string, interactive: bool):
if path[-1] == "/": path = path[:-1] if path[-1] == "/": path = path[:-1]
displaypath = path[1:] displaypath = path[1:]
if not displaypath: displaypath = "/" if not displaypath: displaypath = ""
while interactive: while interactive:
choice = input(f"include '{displaypath}'? [(Y)es, (N)o, (A)ll] ")[:1].lower() choice = input(f"include '{displaypath}'? [(Y)es, (N)o, (A)ll] ")[:1].lower()
@ -452,7 +450,7 @@ def write_shuffle(count):
def main(dirs): def main(dirs):
global header, iTunesSD_file, total_count, KnownEntries, Rules global header, iTunesSD_file, total_count, KnownEntries, Rules
log("Welcome to %s, version %s" % (__title__, __version__)) log(f"Welcome to ShuffleDB, version {__version__}")
log() log()
try: try:
@ -512,7 +510,7 @@ Please make sure that:
log("Searching for files on your iPod.") log("Searching for files on your iPod.")
try: try:
for dir in dirs: for dir in dirs:
browse("./" + dir, args.interactive) browse(dir, args.interactive)
log(f"{total_count} playable files were found on your iPod.") log(f"{total_count} playable files were found on your iPod.")
log() log()
log("Fixing iTunesSD header.") log("Fixing iTunesSD header.")
@ -541,11 +539,12 @@ Please make sure that:
if __name__ == "__main__": if __name__ == "__main__":
import argparse 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('directories', nargs='*', default=["."])
parser.add_argument("-i", "--interactive", action="store_true", help = "prompt before browsing each directory") 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("-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("-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("-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") 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() args = parser.parse_args()
if not args.nochdir:
try: os.chdir(os.path.abspath(__file__))
except OSError: pass
open_log() open_log()
try: try:
main(args.directories) main(args.directories)