Exemple #1
0
async def tgplay(_, message):
    global playing
    if len(queue) != 0:
        await send("__**You Can Only Play Telegram Files After The Queue Gets Finished.**__")
        return
    if not message.reply_to_message:
        await send("__**Reply to an audio.**__")
        return
    if message.reply_to_message.audio:
        if int(message.reply_to_message.audio.file_size) >= 104857600:
            await send("__**Bruh! Only songs within 100 MB.**__")
            playing = False
            return
        duration = message.reply_to_message.audio.duration
        if not duration:
            await send("__**Only Songs With Duration Are Supported.**__")
            return
        m = await send("__**Downloading.**__")
        song = await message.reply_to_message.download()
        await m.edit("__**Transcoding.**__")
        transcode(song)
        await m.edit(f"**Playing** __**{message.reply_to_message.link}.**__")
        await asyncio.sleep(duration)
        playing = False
        return
    await send("__**Only Audio Files (Not Document) Are Supported.**__")
Exemple #2
0
async def ytplay(requested_by, query, message):
    global playing
    ydl_opts = {"format": "bestaudio"}
    m = await message.reply_text(f"__**Searching for {query} on YouTube.**__",
                                 quote=False)
    try:
        results = await arq.youtube(query)
        if not results.ok:
            await message.reply_text(results.result)
            return
        results = results.result
        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
        if time_to_seconds(duration) >= 1800:
            await m.edit("__**Bruh! Only songs within 30 Mins.**__")
            playing = False
            return
    except Exception as e:
        await m.edit("__**Found No Song Matching Your Query.**__")
        playing = False
        print(str(e))
        return
    await m.edit("__**Processing Thumbnail.**__")
    await generate_cover(requested_by, title, views, duration, thumbnail)
    await m.edit("__**Downloading Music.**__")
    with youtube_dl.YoutubeDL(ydl_opts) as ydl:
        info_dict = ydl.extract_info(link, download=False)
        audio_file = ydl.prepare_filename(info_dict)
        ydl.process_info(info_dict)
    await m.edit("__**Transcoding.**__")
    os.rename(audio_file, "audio.webm")
    transcode("audio.webm")
    await m.delete()
    caption = (
        f"🏷 **Name:** [{title[:35]}]({link})\n⏳ **Duration:** {duration}\n" +
        f"🎧 **Requested By:** {message.from_user.mention}\n📡 **Platform:** YouTube"
    )
    m = await message.reply_photo(
        photo="final.png",
        caption=caption,
    )
    os.remove("final.png")
    await asyncio.sleep(int(time_to_seconds(duration)))
    playing = False
    await m.delete()
Exemple #3
0
async def ytplay(requested_by, query):
    global playing
    ydl_opts = {"format": "bestaudio"}
    m = await app.send_message(
        sudo_chat_id, text=f"Searching for `{query}` on YouTube"
    )
    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"]
        if time_to_seconds(duration) >= 1800:  # duration limit
            await m.edit("Bruh! Only songs within 30 Mins")
            playing = False
            return
    except Exception as e:
        await m.edit(
            "Found Literally Nothing!, You Should Work On Your English."
        )
        playing = False
        print(str(e))
        return
    await m.edit("Processing Thumbnail.")
    await generate_cover(requested_by, title, views, duration, thumbnail)
    await m.edit("Downloading Music.")
    with youtube_dl.YoutubeDL(ydl_opts) as ydl:
        info_dict = ydl.extract_info(link, download=False)
        audio_file = ydl.prepare_filename(info_dict)
        ydl.process_info(info_dict)
    await m.edit("Transcoding")
    os.rename(audio_file, "audio.webm")
    transcode("audio.webm")
    await m.delete()
    m = await app.send_photo(
        chat_id=sudo_chat_id,
        caption=f"Playing [{title}]({link}) Via YouTube",
        photo="final.png",
    )
    os.remove("final.png")
    await asyncio.sleep(time_to_seconds(duration))
    playing = False
    await m.delete()
Exemple #4
0
async def ytplay(requested_by, query):
    global playing
    ydl_opts = {"format": "bestaudio"}
    m = await send(f"__**Procurando por {query} no YouTube.**__")
    try:
        results = await arq.youtube(query, 1)
        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
        if time_to_seconds(duration) >= 1800:
            await m.edit(
                "__**Caramba! Apenas músicas dentro de 30 minutos.**__")
            playing = False
            return
    except Exception as e:
        await m.edit("__**OK IREI TOCA LA.**__")
        playing = False
        print(str(e))
        return
    await m.edit("__**Processing Thumbnail.**__")
    await generate_cover(requested_by, title, views, duration, thumbnail)
    await m.edit("__**Downloading Music.**__")
    with youtube_dl.YoutubeDL(ydl_opts) as ydl:
        info_dict = ydl.extract_info(link, download=False)
        audio_file = ydl.prepare_filename(info_dict)
        ydl.process_info(info_dict)
    await m.edit("__**Transcoding.**__")
    os.rename(audio_file, "audio.webm")
    transcode("audio.webm")
    await m.delete()
    m = await app.send_photo(
        chat_id=sudo_chat_id,
        caption=f"**Playing** __**[{title}]({link})**__ **Via YouTube.**",
        photo="final.png",
    )
    os.remove("final.png")
    await asyncio.sleep(int(time_to_seconds(duration)))
    playing = False
    await m.delete()
