Requesting audio with access_key if given

This commit is contained in:
Kylmakalle 2019-02-20 22:06:45 +03:00
parent b6122ae172
commit 5be7ccea93
2 changed files with 4 additions and 3 deletions

View File

@ -32,7 +32,7 @@ VK_APP_ID = os.environ.get('VK_APP_ID', '2685278') # Kate mobile
AUDIO_URL = os.environ.get('AUDIO_URL', 'http://thatmusic.akentev.com/id/{owner_id}/{audio_id}')
AUDIO_ACCESS_URL = os.environ.get('AUDIO_ACCESS_URL',
'http://thatmusic.akentev.com/access_id/{token}/{owner_id}/{audio_id}')
'http://thatmusic.akentev.com/access_id/{token}/{owner_id}/{audio_id}/{access_key}')
TOKEN_REFRESH_URL = os.environ.get('TOKEN_REFRESH_URL', 'http://thatmusic.akentev.com/refresh')
AUDIO_SEARCH_URL = os.environ.get('AUDIO_SEARCH_URL', 'https://thatmusic.akentev.com/search/')
AUDIO_PROXY_URL = os.environ.get('AUDIO_PROXY_URL', 'https://thatmusic.akentev.com/proxy/')

View File

@ -802,14 +802,15 @@ async def process_attachment(attachment, token=None):
return {'content': audio, 'type': 'audio'}
except:
pass
if AUDIO_ACCESS_URL:
if token:
try:
with aiohttp.ClientSession() as session:
r = await session.request('GET', AUDIO_ACCESS_URL.format(token=token,
owner_id=attachment[atype]['owner_id'],
audio_id=attachment[atype]['id']))
audio_id=attachment[atype]['id'],
access_key=attachment[atype].get(
'access_key', '')))
if r.status != 200:
raise Exception
audio = await r.read()