Skip to content

Commit

Permalink
instagram share link fix (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
amadejkastelic authored Dec 6, 2024
1 parent ad8ba67 commit 0222333
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions bot/integrations/instagram/aiograpi/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from urllib.parse import parse_qs, urlparse

import aiograpi
import aiohttp
from aiograpi import exceptions as aiograpi_exceptions

from bot import constants as bot_constants
Expand Down Expand Up @@ -37,6 +38,10 @@ async def get_integration_data(
) -> typing.Tuple[bot_constants.Integration, str, typing.Optional[int]]:
if 'stories' in url:
pk = self.client.story_pk_from_url(url)
elif '/share/reel/' in url:
async with aiohttp.ClientSession() as session:
async with session.get(url=url) as resp:
pk = await self.client.media_pk_from_url(str(resp.url))
else:
pk = await self.client.media_pk_from_url(url)
return self.INTEGRATION, pk, max(0, int(parse_qs(urlparse(url).query).get('img_index', ['1'])[0]) - 1)
Expand Down

0 comments on commit 0222333

Please sign in to comment.