Skip to content

Commit 48d4efd

Browse files
committed
flatten: ensure items are strings
this flatten could be improved but was made with a specific structure in mind
1 parent dc0c426 commit 48d4efd

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

itunes_app_scraper/scraper.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,10 @@ def get_app_details(self, app_id, country="nl", lang="", add_ratings=False, flat
227227
if flatten:
228228
for field in app:
229229
if isinstance(app[field], list):
230-
app[field] = ",".join(app[field])
230+
app[field] = ",".join([str(item) for item in app[field]])
231231
elif isinstance(app[field], dict):
232-
app[field] = ", ".join(["%s star: %s" % (key, value) for key,value in app[field].items()])
232+
# Apparently there was only a single dict in the response of star ratings
233+
app[field] = ", ".join(["%s star: %s" % (str(key), str(value)) for key,value in app[field].items()])
233234

234235
return app
235236

0 commit comments

Comments
 (0)