Cache preview URLs early

Totally not modifying the API to conform with the project based on it
This commit is contained in:
Thomas Wade 2020-04-22 04:52:00 +09:30
parent a70f181673
commit 042f732c69
2 changed files with 17 additions and 1 deletions

View File

@ -339,6 +339,14 @@ class User:
# Get all the submissions on this page
for item in soup.select('.gallery figure'):
sub = Submission.new_or_cached(self._api, int(item.get('id')[4:])) # IDs look like 'sid-35908275', so we just skip the 'sid-'
# Try cache the preview URL early
try:
sub._preview_url = 'https:' + item.select('img')[0].get('src')
sub._has_preview = True
except IndexError:
sub._has_preview = False
submissions.append(sub)
return submissions
@ -360,6 +368,14 @@ class User:
# Get all the submissions on this page
for item in soup.select('.gallery figure'):
sub = Submission.new_or_cached(self._api, int(item.get('id')[4:])) # IDs look like 'sid-35908275', so we just skip the 'sid-'
# Try cache the preview URL early
try:
sub._preview_url = 'https:' + item.select('img')[0].get('src')
sub._has_preview = True
except IndexError:
sub._has_preview = False
submissions.append(sub)
return submissions

View File

@ -2,7 +2,7 @@ from setuptools import setup, find_packages
setup(
name='FAAPI',
version='0.4.0',
version='0.4.2',
packages=find_packages(),
url='https://tem.party/gitea/tom/FAAPI',
license='WTFPL',