Esempio n. 1
0
def run():
    # {"title": tmp_data["title"], "id": video_id, "av": _["av"]}
    work = GetPlayList.get_work_list()
    logger = tool.getLogger()
    account = tool.QRLogin()
    for i in work:
        logger.debug(json.dumps(i))
        logger.info("start: vid[{}], 1080P[{}], Multipart[{}]".format(
            i["id"], i["hd"], i["multipart"]))
        vmer = getVideo.VideoManager(i["id"], i["hd"])
        data = vmer.getVideo()
        if data[0]:
            if i["multipart"]:
                success, res, upos_uri = Upload.uploadWithOldBvid(
                    account.getCookies(), i, data[1])
            else:
                success, res, upos_uri = Upload.uploadWithNewBvid(
                    account.getCookies(), i, data[1])
            if not success:
                continue
            upos_uri = upos_uri.split(".")[0]
            res = json.loads(res)
            if res["code"] != 0:
                logger.error(res["message"])
                continue
            with tool.getDB() as db:
                db.execute(
                    "insert into data(vid,bvid,title,filename) values(?,?,?,?);",
                    (i["id"], res["data"]["bvid"], i["title"], upos_uri))
                db.commit()
            logger.info(f"finished, bvid[{res['data']['bvid']}]")
            vmer.deleteFile()
        else:
            logger.error("download failed")
Esempio n. 2
0
def __consume():
    account = tool.AccountManager("Anki")
    logger = tool.getLogger()
    logger.debug("start video Consumer")
    while True:
        i = buffer.get(block=True)
        logger.debug(json.dumps(i))
        logger.info("start: vid[{}], 1080P[{}], Multipart[{}]".format(
            i["id"], i["hd"], i["multipart"]))
        vmer = getVideo.VideoManager(i["id"], i["hd"])
        data = vmer.getVideo()
        if data[0]:
            if i["multipart"]:
                success, res, upos_uri = Upload.uploadWithOldBvid(
                    account.getCookies(), i, data[1])
            else:
                success, res, upos_uri = Upload.uploadWithNewBvid(
                    account.getCookies(), i, data[1])
            if not success:
                continue
            upos_uri = upos_uri.split(".")[0]
            res = json.loads(res)
            if res["code"] != 0:
                logger.error(res["message"])
                continue
            with tool.getDB() as db:
                db.execute(
                    "insert into data(vid,bvid,title,filename) values(?,?,?,?);",
                    (i["id"], res["data"]["bvid"], i["title"], upos_uri))
                db.commit()
            logger.info(f"finished, bvid[{res['data']['bvid']}]")
            vmer.deleteFile()
        else:
            logger.error("download failed")
Esempio n. 3
0
def __consume():
    account = tool.QRLogin()
    logger = tool.getLogger()
    logger.debug("start video Consumer")
    proxy = tool.settingConf["Proxy"]
    while True:
        i = buffer.get(block=True)
        channelInfo = i.channelParam
        logger.debug(json.dumps(channelInfo))
        logger.info("start: vid[{}], Multipart[{}]".format(
            channelInfo["id"], channelInfo["multipart"]))
        # vmer = getVideo.VideoManager(i["id"], i["hd"])
        data = i.download(proxy)

        if data:
            fpath = i.path()
            if len(fpath) <= 0:
                continue
            if channelInfo["multipart"]:
                success, res, upos_uri = Upload.uploadWithOldBvid(
                    account.getCookies(), channelInfo, fpath)
            else:
                success, res, upos_uri = Upload.uploadWithNewBvid(
                    account.getCookies(), channelInfo, fpath)
            if not success:
                continue
            upos_uri = upos_uri.split(".")[0]
            res = json.loads(res)
            if res["code"] != 0:
                logger.error(res["message"])
                continue
            with tool.getDB() as db:
                db.execute(
                    "insert into data(vid,bvid,title,filename) values(?,?,?,?);",
                    (channelInfo["id"], res["data"]["bvid"],
                     channelInfo["title"], upos_uri))
                db.commit()
            logger.info(f"finished, bvid[{res['data']['bvid']}]")
            i.deleteFile()
        else:
            logger.error("download failed")