From 0df59f3a52f5534efe75ed65f3640ec9532b0394 Mon Sep 17 00:00:00 2001 From: ste94pz <49609029+ste94pz@users.noreply.github.com> Date: Sun, 15 Dec 2024 12:46:37 +0100 Subject: [PATCH 1/2] Fix to restore functionality of "item condition" filter --- src/pyVinted/items/items.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pyVinted/items/items.py b/src/pyVinted/items/items.py index 9c36171..39eeec2 100644 --- a/src/pyVinted/items/items.py +++ b/src/pyVinted/items/items.py @@ -71,7 +71,7 @@ def parseUrl(self, url, nbrItems=20, page=1, time=None) -> Dict: map(str, [tpl[1] for tpl in querys if tpl[0] == "material_ids[]"]) ), "status_ids": ",".join( - map(str, [tpl[1] for tpl in querys if tpl[0] == "status[]"]) + map(str, [tpl[1] for tpl in querys if tpl[0] == "status_ids[]"]) ), "country_ids": ",".join( map(str, [tpl[1] for tpl in querys if tpl[0] == "country_ids[]"]) From 0a3a362d97df71d8d302ff3dc6f4d50ee8a4aa0a Mon Sep 17 00:00:00 2001 From: ste94pz <49609029+ste94pz@users.noreply.github.com> Date: Sat, 21 Dec 2024 22:10:35 +0100 Subject: [PATCH 2/2] Add "getDescription" and "getPhotos" methods "getDescription" obtains the item description as is or translated, and returns it as string. "getPhotos" obtains the links for the full size version of the item photos and returns them in a set. Both return "None" in case of exception. --- src/pyVinted/items/item.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/pyVinted/items/item.py b/src/pyVinted/items/item.py index 82ba0de..877a6bf 100644 --- a/src/pyVinted/items/item.py +++ b/src/pyVinted/items/item.py @@ -1,6 +1,7 @@ from datetime import datetime, timezone from pyVinted.requester import requester - +from urllib.parse import urlparse +from pyVinted.settings import Urls class Item: def __init__(self, data): @@ -31,3 +32,25 @@ def isNewItem(self, minutes=3): delta = datetime.now(timezone.utc) - self.created_at_ts return delta.total_seconds() < minutes * 60 + def getDescription(self, translated=True): + locale = urlparse(self.url).netloc + requester.setLocale(locale) + try: + response = requester.get(url=f"https://{locale}{Urls.VINTED_API_URL}/items/{self.id}/plugins/translatable?localize={translated}") + response = response.json() + return response["plugins"][1]["data"]["description"] + except: + return None + + def getPhotos(self): + locale = urlparse(self.url).netloc + requester.setLocale(locale) + try: + response = requester.get(url=f"https://{locale}{Urls.VINTED_API_URL}/items/{self.id}") + response = response.json() + urls = set() + for photo in response["item"]["photos"]: + urls.add(photo["full_size_url"]) + return urls + except: + return None