inthreedee / photoprism-transfer-album

Transfer a Google Photos album to a new Photoprism album
GNU General Public License v3.0
109 stars 12 forks source link

(No such file or directory #2

Closed milindpatel63 closed 2 years ago

milindpatel63 commented 2 years ago

I am getting the following error when trying to run the script.

awk: cannot open /media/drive/Photos/Takeout/Google\ Photos/AlbumName/*/.json (No such file or directory)

inthreedee commented 2 years ago

I'm assuming you replaced the album's name with "AlbumName" and it's not trying to find a literal directory named "AlbumName"? Does that directory structure it's looking in make sense based on where your takeout files actually are?

If so, are you running the script from a shell other than bash? It uses bash's globstar matching to search the directories so your shell needs to support globstar.

If that doesn't help, you can try this fork of the project. It's a bit more user-friendly and uses slightly different searching and matching. That fork was also merged here in this branch, but I've been iterating and improving on it and haven't fully tested my changes yet. No guarantees that it works, but if you feel like helping test it, that's always welcome.

The main change in that fork/branch is it uses SHA hashes to match photos to be added to the album instead of file names. It's much faster and this is fine if you've uploaded your photos to Photoprism directly from your Google Photos takeout (the hashes will match), but it won't work if you've uploaded originals to Photoprism (the hashes won't match since google compresses photos). I am working on adding support for both modes into that hashes branch.

milindpatel63 commented 2 years ago

Thanks for the quick reply. Yes i found the fork shortly after I opened this issue. That fork seems to work. But I have some issues in that as well. I don't know if you could help, since it's not your project,

But in that fork, some of my albums are not being shown in photoprism. In console i get,

Creating album Some Album Name...
Album UID:
Adding photos...

Then a bunch of photos are added to that album, then

Submitting batch to album id pr3rvru10k97u5g9

So it seems like a album is created but it is not assigned a id at first, but photos are added to some album id. Due to this, this album is not being shown in photoprism.

There are quite a few of albums that are not shown for me, while many are added just fine. It's weird.

milindpatel63 commented 2 years ago

Never mind, I got it... So it seems, whichever google photos album had enrichments, like texts, location block, etc. in them, those albums weren't being added by that script. So like in the metadata.json file, Here's the original file that was causing problems with script...

  "title": "Some Album Name",
  "description": "",
  "access": "protected",
  "date": {
    "timestamp": "1624465723",
    "formatted": "Jun 23, 2021, 4:28:43 PM UTC"
  },
  "location": "",
  "geoData": {
    "latitude": 0.0,
    "longitude": 0.0,
    "altitude": 0.0,
    "latitudeSpan": 0.0,
    "longitudeSpan": 0.0
  },
  "enrichments": [{
    "locationEnrichment": {
      "location": [{
        "name": "Some Location Name",
        "description": "Some Address",
        "latitudeE7": randomLatNumber,
        "longitudeE7": randomLongNumber
      }]
    }
  }]
}

and I modified it and remove the unnecessary enrichments since they are a google photos native feature and not supported right now in photoprism.

{
  "title": "Some Album Name",
  "description": "",
  "access": "protected",
  "date": {
    "timestamp": "1624465723",
    "formatted": "Jun 23, 2021, 4:28:43 PM UTC"
  },
  "location": "",
  "geoData": {
    "latitude": 0.0,
    "longitude": 0.0,
    "altitude": 0.0,
    "latitudeSpan": 0.0,
    "longitudeSpan": 0.0
  }
}
inthreedee commented 2 years ago

Good investigative work! That fork does some json parsing that must be getting tripped up on the enrichments section. I'm going to be looking into that parsing logic next and will try to make sure it handles this scenario. Thanks, this is very helpful.

inthreedee commented 2 years ago

Going to reopen this so it doesn't get lost. The improvements from @cincodenada's fork have been merged to the main branch and I've done a bunch of other updates along the way. Next up is to figure out why it got hung up on the enrichments.

@milindpatel63 If you're able to give it another test, I'm curious if the new name matching mode vs hash matching mode makes any difference. Also if it spits out any warnings or errors in either mode that would help me figure out what's going on.

To see all the new configuration options, run the script with the --help argument. You can switch modes, specify individual albums for import, and set target directories.

inthreedee commented 2 years ago

Okay, this should be fixed in https://github.com/inthreedee/photoprism-transfer-album/commit/73942bcfa3ff85835c44c118a79cd5fe9a30550c

The problem was that second description field in the enrichments section tripping up our parsing of the metadata.json file. To fix it, we'll just throw out any additional description matches after the first one.

Thanks @milindpatel63 for reporting this!