def tickThread():
    global waitTill
    while True:
        sleep(5)
        if generatorclient.last_upload_times is None and not generatorclient.isRequestingScripts:
            print("No update times available... requesting more")
            generatorclient.getLastUploadedScripts()
            sleep(5)

        if videoscript.videoscripts:
            print("Rendering all video scripts...")
            for script in videoscript.videoscripts:
                script.renderVideo()

            if waitTill is not None:
                if datetime.datetime.now() > waitTill:
                    waitTill = None
                else:
                    print("Out of Quote Response... waiting till %s" % waitTill)

            if settings.exportOffline:
                waitTill = None


            if not settings.exportOffline:
                if waitTill is None:
                    amount_to_upload = canUpload()

                    if type(amount_to_upload) is int:
                        scripts_available_to_upload = [script for i, script in enumerate(videoscript.videoscripts) if
                                                       script.isRendered]
                        print("Allowed to upload %s videos" % amount_to_upload)
                        if amount_to_upload > len(scripts_available_to_upload):
                            amount_to_upload = len(scripts_available_to_upload)
                            print("Only %s scripts available to upload" % amount_to_upload)
                        print("Uploading %s video scripts... %s ready to upload (total %s)" % (
                        amount_to_upload, amount_to_upload, len(videoscript.videoscripts)))
                        for i in range(0, amount_to_upload, 1):
                            upload = scripts_available_to_upload[i].uploadVideo()
                            try:
                                if upload is False:
                                    now = datetime.datetime.now()
                                    if now.hour > settings.youtube_api_quota_reset_hour:
                                        waitTill = now.replace(hour=settings.youtube_api_quota_reset_hour, minute=0, second=0) + timedelta(days=1)
                                    else:
                                        waitTill = now.replace(hour=settings.youtube_api_quota_reset_hour, minute=0, second=0)
                            except Exception as e:
                                print(e)
                                pass

                generatorclient.last_upload_times = None
            # elif type(amount_to_upload) is bool:
            #     print("Can't get last update times")
            else:
                print("Estimated out of quotes waiting till %s" % waitTill)
        else:
            print("No video scripts, just chilling...")

        if not generatorclient.isRequestingScripts:
            generatorclient.requestScripts([script.scriptno for script in videoscript.videoscripts])
Esempio n. 2
0
def initQueue():
    ##    process = subprocess.call("wine /home/royalreddit/Desktop/balcon/balcon.exe -t supnerds -w /home/royalreddit/Desktop/test2.wav", shell = True)

    if not os.path.exists(settings.videoqueue_directory):
        os.mkdir(settings.videoqueue_directory)

    if not os.path.exists(settings.rawvideosaves):
        os.mkdir(settings.rawvideosaves)

    if not os.path.exists(settings.finishedvideosdirectory):
        os.mkdir(settings.finishedvideosdirectory)

    if not os.path.exists(settings.overlayPath):
        os.mkdir(settings.overlayPath)

    if not os.path.exists(f"{settings.currentPath}/TempVids"):
        os.mkdir(f"{settings.currentPath}/TempVids")

    loadVideoScripts()
    generatorclient.connectToServer()
    sleep(2)
    generatorclient.requestScripts(
        [script.scriptno for script in videoscript.videoscripts])
    thread = Thread(target=tickThread)
    thread.start()
def initQueue():

    if not os.path.exists(settings.videoqueue_directory):
        os.mkdir(settings.videoqueue_directory)

    if not os.path.exists(settings.rawvideosaves):
        os.mkdir(settings.rawvideosaves)

    if not os.path.exists(settings.finishedvideosdirectory):
        os.mkdir(settings.finishedvideosdirectory)

    generatorclient.connectToServer()
    loadVideoScripts()
    sleep(2)
    generatorclient.requestScripts(
        [script.scriptno for script in videoscript.videoscripts])
    thread = Thread(target=tickThread)
    thread.start()
def tickThread():
    while True:

        sleep(30)
        if generatorclient.last_upload_times is None and not generatorclient.isRequestingScripts:
            print("No update times available... requesting more")
            generatorclient.getLastUploadedScripts()
            sleep(5)

        if videoscript.videoscripts:
            print("Rendering all video scripts...")
            for script in videoscript.videoscripts:
                script.renderVideo()

            amount_to_upload = canUpload()

            if type(amount_to_upload) is int:
                scripts_available_to_upload = [
                    script for i, script in enumerate(videoscript.videoscripts)
                    if script.isRendered
                ]
                print("Allowed to upload %s videos" % amount_to_upload)
                if amount_to_upload > len(scripts_available_to_upload):
                    amount_to_upload = len(scripts_available_to_upload)
                    print("Only %s scripts available to upload" %
                          amount_to_upload)
                print(
                    "Uploading %s video scripts... %s ready to upload (total %s)"
                    % (amount_to_upload, amount_to_upload,
                       len(videoscript.videoscripts)))
                for i in range(0, amount_to_upload, 1):
                    scripts_available_to_upload[i].uploadVideo()
                generatorclient.last_upload_times = None
            elif type(amount_to_upload) is bool:
                print("Can't get last update times")
            else:
                print("Estimated out of quotes waiting till %s" %
                      amount_to_upload)
        else:
            print("No video scripts, just chilling...")

        if not generatorclient.isRequestingScripts:
            generatorclient.requestScripts(
                [script.scriptno for script in videoscript.videoscripts])