__version__ = (1, 0, 0) # # @@@@@@ @@@@@@ @@@@@@@ @@@@@@@ @@@@@@ @@@@@@@@@@ @@@@@@ @@@@@@@ @@@ @@@ @@@ @@@@@@@@ @@@@@@ # @@@@@@@@ @@@@@@@ @@@@@@@ @@@@@@@@ @@@@@@@@ @@@@@@@@@@@ @@@@@@@@ @@@@@@@@ @@@ @@@ @@@ @@@@@@@@ @@@@@@@ # @@! @@@ !@@ @@! @@! @@@ @@! @@@ @@! @@! @@! @@! @@@ @@! @@@ @@! @@@ @@! @@! !@@ # !@! @!@ !@! !@! !@! @!@ !@! @!@ !@! !@! !@! !@! @!@ !@! @!@ !@! @!@ !@! !@! !@! # @!@!@!@! !!@@!! @!! @!@!!@! @!@ !@! @!! !!@ @!@ @!@ !@! @!@ !@! @!@ !@! @!! @!!!:! !!@@!! # !!!@!!!! !!@!!! !!! !!@!@! !@! !!! !@! ! !@! !@! !!! !@! !!! !@! !!! !!! !!!!!: !!@!!! # !!: !!! !:! !!: !!: :!! !!: !!! !!: !!: !!: !!! !!: !!! !!: !!! !!: !!: !:! # :!: !:! !:! :!: :!: !:! :!: !:! :!: :!: :!: !:! :!: !:! :!: !:! :!: :!: !:! # :: ::: :::: :: :: :: ::: ::::: :: ::: :: ::::: :: :::: :: ::::: :: :: :::: :: :::: :::: :: # : : : :: : : : : : : : : : : : : : : :: : : : : : : :: : : : :: :: :: : : # # © Copyright 2024 # # https://t.me/Den4ikSuperOstryyPer4ik # and # https://t.me/ToXicUse # # 🔒 Licensed under the GNU AGPLv3 # https://www.gnu.org/licenses/agpl-3.0.html # # meta developer: @AstroModules # meta banner: https://raw.githubusercontent.com/Den4ikSuperOstryyPer4ik/Astro-modules/main/Banners/AstroShazam.png # The code snippet is adapted from VoiceMod code by D4n1l3k300 # requires: ShazamAPI import io from ShazamAPI import Shazam from .. import loader, utils @loader.tds class ShazamMod(loader.Module): """Use to search for a song using audio.""" strings = { "name": 'Shazam', "Downloading": "📥 Downloading...", "Searching": "🔎 Searching...", "no_reply": "🎙 Please reply to an audio message.", "not_found": "🚫 Song not found.", "track_info": ( " Song found\n" '📝 Name "{}"' ) } strings_ru = { "Downloading": "📥 Загрузка..", "Searching": "🔎 Поиск..", "no_reply": "🎙 Oтветьте на аудио сообщение", "not_found": "🚫 Не удалось найти песню", "track_info": ( " Песня найдена\n" '📝 Название: "{}"' ) } async def fetch_audio(self, message): reply = await message.get_reply_message() if reply and reply.file and reply.file.mime_type.startswith("audio"): await utils.answer(message, self.strings['Downloading']) audio_data = io.BytesIO(await reply.download_media(bytes)) await utils.answer(message, self.strings['Searching']) return audio_data, reply await utils.answer(message, self.strings['no_reply']) return None, None @loader.command(ru_doc=' - распознать трек') async def sh(self, message): """ - recognize track""" audio_data, reply = await self.fetch_audio(message) if not audio_data: return try: shazam = Shazam(audio_data.read()) recog = next(shazam.recognizeSong())[1]["track"] await self.client.send_file( message.peer_id, file=recog["images"]["background"], caption=self.strings['track_info'].format(recog["share"]["subject"]), reply_to=reply.id, ) await message.delete() except Exception: await utils.answer(message, self.strings['not_found'])