Exemplo n.º 1
0
async def get_qb_client():
    try:
        qb = Client(config.qb_web_url)
        qb.login()
    except Exception as e:
        bot = nonebot.get_bot()
        msg = (
            "❌ 无法连接到 qbittorrent ,请检查:\n"
            "1.是否启动程序\n"
            "2.是否勾选了“Web用户界面(远程控制)”\n"
            f"3.连接地址、端口是否正确\nE: {e}"
        )
        logger.error(msg)
        await bot.send_msg(
            message_type="private", user_id=str(list(config.superusers)[0]), message=msg
        )
        return None
    try:
        qb.get_default_save_path()
    except Exception as e:
        bot = nonebot.get_bot()
        msg = f"❌ 无法连登录到 qbittorrent ,请检查是否勾选 “对本地主机上的客户端跳过身份验证”。\nE: {e}"
        logger.error(msg)
        await bot.send_msg(
            message_type="private", user_id=str(list(config.superusers)[0]), message=msg
        )
        return None
    return qb
Exemplo n.º 2
0
def torrent_view(request):
    qb = Client('http://127.0.0.1:8080/')
    qb.login('admin', 'adminadmin')
    BASE_DIR = Path(__file__).resolve().parent.parent
    d_path = os.path.join(BASE_DIR, 'static/folder/')
    print("Location : ", qb.get_default_save_path())
    if request.method == 'POST':
        ezflix = Ezflix(query=request.POST['title1'],
                        media_type='movie',
                        quality='720p',
                        limit=1)
        shows = ezflix.search()
        # magnet = 'https://webtorrent.io/torrents/big-buck-bunny.torrent'
        magnet = 'https://webtorrent.io/torrents/cosmos-laundromat.torrent'
        if shows is not None:
            for s in shows:
                if s['imdb'] == request.POST['imdb1']:
                    print(s['link'])
                    # torrent_location=Torrent.objects.filter(Info_code=s['title'])[0]
                    # print ("Finally",torrent_location.title)
                    # print(torrent_location)
                    qb.download_from_link(magnet, savepath=d_path)
                    time.sleep(90)
                    torrents = qb.torrents(filter='downloading')
                    # for k in info_hash
                    # k.Info code
                    # print("This is the info")

                    path_torrent = Torrent_details(torrents, qb, s['title'])
                    print(
                        '--------------------------------------------------------------------------------------'
                    )
        else:
            print("Not found")
    return HttpResponse(path_torrent)
async def get_qb(session: CommandSession):
    try:
        qb = Client(config.qb_web_url)
        qb.login()
    except Exception as e:
        msg = ("❌ 无法连接到 qbittorrent ,请检查:\n"
               "1.是否启动程序\n"
               "2.是否勾选了“Web用户界面(远程控制)”\n"
               f"3.连接地址、端口是否正确\nE: {e}")
        logger.error(msg)
        await session.send(msg)
        return None
    try:
        qb.get_default_save_path()
    except Exception as e:
        msg = f"❌ 无法连登录到 qbittorrent ,请检查是否勾选 “对本地主机上的客户端跳过身份验证”。\nE: {e}"
        logger.error(msg)
        await session.send(msg)
        return None
    return qb