Support imgur.com/gallery links

This commit is contained in:
blank X 2021-11-14 02:04:32 +07:00
parent 2b399d4bd5
commit 713b2250bc
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
1 changed files with 2 additions and 2 deletions

View File

@ -359,9 +359,9 @@ async def main():
splitted = os.path.splitext(parsed[2])
domain = getattr(random_post, 'domain', parsed[1])
preview = getattr(random_post, 'preview', None)
if domain.endswith('imgur.com'):
if domain == 'imgur.com' or domain.endswith('.imgur.com'):
parsed[1] = 'i.imgur.com'
if parsed[2].startswith('/a/'):
if parsed[2].startswith('/a/') or parsed[2].startswith('/gallery/'):
albumid = os.path.split(parsed[2].rstrip('/'))[1]
async with session.get(f'https://imgur.com/ajaxalbums/getimages/{albumid}/hit.json?all=true') as resp:
apidata = (await resp.json())['data']