Create lyrics.py
Browse files- Akeno/plugins/lyrics.py +43 -0
Akeno/plugins/lyrics.py
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import asyncio
|
2 |
+
import os
|
3 |
+
import random
|
4 |
+
import time
|
5 |
+
|
6 |
+
from lyricsgenius import Genius
|
7 |
+
from pyrogram import Client, filters
|
8 |
+
from pyrogram.types import Message
|
9 |
+
|
10 |
+
from Akeno.utils.database import db
|
11 |
+
from Akeno.utils.handler import *
|
12 |
+
from config import *
|
13 |
+
|
14 |
+
|
15 |
+
@Akeno(
|
16 |
+
~filters.scheduled
|
17 |
+
& filters.command(["lyrics"], CMD_HANDLER)
|
18 |
+
& filters.me
|
19 |
+
& ~filters.forwarded
|
20 |
+
)
|
21 |
+
async def lyrics_songs(_, message: Message):
|
22 |
+
query = message.text.split(" ", 1)[1] if len(message.command) > 1 else None
|
23 |
+
if not query:
|
24 |
+
return await message.reply_text("Search For lyrics")
|
25 |
+
token = await db.get_env(ENV_TEMPLATE.lyrics_api)
|
26 |
+
if not token:
|
27 |
+
return await message.reply_text("Required: `LYRICS_API`")
|
28 |
+
genius = Genius(token)
|
29 |
+
artist = genius.search_song(query)
|
30 |
+
results = artist.lyrics
|
31 |
+
if len(results) > 4096:
|
32 |
+
with open("lyrics.txt", "w+", encoding="utf8") as out_file:
|
33 |
+
out_file.write(results)
|
34 |
+
await message.reply_document(
|
35 |
+
document="lyrics.txt",
|
36 |
+
disable_notification=True
|
37 |
+
)
|
38 |
+
os.remove("lyrics.txt")
|
39 |
+
else:
|
40 |
+
await message.reply_text(f"<b><blockquote>{results}</blockquote></b>")
|
41 |
+
|
42 |
+
module = modules_help.add_module("lyrics", __file__)
|
43 |
+
module.add_command("lyrics", "Get lyrics matched artist and song.")
|