Exemple #5
0
async def tgplay(_, message):
    global playing
    if len(queue) != 0:
        await message.reply_text(
            "__**You Can Only Play Telegram Files After The Queue Gets "
            + "Finished.**__",
            quote=False,
        )
        return
    if not message.reply_to_message:
        await message.reply_text("__**Reply to an audio.**__", quote=False)
        return
    if message.reply_to_message.audio:
        if int(message.reply_to_message.audio.file_size) >= 104857600:
            await message.reply_text(
                "__**Bruh! Only songs within 100 MB.**__", quote=False
            )
            playing = False
            return
        duration = message.reply_to_message.audio.duration
         
        if not duration:
            await message.reply_text(
                "__**Only Songs With Duration Are Supported.**__", quote=False
            )
            return
        m = await message.reply_text("__**Downloading.**__", quote=False)
        song = await message.reply_to_message.download()
        song_name = message.reply_to_message.audio.title 
        await app.update_profile(first_name=f"🔉{song_name[:35]} ",bio = f"__{song_name[:35]}__ ijro etilmoqda") 
        await m.edit("__**Transcoding.**__")
        transcode(song)
        await m.edit(f"**Playing** __**{message.reply_to_message.link}.**__")
        await asyncio.sleep(duration)
        playing = False
        return
    await message.reply_text(
        "__**Only Audio Files (Not Document) Are Supported.**__", quote=False
    )
Exemple #6
0
async def ytplay(requested_by, query, message):
    global playing
    ydl_opts = {"format": "bestaudio"}
    #n = await send(f"__**Searching for {query} on YouTube.**__")     
    m = await message.reply_text(
        f"__**Searching for {query} on YouTube.**__", quote=False
    )
    try:
        results = await arq.youtube(query)
        if not results.ok:
            await message.reply_text(results.result)
            return
        results = results.result
        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
         
         
         
         
        songname = title.lower()
        detecting = detect(songname)
         
        wordfilter = Wordfilter()
        wordfilter.addWords(['yamete', 'kudasai', 'arigato', 'hentai'])     
        if wordfilter.blacklisted(songname): 
           await m.edit(f"__**Shame on you ! {requested_by}\nNot allowed song !!!**__\n@wuminjun block him!\n{songname}")  
           playing = False
           return
        if detecting == "ko":
           await m.edit(f"__**Not allowed Language !!!**__ {songname}")  
           playing = False
           return
         
         
         
        if time_to_seconds(duration) >= 3600:
            await m.edit("__**Bruh! Only songs within 60 Mins.**__")
            playing = False
            return
    except Exception as e:
        await m.edit("__**Found No Song Matching Your Query.**__")
        playing = False
        print(str(e))
        return
    await m.edit("__**Processing Thumbnail.**__")
    await app.update_profile(first_name=f"🔉{title[:35]} ",bio = f"__{title[:35]}__ ijro etilmoqda")     
    await generate_cover(requested_by, title, views, duration, thumbnail)
    await m.edit("__**Downloading Music.**__")
    with youtube_dl.YoutubeDL(ydl_opts) as ydl:
        info_dict = ydl.extract_info(link, download=False)
        audio_file = ydl.prepare_filename(info_dict)
        ydl.process_info(info_dict)
    await m.edit("__**Transcoding.**__")
    os.rename(audio_file, "audio.webm")
    transcode("audio.webm")
    await m.delete()
       
    caption = f"🏷 **Name:** [{title}]({link})\n⏳ **Duration:** {duration}\n" \
               + f"🎧 **Requested By:** {requested_by}\n📡 **Platform:** YouTube"
    m = await message.reply_photo(
        photo="final.png",
        caption=caption,
    )
    msg_id = m.message_id     
    if message.chat.username != "music_streaming_channel":     
       copy = await app.copy_message(SUDO_CHANNEL, message.chat.username, msg_id)     
   
    await app.set_profile_photo(photo="final.png")     
    #await app.pin_chat_message(SUDO_CHAT_ID, msg_id, disable_notification=True) 
         
    os.remove("final.png")
    await asyncio.sleep(int(time_to_seconds(duration)))
    await m.delete()
    await copy.delete()     
     
    photos = await app.get_profile_photos("me")     
    await app.delete_profile_photos([p.file_id for p in photos[1:]])     
    playing = False