Properly check if pagination is present

This commit is contained in:
Mark Veidemanis 2023-03-11 22:07:56 +00:00
parent 6d6b370327
commit fa2a6c9c77
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
1 changed files with 31 additions and 28 deletions

View File

@ -292,14 +292,15 @@ class LocalPlatformClient(ABC):
if "pagination" in ads:
if ads["pagination"]:
if "next" in ads["pagination"]:
page += 1
ads_iter = await self.enum_ad_ids(page)
if ads_iter is None:
return False
if ads_iter is False:
return False
for ad in ads_iter:
ads_total.append(ad)
if ads["pagination"]["next"] is not None:
page += 1
ads_iter = await self.enum_ad_ids(page)
if ads_iter is None:
return False
if ads_iter is False:
return False
for ad in ads_iter:
ads_total.append(ad)
return ads_total
async def enum_ads(self, requested_asset=None, page=0):
@ -321,14 +322,15 @@ class LocalPlatformClient(ABC):
if "pagination" in ads:
if ads["pagination"]:
if "next" in ads["pagination"]:
page += 1
ads_iter = await self.enum_ads(requested_asset, page)
if ads_iter is None:
return False
if ads_iter is False:
return False
for ad in ads_iter:
ads_total.append([ad[0], ad[1], ad[2], ad[3], ad[4]])
if ads["pagination"]["next"] is not None:
page += 1
ads_iter = await self.enum_ads(requested_asset, page)
if ads_iter is None:
return False
if ads_iter is False:
return False
for ad in ads_iter:
ads_total.append([ad[0], ad[1], ad[2], ad[3], ad[4]])
return ads_total
def last_online_recent(self, date):
@ -413,18 +415,19 @@ class LocalPlatformClient(ABC):
if "pagination" in ads:
if ads["pagination"]:
if "next" in ads["pagination"]:
page += 1
ads_iter = await self.enum_public_ads(
asset, currency, provider, page
)
if ads_iter is None:
return False
if ads_iter is False:
return False
for ad in ads_iter:
to_append = [ad[0], ad[1], ad[2], ad[3], ad[4], ad[5]]
if to_append not in to_return:
to_return.append(to_append)
if ads["pagination"]["next"] is not None:
page += 1
ads_iter = await self.enum_public_ads(
asset, currency, provider, page
)
if ads_iter is None:
return False
if ads_iter is False:
return False
for ad in ads_iter:
to_append = [ad[0], ad[1], ad[2], ad[3], ad[4], ad[5]]
if to_append not in to_return:
to_return.append(to_append)
return to_return
async def cheat(self, assets=None):