mvlnetdev / photoprism_client

A Python client to interact with photoprism.
MIT License
18 stars 12 forks source link

Downloading an image results in a .svg file #11

Closed vdleun closed 8 months ago

vdleun commented 8 months ago

These are my first steps with photoprism_client version 0.2.1, installed using pip install --break-system-packages photoprism-client on a Debian Bookworm system. Photoprism is running in a Docker container on my NAS and is behind a NGINX proxy for connecting to Photoprism using HTTPS.

When running this code, I get a test.jpg.svg file as a result.

#!/usr/bin/python3

from photoprism.Session import Session
from photoprism.Photo import Photo
import random

pp_session = Session("USERNAME", "PASSWORD", "PHOTOPRISM_URL", use_https=True, verify_cert=True)
pp_session.create()

random_offset = random.randint(0,5000)

p = Photo(pp_session)
data = p.search(query='type:image', count=1, offset=random_offset)
print(data)
p.download_file(data[0]["Hash"], filename="test.jpg")

When running this code without defining a filename="test.jpg" parameter I get the Content-Disposition error which is mentioned in another issue here on github.

Running the script, gives this output:

$ ./test.py 

[{'ID': '6296', 'DocumentID': '7d874b7d-9826-46d1-81cf-88ecfb83ca04', 'UID': 'prx16jmeylyvd2qa', 'Type': 'image', 'TypeSrc': '', 'TakenAt': '2018-05-14T19:07:50Z', 'TakenAtLocal': '2018-05-14T19:07:50Z', 'TakenSrc': 'meta', 'TimeZone': '', 'Path': '2018/05', 'Name': '20180514_190750_5DD837FA', 'OriginalName': "Google Photo's/2018/05/img_0420", 'Title': 'Fruit / 2018', 'Description': '', 'Year': 2018, 'Month': 5, 'Day': 14, 'Country': 'zz', 'Stack': 0, 'Favorite': False, 'Private': False, 'Iso': 25, 'FocalLength': 29, 'FNumber': 2.2, 'Exposure': '1/144', 'Quality': 3, 'Resolution': 12, 'Color': 1, 'Scan': False, 'Panorama': False, 'CameraID': 20, 'CameraSrc': 'meta', 'CameraModel': 'iPhone SE', 'CameraMake': 'Apple', 'LensID': 7, 'LensModel': 'iPhone SE back camera 4.15mm f/2.2', 'LensMake': 'Apple', 'Lat': 0, 'Lng': 0, 'CellID': 'zz', 'PlaceID': 'zz', 'PlaceSrc': '', 'PlaceLabel': 'Unknown', 'PlaceCity': 'Unknown', 'PlaceState': 'Unknown', 'PlaceCountry': 'zz', 'InstanceID': '', 'FileUID': 'frx16jm20ikks846', 'FileRoot': '/', 'FileName': '2018/05/20180514_190750_5DD837FA.jpg', 'Hash': '03f420376dfc0fa4b8770b250fc91d55b872e0b0', 'Width': 4032, 'Height': 3024, 'Portrait': False, 'Merged': False, 'CreatedAt': '2023-06-29T20:06:58Z', 'UpdatedAt': '2023-10-31T13:22:12Z', 'EditedAt': '0001-01-01T00:00:00Z', 'CheckedAt': '2023-10-31T13:22:12Z', 'DeletedAt': '0001-01-01T00:00:00Z', 'Files': None}]

The file test.jpg.svg is now on my filesystem. The content of this scalable vector graphics .svg file is:

$ cat test.jpg.svg 

<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
<path fill="none" d="M0 0h24v24H0zm0 0h24v24H0zm21 19c0 1.1-.9 2-2 2H5c-1.1 0-2-.9-2-2V5c0-1.1.9-2 2-2h14c1.1 0 2 .9 2 2"/>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M21 5v6.59l-3-3.01-4 4.01-4-4-4 4-3-3.01V5c0-1.1.9-2 2-2h14c1.1 0 2 .9 2 2zm-3 6.42l3 3.01V19c0 1.1-.9 2-2 2H5c-1.1 0-2-.9-2-2v-6.58l3 2.99 4-4 4 4 4-3.99z"/></svg>

My script is based on an example in this repository. Am I doing something wrong or is this a bug?

vdleun commented 8 months ago

Problem is solved when using the latest master from the repository. So I think it's a good idea to do a new release of the software?