diff options
-rwxr-xr-x | AntennaPodDbFixer.py | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/AntennaPodDbFixer.py b/AntennaPodDbFixer.py index 9966209..5e78924 100755 --- a/AntennaPodDbFixer.py +++ b/AntennaPodDbFixer.py @@ -9,6 +9,13 @@ import getopt def usage(): return sys.argv[0] + " [--help] [--verbose] [corrupt.db] [empty.db]" +def get_db_version(fileName): + return subprocess.run( + ["sqlite3", fileName, "PRAGMA user_version;"], + capture_output=True, + text=True + ).stdout.strip() + def integrity_is_ok(fileName): print("Checking integrity of " + fileName + ".", end="") if verbose: @@ -62,11 +69,7 @@ else: if verbose: print("It seems sqlite3 on this system has the dbpage extension. Good!") -corruptedVersion = subprocess.run( - ["sqlite3", inputFilePath, "PRAGMA user_version;"], - capture_output=True, - text=True - ).stdout.strip() +corruptedVersion = get_db_version(inputFilePath) if corruptedVersion == "0": print("Error: File not found, not a database, or too corrupted for this script.", file=sys.stderr) exit(1) @@ -81,11 +84,7 @@ else: if not os.path.isfile(emptyFilePath): print("If needed, you can download old app versions on F-Droid and export an empty database.") emptyFilePath = input("Enter file path to an EMPTY AntennaPod database with the same version: ") -emptyVersion = subprocess.run( - ["sqlite3", emptyFilePath, "PRAGMA user_version;"], - capture_output=True, - text=True - ).stdout.strip() +emptyVersion = get_db_version(emptyFilePath) print("Empty file version: " + emptyVersion) if corruptedVersion != emptyVersion: print("Error: Application version differs between database files.", file=sys.stderr) |