Пример #1
0
async def last_fm_(message: Message):
    """Currently Playing"""
    query = message.input_str or Config.LASTFM_USERNAME
    view_data = (await recs(query, "recenttracks", 3))[1]
    recent_song = view_data["recenttracks"]["track"]
    if len(recent_song) == 0:
        return await message.err("No Recent Tracks found", del_in=5)
    qd = f"[{query}]({du}{query})" if message.input_str else await user()
    if recent_song[0].get("@attr"):
        song_ = recent_song[0]
        sn, an = song_["name"], song_["artist"]["#text"]
        gt = (await info("track", query, an, sn))[1]["track"]
        y = [i.replace(" ", "_").replace("-", "_") for i in [tg["name"] for tg in gt["toptags"]["tag"]]]
        z = [k for k in y if y!=[] and k.lower() in tglst()]
        neutags = " #".join(z[i] for i in range(min(len(z), 4)))
        img = ri(recent_song[0].get("image")[3].get("#text"))
        rep = f"[\u200c]({img})**{qd}** is currently listening to: \n🎧  `{an} - {sn}`"
        rep += ", ♥️" if gt["userloved"] != "0" else ""
        rep += f"\n#{neutags}" if neutags != "" else ""
    else:
        rep = f"**{qd}** was listening to ...\n"
        for song_ in recent_song:
            sn, an = song_["name"], song_["artist"]["#text"]
            rep += f"\n🎧  {an} - {sn}"
            rep += ", ♥️" if (await info("track", query, an, sn))[1]["track"]["userloved"] != "0" else ""
        playcount = view_data.get("recenttracks").get("@attr").get("total")
        rep += f"`\n\nTotal Scrobbles = {playcount}`"
    await message.edit(rep)
Пример #2
0
async def last_fm_unlove_(message: Message):
    """UnLoves Currently Playing Song"""
    await message.edit("UnLoving Currently Playing...")
    recent_song = (await recs(Config.LASTFM_USERNAME, "recenttracks", 2))[1]["recenttracks"]["track"]
    if len(recent_song) == 0 or not recent_song[0].get("@attr"):
        return await message.err("No Currently Playing Track found", del_in=10)
    song_ = recent_song[0]
    anm, snm = song_["artist"]["#text"], song_["name"]
    auth_().get_track(anm, snm).unlove()
    img = ri(song_.get("image")[3].get("#text"))
    await message.edit(f"UnLoved currently playing track...\n`{anm} - {snm}` [\u200c]({img})")