new player version
This commit is contained in:
parent
4605a46765
commit
27dc827880
|
|
@ -1,6 +1,7 @@
|
||||||
import json
|
import json
|
||||||
import asyncio
|
import asyncio
|
||||||
import os
|
import os
|
||||||
|
import string
|
||||||
import aiofiles
|
import aiofiles
|
||||||
from hashlib import sha256
|
from hashlib import sha256
|
||||||
|
|
||||||
|
|
@ -60,7 +61,7 @@ async def create_metadata_for_item(
|
||||||
|
|
||||||
item_metadata = {
|
item_metadata = {
|
||||||
'name': title,
|
'name': title,
|
||||||
'description': ' '.join([f"#{_h.replace(' ', '_')}" for _h in hashtags]),
|
'description': ' '.join([f"#{''.join([(_h_ch if (_h_ch.lower() in string.ascii_lowercase) else '_') for _h_ch in _h])}" for _h in hashtags]),
|
||||||
'attributes': [
|
'attributes': [
|
||||||
# {
|
# {
|
||||||
# 'trait_type': 'Artist',
|
# 'trait_type': 'Artist',
|
||||||
|
|
|
||||||
|
|
@ -97,31 +97,6 @@ class PlayerTemplates:
|
||||||
template_kwargs['audio'] = URLInputFile(local_content_preview_url)
|
template_kwargs['audio'] = URLInputFile(local_content_preview_url)
|
||||||
if cover_content:
|
if cover_content:
|
||||||
template_kwargs['thumbnail'] = URLInputFile(cover_content.web_url)
|
template_kwargs['thumbnail'] = URLInputFile(cover_content.web_url)
|
||||||
|
|
||||||
if self.bot_id == 1:
|
|
||||||
inline_keyboard_array.append([
|
|
||||||
{
|
|
||||||
'text': self.user.translated('shareTrack_button'),
|
|
||||||
'switch_inline_query': f"Q{user_existing_license.onchain_address}" if user_existing_license else f"C{content.cid.serialize_v2()}",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'text': self.user.translated('shareLink_button'),
|
|
||||||
'url': f"https://t.me/share/url?text={urllib.parse.quote(content_share_link['text'])}&url={urllib.parse.quote(content_share_link['url'])}"
|
|
||||||
}
|
|
||||||
])
|
|
||||||
inline_keyboard_array.append([{
|
|
||||||
'text': self.user.translated('openTrackInApp_button'),
|
|
||||||
'url': f"https://t.me/{CLIENT_TELEGRAM_BOT_USERNAME}/content?startapp={content.cid.serialize_v2()}"
|
|
||||||
}])
|
|
||||||
else:
|
|
||||||
inline_keyboard_array.append([{
|
|
||||||
'text': self.user.translated('viewTrackAsClient_button'),
|
|
||||||
'url': f"https://t.me/{CLIENT_TELEGRAM_BOT_USERNAME}?start=C{content.cid.serialize_v2()}"
|
|
||||||
}])
|
|
||||||
inline_keyboard_array.append([{
|
|
||||||
'text': self.user.translated('openContractPage_button'),
|
|
||||||
'url': f"https://tonviewer.com/{content_meta['item_address']}"
|
|
||||||
}])
|
|
||||||
elif content_type == 'video':
|
elif content_type == 'video':
|
||||||
# Processing video
|
# Processing video
|
||||||
video_title = content_metadata_json.get('name', "")
|
video_title = content_metadata_json.get('name', "")
|
||||||
|
|
@ -155,16 +130,6 @@ class PlayerTemplates:
|
||||||
)
|
)
|
||||||
).first())
|
).first())
|
||||||
)
|
)
|
||||||
if False and have_access:
|
|
||||||
full_content = self.db_session.query(StoredContent).filter_by(
|
|
||||||
hash=content.meta.get('converted_content', {}).get('low') # TODO: support high quality
|
|
||||||
).first()
|
|
||||||
if content_type == 'audio':
|
|
||||||
# Restrict audio to 30 seconds if user does not have access
|
|
||||||
template_kwargs['audio'] = URLInputFile(full_content.web_url)
|
|
||||||
elif content_type == 'video':
|
|
||||||
# Restrict video to 30 seconds if user does not have access
|
|
||||||
template_kwargs['video'] = URLInputFile(full_content.web_url)
|
|
||||||
|
|
||||||
make_log("TG-Player", f"Send content {content_type} ({content_encoding}) to chat {self._chat_id}. {cd_log}")
|
make_log("TG-Player", f"Send content {content_type} ({content_encoding}) to chat {self._chat_id}. {cd_log}")
|
||||||
for kmsg in self.db_session.query(KnownTelegramMessage).filter_by(
|
for kmsg in self.db_session.query(KnownTelegramMessage).filter_by(
|
||||||
|
|
@ -176,7 +141,7 @@ class PlayerTemplates:
|
||||||
await self.delete_message(kmsg.message_id)
|
await self.delete_message(kmsg.message_id)
|
||||||
|
|
||||||
r = await tg_process_template(
|
r = await tg_process_template(
|
||||||
self, text + '\n\n' + f"""<a href="https://t.me/MY_Web3Bot/content?startapp={content.cid.serialize_v2()}"><code>🌐 Открыть на MY</code></a>""", message_id=message_id, **template_kwargs,
|
self, text + '\n\n' + f"""<a href="{content_share_link['url']}"><code>🌐 Открыть на MY</code></a>""", message_id=message_id, **template_kwargs,
|
||||||
keyboard=get_inline_keyboard([*inline_keyboard_array, *extra_buttons]) if inline_keyboard_array else None,
|
keyboard=get_inline_keyboard([*inline_keyboard_array, *extra_buttons]) if inline_keyboard_array else None,
|
||||||
message_type=f'content/{content_type}',
|
message_type=f'content/{content_type}',
|
||||||
message_meta={'content_sha256': content_meta['hash']} if local_content else {},
|
message_meta={'content_sha256': content_meta['hash']} if local_content else {},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue