Esempio n. 1
0
def play_playlist(client, message):
    playlist = db.get_playlist("custom")["items"]

    if not playlist:
        message.reply_text(_("playlist_1"))
    elif player.is_currently_playing():
        message.reply_text(_("playlist_9"))
    else:
        message.reply_text(_("playlist_2"))

        for item in playlist:
            download(
                item["url"],
                message.from_user.id,
                message.from_user.first_name,
                func(
                    player.play,
                    log=func(
                        client.send_photo,
                        chat_id=LOG_GROUP,
                        caption=_("group_1").format(
                            '<a href="{}">{}</a>',
                            "{}",
                            '<a href="tg://user?id={}">{}</a>',
                        ),
                        parse_mode="HTML",
                        reply_markup=InlineKeyboardMarkup([
                            [
                                InlineKeyboardButton(_("playlist_6"),
                                                     "rm_from_playlist"),
                            ],
                        ]),
                    ),
                ) if LOG_GROUP else None,
            )
Esempio n. 2
0
def message(client, message):
    if message.text.startswith("/"):
        return

    if not is_youtube(message.text):
        message.reply_text(_("play_1"))
        return

    if "list=" in message.text:
        message.reply_text(_("play_2"))
        return

    m = message.reply_text(_("play_3"), quote=True)

    download(
        message.text,
        func(
            player.play,
            sent_by_id=message.from_user.id,
            sent_by_name=message.from_user.first_name,
            log=func(
                client.send_photo,
                chat_id=LOG_GROUP,
                caption=_("group_1").format(
                    '<a href="{}">{}</a>',
                    "{}",
                    '<a href="tg://user?id={}">{}</a>',
                ),
                parse_mode="HTML",
                reply_markup=InlineKeyboardMarkup([
                    [
                        InlineKeyboardButton(_("playlist_3"),
                                             "add_to_playlist"),
                    ],
                ]),
            ) if LOG_GROUP else None,
            on_start=func(
                message.reply_text,
                _("player_1"),
            ),
            on_end=func(
                message.reply_text,
                _("player_2"),
            ),
            on_skip=func(
                message.reply_text,
                _("skip_3"),
            ),
        ),
        func(m.edit, _("ytdl_1")),
        func(m.edit,
             _("ytdl_2").format(player.q.qsize() + 1)),
        func(m.edit, _("ytdl_3")),
        func(m.edit, _("error")),
        func(m.edit, _("ytdl_4")),
    )
Esempio n. 3
0
def stream(client, message):
    if player.STATE in (State.Playing, State.Paused):
        message.reply_text(
            _("stream_3")
        )
    else:
        args = message.text.split()

        if len(args) == 1:
            message.reply_text(
                _("stream_1")
            )
        elif len(args) != 2:
            message.reply_text(
                _("stream_2")
            )
        else:
            player.stream(
                args[1],
                func(
                    client.send_message,
                    LOG_GROUP,
                    _("group_2").format(
                        args[1]
                    )
                ) if LOG_GROUP else None
            )

            message.reply_text(
                _("stream_4")
            )