Philipp91 / picasa2digikam

Script to migrate Picasa metadata to digiKam
GNU General Public License v3.0
18 stars 3 forks source link

error - No digiKam AlbumRoot found #25

Closed dan86603 closed 6 months ago

dan86603 commented 6 months ago

I'm having trouble running the code. I'm an absolute beginner at Python and I'm using VScode to run & debug, on Windows 10.

This is the powersell prompt (terminal inside VScode) running debug with arguments:

PS D:\dla\Dla-Projects\Git\picasa2digikam> d:\dla\Dla-Projects\Git\picasa2digikam.venv\Scripts\python.exe c:\Users\Dan.vscode\extensions\ms-python.debugpy-2024.0.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher 50742 -- D:\dla\Dla-Projects\Git\picasa2digikam\main.py --photos_dir="D:\temp\Photos for digikam test" --digikam_db="C:\Temp\_Digikam Database\digikam4.db" --contacts="C:\Users\Dan\AppData\Local\Google\Picasa2\contacts\contacts.xml" WARNING: Cannot determine address of disk E:\ mounted at E:\, so it will be unavailable WARNING: Cannot determine address of disk F:\ mounted at F:\, so it will be unavailable WARNING: Cannot determine address of disk G:\ mounted at G:\, so it will be unavailable WARNING: No photos and no .ini file in D:\temp\Photos for digikam test WARNING: No photos and no .ini file in D:\temp\Photos for digikam test.dtrash WARNING: No photos and no .ini file in D:\temp\Photos for digikam test\2023

Not sure why the code is scanning drives E, F & G?

D:\temp\Photos for digikam test is the only collection in Digikam, I tried both as local collection and on a network share with same result.

Here is the error:

Exception has occurred: ValueError No digiKam AlbumRoot found for D:\temp\Photos for digikam test\2023\2023-12-26, only have {'D:/temp/Photos for digikam test&fileuuid=bbcf04f6-e999-4ee6-90aa-f6c6f02cab07': 5} File "D:\dla\Dla-Projects\Git\picasa2digikam\digikam_db.py", line 112, in find_album_by_dir raise ValueError(f'No digiKam AlbumRoot found for {path}, only have {self.album_roots}') File "D:\dla\Dla-Projects\Git\picasa2digikam\migrator.py", line 128, in migrate_directory album_id = db.find_album_by_dir(input_dir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\dla\Dla-Projects\Git\picasa2digikam\migrator.py", line 107, in migrate_directories_under contact_tags_per_dir[dir] = migrate_directory(dir, files, db, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\dla\Dla-Projects\Git\picasa2digikam\main.py", line 56, in main migrator.migrate_directories_under(input_root_dir=args.photos_dir, db=db, File "D:\dla\Dla-Projects\Git\picasa2digikam\main.py", line 66, in main() ValueError: No digiKam AlbumRoot found for D:\temp\Photos for digikam test\2023\2023-12-26, only have {'D:/temp/Photos for digikam test&fileuuid=bbcf04f6-e999-4ee6-90aa-f6c6f02cab07': 5}

Thank you for any help

Philipp91 commented 6 months ago

No digiKam AlbumRoot found for D:\temp\Photos for digikam test\2023\2023-12-26, only have {'D:/temp/Photos for digikam test&fileuuid=bbcf04f6-e999-4ee6-90aa-f6c6f02cab07': 5}

Try inverting your slashes:

--photos_dir="D:/temp/Photos for digikam test"

The --digikam_db and --contacts paths are interpreted by picasa2digikam under your local Python interpreter, which understands Windows paths in both styles, so there it doesn't matter. The --photos_dir is string-matched against the contents of your digiKam database. And because digiKam is a Linux program, it (presumably) stores paths with forward slashes, even when it runs on Windows.


Then I hope that the &fileuuid=bbcf04f6-e999-4ee6-90aa-f6c6f02cab07 suffix doesn't become an issue. If it still gives the same error with forward slashes, then please try this: Back up the .db file (and your photos, as you should anyway), shut down digiKam and revert any .db file changes you make before ever starting digiKam again. The one change you should make: Download SQLite Browser, open the AlbumRoots table and remove that &fileuuid=bbcf04f6-e999-4ee6-90aa-f6c6f02cab07 part from the corresponding cell in the table (Browse Table -> edit the cell -> Apply -> Write Changes). Also please post the entire value of that cell here so that I can make the script do this automatically in future if it worked for you.

dan86603 commented 6 months ago

Thank you! Deleting &fileuuid=... did the trick. There was no need to change slashes, either way worked the same. During testing I reset the database with a new folder which had two different fileuuid's:

volumeid:?path=D:/temp/Photos for digikam test&fileuuid=f32a52c1-813e-46e5-8507-04c9e4aeff38
volumeid:?path=D:/temp/Photos for digikam test2&fileuuid=121e44e0-ab7b-48c0-8ce0-27e02580d782

On open Digikam resets the database and adds back the fileuuid. But since the script will hopefully only be run once, should not be an issue.