Ejemplo n.º 1
0
async def play(client: Client, message_: Message):
    audio = (message_.reply_to_message.audio or message_.reply_to_message.voice) if message_.reply_to_message else None
    chat_id=message_.chat.id
    res = await message_.reply_text("🔄 Processing...")

    if audio:
        if round(audio.duration / 60) > DURATION_LIMIT:
            raise DurationLimitError(
                f"Videos longer than {DURATION_LIMIT} minute(s) aren't allowed, the provided video is {audio.duration / 60} minute(s)"
            )

        file_name = audio.file_id + audio.file_name.split(".")[-1]
        file = await convert(await message_.reply_to_message.download(file_name))
    else:
        messages = [message_]
        text = ""
        offset = None
        length = None

        if message_.reply_to_message:
            messages.append(message_.reply_to_message)

        for message in messages:
            if offset:
                break

            if message.entities:
                for entity in message.entities:
                    if entity.type == "url":
                        text = message.text or message.caption
                        offset, length = entity.offset, entity.length
                        break

        if offset == None:
            await res.edit_text("❕ You did not give me anything to play.")
            return

        url = text[offset:offset+length]

        file =await convert(download(url))

    if message_.chat.id in tgcalls.GroupsOn:
        position = sira.add(message_.chat.id, file)
        await res.edit_text(f"#️⃣ Queued at position {position}.")
    else:
        await res.edit_text("▶️ Playing...")
        res.delete
        m = await client.send_photo(
        chat_id=message_.chat.id,
        photo="https://telegra.ph/file/fe07b15733ed56f103cb4.jpg",
        caption=f"Playing Your song Via Devil music bot.",
         ) 
        tgcalls.setsong(message_.chat.id, file)
Ejemplo n.º 2
0
async def ytp(client: Client, message_: Message):
    requested_by = message_.from_user.first_name
    chat_id=message_.chat.id
    text = message_.text.split(" ", 1)
    query = text[1]
    res = await message_.reply_text(f"Searching 🔍🔎🔍🔎 for `{query}` on You Tube")
    try:
        results = YoutubeSearch(query, max_results=1).to_dict()
        link = f"https://youtube.com{results[0]['url_suffix']}"
        title = results[0]["title"]
        thumbnail = results[0]["thumbnails"][0]
        duration = results[0]["duration"]
        views = results[0]["views"]
    except Exception as e:
        await res.edit(
            "Found Literally Nothing!, You Should Work On Your English."
        )
        is_playing = False
        print(str(e))
        return
    file = await convert(download(link))
    if message_.chat.id in tgcalls.GroupsOn:
        position = sira.add(message_.chat.id, file)
        await res.edit_text(f"#️⃣ Queued at position {position}.")
    else:
        await res.edit_text("▶️ Playing...")
        tgcalls.setsong(message_.chat.id, file)
    await res.edit("Processing Thumbnail.")
    await generate_cover(requested_by, title, views, duration, thumbnail)
    res.delete
    m = await client.send_photo(
        chat_id=message_.chat.id,
        caption=f"Playing `{query}` Via YouTube",
        photo="final.png",
        reply_markup=InlineKeyboardMarkup(
            [[InlineKeyboardButton("watch on Youtube", url=link)]]
        ),
        parse_mode="markdown",
    )
    os.remove("final.png")
Ejemplo n.º 3
0
async def jiosaavn(client: Client, message_: Message):
    requested_by = message_.from_user.first_name
    chat_id=message_.chat.id
    text = message_.text.split(" ", 1)
    query = text[1]
    res = await message_.reply_text(f"Searching 🔍🔎🔍🔎 for `{query}` on jio saavn")
    try:
        async with aiohttp.ClientSession() as session:
            async with session.get(
                f"https://jiosaavnapi.bhadoo.uk/result/?query={query}"
            ) as resp:
                r = json.loads(await resp.text())
        sname = r[0]["song"]
        slink = r[0]["media_url"]
        ssingers = r[0]["singers"]
        sthumb = r[0]["image"]
        sduration = int(r[0]["duration"])
    except Exception as e:
        await res.edit(
            "Found Literally Nothing!, You Should Work On Your English."
        )
        print(str(e))
        is_playing = False
        return
    file= await convert(wget.download(slink))
    if message_.chat.id in tgcalls.GroupsOn:
        position = sira.add(message_.chat.id, file)
        await res.edit_text(f"#️⃣ Queued at position {position}.")
    else:
        await res.edit_text("▶️ Playing...")
        tgcalls.setsong(message_.chat.id, file)
    await res.edit("Processing Thumbnail.")
    await generate_cover_square(requested_by, sname, ssingers, sduration, sthumb)
    await res.delete()
    m = await client.send_photo(
        chat_id=message_.chat.id,
        caption=f"Playing {sname} Via Jiosaavn",
        photo="final.png",
    )
    os.remove("final.png")
Ejemplo n.º 4
0
async def deezer(client: Client, message_: Message):
    requested_by = message_.from_user.first_name
    text = message_.text.split(" ", 1)
    queryy = text[1]
    res = await message_.reply_text(f"Searching 🔍🔎🔍🔎 for `{queryy}` on deezer")
    try:
        arq = ARQ("https://thearq.tech")
        r = await arq.deezer(query=queryy, limit=1)
        title = r[0]["title"]
        duration = int(r[0]["duration"])
        thumbnail = r[0]["thumbnail"]
        artist = r[0]["artist"]
        url = r[0]["url"]
    except:
        await res.edit(
            "Found Literally Nothing, You Should Work On Your English!"
        )
        is_playing = False
        return
    f= await convert(wget.download(url))
    await res.edit("Generating Thumbnail")
    await generate_cover_square(requested_by, title, artist, duration, thumbnail)
    if message_.chat.id in tgcalls.GroupsOn:
        await res.edit("adding in queue")
        position = sira.add(message_.chat.id, fi)
        await res.edit_text(f"#️⃣ Queued at position {position}.")
    else:
        await res.edit_text("▶️ Playing...")
        tgcalls.setsong(message_.chat.id, file)
        await res.delete()
    m = await client.send_photo(
        chat_id=message_.chat.id,
        photo="final.png",
        caption=f"Playing [{title}]({url}) Via Deezer."
    ) 
    os.remove("final.png")