From a70b172940a638586d5913468697d9509c5380b2 Mon Sep 17 00:00:00 2001 From: Alexis MARQUIS Date: Sat, 13 Jul 2024 15:18:17 +0200 Subject: [PATCH 1/8] Handle application/octet-stream content type --- src/synology_dsm/synology_dsm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/synology_dsm/synology_dsm.py b/src/synology_dsm/synology_dsm.py index 8b48c57..58146d1 100644 --- a/src/synology_dsm/synology_dsm.py +++ b/src/synology_dsm/synology_dsm.py @@ -384,7 +384,7 @@ async def _execute_request( ]: return dict(await response.json(content_type=content_type)) - if content_type.startswith("image"): + if content_type == "application/octet-stream" or content_type.startswith("image"): return await response.read() return await response.text() From 0faabf4479ffcb5707c6926cc0f99547ba98b4a3 Mon Sep 17 00:00:00 2001 From: Alexis MARQUIS Date: Sat, 13 Jul 2024 16:02:42 +0200 Subject: [PATCH 2/8] Typos --- tests/api_data/dsm_7/__init__.py | 2 +- tests/api_data/dsm_7/core/const_7_core_external_usb.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/api_data/dsm_7/__init__.py b/tests/api_data/dsm_7/__init__.py index 037a5c6..039dbdb 100644 --- a/tests/api_data/dsm_7/__init__.py +++ b/tests/api_data/dsm_7/__init__.py @@ -1,4 +1,4 @@ -"""DSM 6 datas.""" +"""DSM 7 datas.""" from .const_7_api_auth import ( DSM_7_AUTH_LOGIN, diff --git a/tests/api_data/dsm_7/core/const_7_core_external_usb.py b/tests/api_data/dsm_7/core/const_7_core_external_usb.py index 31b282d..aeaaa09 100644 --- a/tests/api_data/dsm_7/core/const_7_core_external_usb.py +++ b/tests/api_data/dsm_7/core/const_7_core_external_usb.py @@ -1,4 +1,4 @@ -"""DSM 6 SYNO.Core.ExternalDevice.Storage.USB data.""" +"""DSM 7 SYNO.Core.ExternalDevice.Storage.USB data.""" DSM_7_CORE_EXTERNAL_USB_DS1821_PLUS_NO_EXTERNAL_USB = { "data": {"devices": []}, From 15eea908e0418e34d284ca53a2ff7e43ca0f241e Mon Sep 17 00:00:00 2001 From: Alexis MARQUIS Date: Sat, 13 Jul 2024 16:04:10 +0200 Subject: [PATCH 3/8] Fix download/thumbnail shared photos from shared albums --- src/synology_dsm/api/photos/__init__.py | 57 ++++++++++++++++--------- src/synology_dsm/api/photos/model.py | 2 + 2 files changed, 40 insertions(+), 19 deletions(-) diff --git a/src/synology_dsm/api/photos/__init__.py b/src/synology_dsm/api/photos/__init__.py index 953bc97..cc620f0 100644 --- a/src/synology_dsm/api/photos/__init__.py +++ b/src/synology_dsm/api/photos/__init__.py @@ -33,12 +33,12 @@ async def get_albums( for album in data["list"]: albums.append( - SynoPhotosAlbum(album["id"], album["name"], album["item_count"]) + SynoPhotosAlbum(album["id"], album["name"], album["item_count"], album["passphrase"] if album["passphrase"] != '' else None) ) return albums def _raw_data_to_items( - self, raw_data: bytes | dict | str + self, raw_data: bytes | dict | str, passphrase: str | None = None ) -> list[SynoPhotosItem] | None: """Parse the raw data response to a list of photo items.""" items: list[SynoPhotosItem] = [] @@ -62,6 +62,7 @@ def _raw_data_to_items( item["additional"]["thumbnail"]["cache_key"], size, item["owner_user_id"] == 0, + passphrase, ) ) return items @@ -80,7 +81,7 @@ async def get_items_from_album( "additional": '["thumbnail"]', }, ) - return self._raw_data_to_items(raw_data) + return self._raw_data_to_items(raw_data, album.passphrase) async def get_items_from_shared_space( self, offset: int = 0, limit: int = 100 @@ -118,13 +119,19 @@ async def download_item(self, item: SynoPhotosItem) -> bytes | None: download_api = self.DOWNLOAD_API_KEY if item.is_shared: download_api = self.DOWNLOAD_FOTOTEAM_API_KEY + + params = { + "unit_id": f"[{item.item_id}]", + "cache_key": item.thumbnail_cache_key, + } + + if item.passphrase is not None : + params["passphrase"] = item.passphrase + raw_data = await self._dsm.get( download_api, "download", - { - "unit_id": f"[{item.item_id}]", - "cache_key": item.thumbnail_cache_key, - }, + params, ) if isinstance(raw_data, bytes): return raw_data @@ -135,15 +142,21 @@ async def download_item_thumbnail(self, item: SynoPhotosItem) -> bytes | None: download_api = self.THUMBNAIL_API_KEY if item.is_shared: download_api = self.THUMBNAIL_FOTOTEAM_API_KEY + + params = { + "id": item.item_id, + "cache_key": item.thumbnail_cache_key, + "size": item.thumbnail_size, + "type": "unit", + } + + if item.passphrase is not None : + params["passphrase"] = item.passphrase + raw_data = await self._dsm.get( download_api, "get", - { - "id": item.item_id, - "cache_key": item.thumbnail_cache_key, - "size": item.thumbnail_size, - "type": "unit", - }, + params, ) if isinstance(raw_data, bytes): return raw_data @@ -154,13 +167,19 @@ async def get_item_thumbnail_url(self, item: SynoPhotosItem) -> str: download_api = self.THUMBNAIL_API_KEY if item.is_shared: download_api = self.THUMBNAIL_FOTOTEAM_API_KEY + + params = { + "id": item.item_id, + "cache_key": item.thumbnail_cache_key, + "size": item.thumbnail_size, + "type": "unit", + } + + if item.passphrase is not None : + params["passphrase"] = item.passphrase + return await self._dsm.generate_url( download_api, "get", - { - "id": item.item_id, - "cache_key": item.thumbnail_cache_key, - "size": item.thumbnail_size, - "type": "unit", - }, + params, ) diff --git a/src/synology_dsm/api/photos/model.py b/src/synology_dsm/api/photos/model.py index 40985cf..2d31f5c 100644 --- a/src/synology_dsm/api/photos/model.py +++ b/src/synology_dsm/api/photos/model.py @@ -10,6 +10,7 @@ class SynoPhotosAlbum: album_id: int name: str item_count: int + passphrase: str @dataclass @@ -23,3 +24,4 @@ class SynoPhotosItem: thumbnail_cache_key: str thumbnail_size: str is_shared: bool + passphrase: str From 512b23555058efae2cbbfcbf81608a133180df59 Mon Sep 17 00:00:00 2001 From: Alexis MARQUIS Date: Sat, 13 Jul 2024 16:06:13 +0200 Subject: [PATCH 4/8] Add tests --- tests/__init__.py | 6 ++- tests/api_data/dsm_7/__init__.py | 2 + tests/api_data/dsm_7/photos/const_7_photo.py | 47 ++++++++++++++++++++ tests/test_synology_dsm_7.py | 32 ++++++++++++- 4 files changed, 85 insertions(+), 2 deletions(-) diff --git a/tests/__init__.py b/tests/__init__.py index d4acbe0..56b189c 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -71,6 +71,7 @@ DSM_7_DSM_INFORMATION, DSM_7_FOTO_ALBUMS, DSM_7_FOTO_ITEMS, + DSM_7_FOTO_ITEMS_SHARED_ALBUM, DSM_7_FOTO_ITEMS_SEARCHED, DSM_7_FOTO_SHARED_ITEMS, ) @@ -285,7 +286,10 @@ async def _execute_request(self, method, url, params, **kwargs): return DSM_7_FOTO_ALBUMS if SynoPhotos.BROWSE_ITEM_API_KEY in url: - return DSM_7_FOTO_ITEMS + if "album_id=3" in url: + return DSM_7_FOTO_ITEMS_SHARED_ALBUM + else: + return DSM_7_FOTO_ITEMS if SynoPhotos.SEARCH_API_KEY in url: return DSM_7_FOTO_ITEMS_SEARCHED diff --git a/tests/api_data/dsm_7/__init__.py b/tests/api_data/dsm_7/__init__.py index 039dbdb..3865ef6 100644 --- a/tests/api_data/dsm_7/__init__.py +++ b/tests/api_data/dsm_7/__init__.py @@ -14,6 +14,7 @@ from .photos.const_7_photo import ( DSM_7_FOTO_ALBUMS, DSM_7_FOTO_ITEMS, + DSM_7_FOTO_ITEMS_SHARED_ALBUM, DSM_7_FOTO_ITEMS_SEARCHED, DSM_7_FOTO_SHARED_ITEMS, ) @@ -29,6 +30,7 @@ "DSM_7_DSM_INFORMATION", "DSM_7_FOTO_ALBUMS", "DSM_7_FOTO_ITEMS", + "DSM_7_FOTO_ITEMS_SHARED_ALBUM", "DSM_7_FOTO_ITEMS_SEARCHED", "DSM_7_FOTO_SHARED_ITEMS", ] diff --git a/tests/api_data/dsm_7/photos/const_7_photo.py b/tests/api_data/dsm_7/photos/const_7_photo.py index e3c78d3..7d885fb 100644 --- a/tests/api_data/dsm_7/photos/const_7_photo.py +++ b/tests/api_data/dsm_7/photos/const_7_photo.py @@ -38,6 +38,25 @@ "type": "normal", "version": 195694, }, + { + "cant_migrate_condition": {}, + "condition": {}, + "create_time": 1718658534, + "end_time": 1719075481, + "freeze_album": False, + "id": 3, + "item_count": 1, + "name": "Album3", + "owner_user_id": 7, + "passphrase": "NiXlv1i2N", + "shared": False, + "sort_by": "default", + "sort_direction": "default", + "start_time": 1659724703, + "temporary_shared": False, + "type": "normal", + "version": 102886, + }, ] }, "success": True, @@ -111,6 +130,34 @@ }, } +DSM_7_FOTO_ITEMS_SHARED_ALBUM = { + "success": True, + "data": { + "list": [ + { + "id": 29807, + "filename": "20221115_185645.jpg", + "filesize": 2644859, + "time": 1668538602, + "indexed_time": 1668564550862, + "owner_user_id": 7, + "folder_id": 597, + "type": "photo", + "additional": { + "thumbnail": { + "m": "ready", + "xl": "ready", + "preview": "broken", + "sm": "ready", + "cache_key": "29810_1668560967", + "unit_id": 29807, + } + }, + }, + ] + }, +} + DSM_7_FOTO_SHARED_ITEMS = { "success": True, "data": { diff --git a/tests/test_synology_dsm_7.py b/tests/test_synology_dsm_7.py index d3ffef7..b886c9f 100644 --- a/tests/test_synology_dsm_7.py +++ b/tests/test_synology_dsm_7.py @@ -179,13 +179,21 @@ async def test_photos(self, dsm_7): albums = await dsm_7.photos.get_albums() assert albums - assert len(albums) == 2 + assert len(albums) == 3 assert albums[0].album_id == 4 assert albums[0].name == "Album1" assert albums[0].item_count == 3 + assert albums[0].passphrase is None + assert albums[1].album_id == 1 assert albums[1].name == "Album2" assert albums[1].item_count == 1 + assert albums[1].passphrase is None + + assert albums[2].album_id == 3 + assert albums[2].name == "Album3" + assert albums[2].item_count == 1 + assert albums[2].passphrase == 'NiXlv1i2N' items = await dsm_7.photos.get_items_from_album(albums[0]) assert items @@ -193,12 +201,17 @@ async def test_photos(self, dsm_7): assert items[0].file_name == "20221115_185642.jpg" assert items[0].thumbnail_cache_key == "29807_1668560967" assert items[0].thumbnail_size == "xl" + assert items[0].passphrase is None + assert items[1].file_name == "20221115_185643.jpg" assert items[1].thumbnail_cache_key == "29808_1668560967" assert items[1].thumbnail_size == "m" + assert items[1].passphrase is None + assert items[2].file_name == "20221115_185644.jpg" assert items[2].thumbnail_cache_key == "29809_1668560967" assert items[2].thumbnail_size == "sm" + assert items[2].passphrase is None thumb_url = await dsm_7.photos.get_item_thumbnail_url(items[0]) assert thumb_url @@ -218,6 +231,23 @@ async def test_photos(self, dsm_7): "&_sid=session_id&SynoToken=Sy%C3%B10_T0k%E2%82%AC%C3%B1" ) + items = await dsm_7.photos.get_items_from_album(albums[2]) + assert items + assert len(items) == 1 + assert items[0].file_name == "20221115_185645.jpg" + assert items[0].thumbnail_cache_key == "29810_1668560967" + assert items[0].thumbnail_size == "xl" + assert items[0].passphrase == 'NiXlv1i2N' + + thumb_url = await dsm_7.photos.get_item_thumbnail_url(items[0]) + assert thumb_url + assert thumb_url == ( + "https://nas.mywebsite.me:443/webapi/entry.cgi?" + "id=29807&cache_key=29810_1668560967&size=xl&type=unit" + "&passphrase=NiXlv1i2N&api=SYNO.Foto.Thumbnail&version=2&method=get" + "&_sid=session_id&SynoToken=Sy%C3%B10_T0k%E2%82%AC%C3%B1" + ) + items = await dsm_7.photos.get_items_from_search(albums[0]) assert items assert len(items) == 2 From a3c42581d0aae73dcb2e66c61951e4705ac97a58 Mon Sep 17 00:00:00 2001 From: Alexis MARQUIS Date: Sun, 14 Jul 2024 17:25:19 +0200 Subject: [PATCH 5/8] Query shared albums not owned by user --- src/synology_dsm/api/photos/__init__.py | 23 ++++++++++++++++------- tests/__init__.py | 2 +- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/synology_dsm/api/photos/__init__.py b/src/synology_dsm/api/photos/__init__.py index cc620f0..7a5f4a8 100644 --- a/src/synology_dsm/api/photos/__init__.py +++ b/src/synology_dsm/api/photos/__init__.py @@ -26,7 +26,11 @@ async def get_albums( """Get a list of all albums.""" albums: list[SynoPhotosAlbum] = [] raw_data = await self._dsm.get( - self.BROWSE_ALBUMS_API_KEY, "list", {"offset": offset, "limit": limit} + self.BROWSE_ALBUMS_API_KEY, "list", { + "offset": offset, + "limit": limit, + "category": "normal_share_with_me" + } ) if not isinstance(raw_data, dict) or (data := raw_data.get("data")) is None: return None @@ -71,15 +75,20 @@ async def get_items_from_album( self, album: SynoPhotosAlbum, offset: int = 0, limit: int = 100 ) -> list[SynoPhotosItem] | None: """Get a list of all items from given album.""" + params = { + "offset": offset, + "limit": limit, + "additional": '["thumbnail"]', + } + if album.passphrase is not None: + params["passphrase"] = album.passphrase + else: + params["album_id"] = album.album_id + raw_data = await self._dsm.get( self.BROWSE_ITEM_API_KEY, "list", - { - "album_id": album.album_id, - "offset": offset, - "limit": limit, - "additional": '["thumbnail"]', - }, + params, ) return self._raw_data_to_items(raw_data, album.passphrase) diff --git a/tests/__init__.py b/tests/__init__.py index 56b189c..4f72df1 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -286,7 +286,7 @@ async def _execute_request(self, method, url, params, **kwargs): return DSM_7_FOTO_ALBUMS if SynoPhotos.BROWSE_ITEM_API_KEY in url: - if "album_id=3" in url: + if "passphrase" in url: return DSM_7_FOTO_ITEMS_SHARED_ALBUM else: return DSM_7_FOTO_ITEMS From 1703a40cc440758ac115c3372424867c4a6ed7fd Mon Sep 17 00:00:00 2001 From: Alexis MARQUIS Date: Sat, 3 Aug 2024 17:07:29 +0200 Subject: [PATCH 6/8] Fixes for pre-commit hooks --- .flake8 | 2 +- tests/__init__.py | 2 +- tests/api_data/dsm_7/__init__.py | 2 +- tests/api_data/dsm_7/photos/const_7_photo.py | 2 +- tests/test_synology_dsm_7.py | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.flake8 b/.flake8 index c2e9783..caca3c6 100644 --- a/.flake8 +++ b/.flake8 @@ -10,6 +10,6 @@ max-line-length = 80 max-complexity = 10 docstring-convention = google per-file-ignores = - tests/*:S101 + tests/*:S101,S105 tests/**/const_*.py:B950 src/synology_dsm/const.py:B950 diff --git a/tests/__init__.py b/tests/__init__.py index 4f72df1..89e0b96 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -71,8 +71,8 @@ DSM_7_DSM_INFORMATION, DSM_7_FOTO_ALBUMS, DSM_7_FOTO_ITEMS, - DSM_7_FOTO_ITEMS_SHARED_ALBUM, DSM_7_FOTO_ITEMS_SEARCHED, + DSM_7_FOTO_ITEMS_SHARED_ALBUM, DSM_7_FOTO_SHARED_ITEMS, ) from .const import ( diff --git a/tests/api_data/dsm_7/__init__.py b/tests/api_data/dsm_7/__init__.py index 3865ef6..5d2770d 100644 --- a/tests/api_data/dsm_7/__init__.py +++ b/tests/api_data/dsm_7/__init__.py @@ -14,8 +14,8 @@ from .photos.const_7_photo import ( DSM_7_FOTO_ALBUMS, DSM_7_FOTO_ITEMS, - DSM_7_FOTO_ITEMS_SHARED_ALBUM, DSM_7_FOTO_ITEMS_SEARCHED, + DSM_7_FOTO_ITEMS_SHARED_ALBUM, DSM_7_FOTO_SHARED_ITEMS, ) diff --git a/tests/api_data/dsm_7/photos/const_7_photo.py b/tests/api_data/dsm_7/photos/const_7_photo.py index 7d885fb..2ae4486 100644 --- a/tests/api_data/dsm_7/photos/const_7_photo.py +++ b/tests/api_data/dsm_7/photos/const_7_photo.py @@ -38,7 +38,7 @@ "type": "normal", "version": 195694, }, - { + { "cant_migrate_condition": {}, "condition": {}, "create_time": 1718658534, diff --git a/tests/test_synology_dsm_7.py b/tests/test_synology_dsm_7.py index b886c9f..2c3bade 100644 --- a/tests/test_synology_dsm_7.py +++ b/tests/test_synology_dsm_7.py @@ -193,7 +193,7 @@ async def test_photos(self, dsm_7): assert albums[2].album_id == 3 assert albums[2].name == "Album3" assert albums[2].item_count == 1 - assert albums[2].passphrase == 'NiXlv1i2N' + assert albums[2].passphrase == "NiXlv1i2N" items = await dsm_7.photos.get_items_from_album(albums[0]) assert items @@ -237,7 +237,7 @@ async def test_photos(self, dsm_7): assert items[0].file_name == "20221115_185645.jpg" assert items[0].thumbnail_cache_key == "29810_1668560967" assert items[0].thumbnail_size == "xl" - assert items[0].passphrase == 'NiXlv1i2N' + assert items[0].passphrase == "NiXlv1i2N" thumb_url = await dsm_7.photos.get_item_thumbnail_url(items[0]) assert thumb_url From dbef571e03a7008f6ef02bf1365d9ecf659c2c96 Mon Sep 17 00:00:00 2001 From: Alexis MARQUIS Date: Sat, 10 Aug 2024 20:08:07 +0200 Subject: [PATCH 7/8] Requested changes --- src/synology_dsm/api/photos/__init__.py | 23 +++++++++++++---------- src/synology_dsm/api/photos/model.py | 6 ++++-- src/synology_dsm/synology_dsm.py | 5 ++++- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/synology_dsm/api/photos/__init__.py b/src/synology_dsm/api/photos/__init__.py index 7a5f4a8..370a77e 100644 --- a/src/synology_dsm/api/photos/__init__.py +++ b/src/synology_dsm/api/photos/__init__.py @@ -26,18 +26,21 @@ async def get_albums( """Get a list of all albums.""" albums: list[SynoPhotosAlbum] = [] raw_data = await self._dsm.get( - self.BROWSE_ALBUMS_API_KEY, "list", { - "offset": offset, - "limit": limit, - "category": "normal_share_with_me" - } + self.BROWSE_ALBUMS_API_KEY, + "list", + {"offset": offset, "limit": limit, "category": "normal_share_with_me"}, ) if not isinstance(raw_data, dict) or (data := raw_data.get("data")) is None: return None for album in data["list"]: albums.append( - SynoPhotosAlbum(album["id"], album["name"], album["item_count"], album["passphrase"] if album["passphrase"] != '' else None) + SynoPhotosAlbum( + album["id"], + album["name"], + album["item_count"], + album["passphrase"] if album["passphrase"] != "" else None, + ) ) return albums @@ -134,7 +137,7 @@ async def download_item(self, item: SynoPhotosItem) -> bytes | None: "cache_key": item.thumbnail_cache_key, } - if item.passphrase is not None : + if item.passphrase is not None: params["passphrase"] = item.passphrase raw_data = await self._dsm.get( @@ -159,7 +162,7 @@ async def download_item_thumbnail(self, item: SynoPhotosItem) -> bytes | None: "type": "unit", } - if item.passphrase is not None : + if item.passphrase is not None: params["passphrase"] = item.passphrase raw_data = await self._dsm.get( @@ -184,8 +187,8 @@ async def get_item_thumbnail_url(self, item: SynoPhotosItem) -> str: "type": "unit", } - if item.passphrase is not None : - params["passphrase"] = item.passphrase + if item.passphrase is not None: + params["passphrase"] = item.passphrase return await self._dsm.generate_url( download_api, diff --git a/src/synology_dsm/api/photos/model.py b/src/synology_dsm/api/photos/model.py index 2d31f5c..2896c1e 100644 --- a/src/synology_dsm/api/photos/model.py +++ b/src/synology_dsm/api/photos/model.py @@ -1,5 +1,7 @@ """Data models for Synology Photos Module.""" +from __future__ import annotations + from dataclasses import dataclass @@ -10,7 +12,7 @@ class SynoPhotosAlbum: album_id: int name: str item_count: int - passphrase: str + passphrase: str | None @dataclass @@ -24,4 +26,4 @@ class SynoPhotosItem: thumbnail_cache_key: str thumbnail_size: str is_shared: bool - passphrase: str + passphrase: str | None diff --git a/src/synology_dsm/synology_dsm.py b/src/synology_dsm/synology_dsm.py index 58146d1..d7c17ca 100644 --- a/src/synology_dsm/synology_dsm.py +++ b/src/synology_dsm/synology_dsm.py @@ -384,7 +384,10 @@ async def _execute_request( ]: return dict(await response.json(content_type=content_type)) - if content_type == "application/octet-stream" or content_type.startswith("image"): + if ( + content_type == "application/octet-stream" + or content_type.startswith("image") + ): return await response.read() return await response.text() From b222c320a660ae84b5213533ad860adb33393f92 Mon Sep 17 00:00:00 2001 From: Alexis MARQUIS Date: Sun, 11 Aug 2024 16:42:57 +0200 Subject: [PATCH 8/8] Review changes --- src/synology_dsm/api/photos/__init__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/synology_dsm/api/photos/__init__.py b/src/synology_dsm/api/photos/__init__.py index 370a77e..83ada14 100644 --- a/src/synology_dsm/api/photos/__init__.py +++ b/src/synology_dsm/api/photos/__init__.py @@ -39,7 +39,7 @@ async def get_albums( album["id"], album["name"], album["item_count"], - album["passphrase"] if album["passphrase"] != "" else None, + album["passphrase"] if album["passphrase"] else None, ) ) return albums @@ -83,7 +83,7 @@ async def get_items_from_album( "limit": limit, "additional": '["thumbnail"]', } - if album.passphrase is not None: + if album.passphrase: params["passphrase"] = album.passphrase else: params["album_id"] = album.album_id @@ -137,7 +137,7 @@ async def download_item(self, item: SynoPhotosItem) -> bytes | None: "cache_key": item.thumbnail_cache_key, } - if item.passphrase is not None: + if item.passphrase: params["passphrase"] = item.passphrase raw_data = await self._dsm.get( @@ -162,7 +162,7 @@ async def download_item_thumbnail(self, item: SynoPhotosItem) -> bytes | None: "type": "unit", } - if item.passphrase is not None: + if item.passphrase: params["passphrase"] = item.passphrase raw_data = await self._dsm.get( @@ -187,7 +187,7 @@ async def get_item_thumbnail_url(self, item: SynoPhotosItem) -> str: "type": "unit", } - if item.passphrase is not None: + if item.passphrase: params["passphrase"] = item.passphrase return await self._dsm.generate_url(