Пример #1
0
def activate():
    if request.method == 'GET':
        email = request.args['email']
        if database.getStatus(email):
            return redirect(url_for('home'))
        database.updateStatus(email)
        return render_template("activate.html")
    return redirect(url_for('home'))
def cleanDatabase():
    clips = database.getClipsByStatus("DOWNLOADED")

    print("Checking %s clips for MP4s" % len(clips))

    for i, clip in enumerate(clips):
        filePath = f"{settings.vid_filepath}/%s.mp4" % clip.mp4
        print(f"Checking if clip ({i + 1}/{len(clips)}) exists")
        if not os.path.exists(f"{settings.vid_filepath}/%s.mp4" % clip.mp4):
            print(f"Clip does not exist {filePath}")
            database.updateStatus(clip.id, "MISSING")
def deleteClipsForGame(game):
    clips = database.getGameClipsByStatus(game, "DOWNLOADED")

    print("Attemping to delete all clips for %s (%s downloaded found)" % (game, len(clips)))
    for i, clip in enumerate(clips):
        filePath = f"{settings.vid_filepath}/%s.mp4" % clip.mp4
        print(f"Checking if clip ({i + 1}/{len(clips)}) exists")
        if not os.path.exists(f"{settings.vid_filepath}/%s.mp4" % clip.mp4):
            print(f"Clip does not exist {filePath}")
            database.updateStatus(clip.id, "FOUND")
        else:
            os.remove(f"{settings.vid_filepath}/%s.mp4" % clip.mp4)
            print(f"Clip exists, deleting it {filePath}")
            database.updateStatus(clip.id, "FOUND")
Пример #4
0
def createTwitchVideoFromJSON(videojson):
    final_clips = []

    clips = videojson["clips"]

    for clip in clips:
        print(clip)
        id = clip["id"]
        audio = clip["audio"]
        used = clip["keep"]

        isUpload = clip["isUpload"]
        isIntro = clip["isIntro"]
        uploadMp4 = clip["mp4"]
        uploadDuration = clip["duration"]

        if not isUpload:
            oldwrapper = database.getClipById(id)
            oldwrapper.audio = audio
            oldwrapper.isUsed = used

            final_clips.append(oldwrapper)
            database.updateStatus(id, "USED")
        else:
            id = "na"
            url = "na"
            streamer_name = "na"
            title = "na"
            channel_url = "na"

            if not isIntro:
                name = len(uploadMp4.split("/"))
                new_name = (uploadMp4.split("/")[name - 1]).replace(".mp4", "")

                channel_url = f"https://www.twitch.tv/{new_name}"
                streamer_name = new_name

            wrapper = ClipWrapper(id, url, streamer_name, title, channel_url)
            wrapper.mp4 = uploadMp4
            wrapper.vid_duration = uploadDuration
            wrapper.isIntro = isIntro
            wrapper.audio = audio
            wrapper.isUsed = used

            final_clips.append(wrapper)

    video = TikTokVideo(final_clips)
    return video
Пример #5
0
def reformatPartialJson(videojson):
    final_clips = []

    clips = videojson["clips"]
    name = videojson["name"]

    intervalClip = None
    outroClip = None
    for clip in clips:
        id = clip["id"]

        isUpload = clip["isUpload"]
        isIntro = clip["isIntro"]
        isOutro = clip["isOutro"]
        uploadMp4 = clip["mp4"]
        used = clip["keep"]
        isInterval = clip["isInterval"]

        if not used:
            mp4path = "%s/%s.mp4" % (settings.vid_filepath, uploadMp4)
            print("Clip %s is not used, deleting" % mp4path)
            os.remove(mp4path)

        if not isUpload:
            oldwrapper = database.getClipById(id)
            database.updateStatus(id, "USED")
            clip["author_name"] = oldwrapper.author_name
            final_clips.append(clip)
        else:
            streamer_name = ""
            title = ""

            if not isIntro:
                name = len(uploadMp4.split("/"))
                new_name = (uploadMp4.split("/")[name - 1]).replace(".mp4", "")

                channel_url = f"https://www.twitch.tv/{new_name}"
                streamer_name = new_name

            clip["author_name"] = streamer_name
            clip["title"] = title

            if isOutro:
                clip["author_name"] = ""
                outroClip = clip
                continue

            final_clips.append(clip)
        if isInterval:
            clip["author_name"] = ""
            intervalClip = clip
        if not isUpload and intervalClip is not None and not isIntro and used and not isOutro:
            final_clips.append(intervalClip)

    if outroClip is not None:
        final_clips.append(outroClip)

    #print(final_clips)
    videojson["clips"] = final_clips
    videojson["name"] = name
    #print(videojson)
    return videojson
def createTwitchVideoFromJSON(videojson):
    final_clips = []

    clips = videojson["clips"]
    colour1 = videojson["colour1"]
    colour2 = videojson["colour2"]
    background_volume = videojson["background_volume"]
    music_cat = videojson["music"]

    for clip in clips:
        print(clip)
        id = clip["id"]
        start_cut = clip["start_cut"]
        end_cut = clip["end_cut"]
        audio = clip["audio"]
        used = clip["keep"]

        isUpload = clip["isUpload"]
        isIntro = clip["isIntro"]
        uploadMp4 = clip["mp4"]
        uploadDuration = clip["duration"]

        if not isUpload:
            oldwrapper = database.getClipById(id)
            oldwrapper.start_cut = start_cut
            oldwrapper.end_cut = end_cut
            oldwrapper.audio = audio
            oldwrapper.isUsed = used

            final_clips.append(oldwrapper)
            database.updateStatus(id, "USED")
        else:
            id = "na"
            url = "na"
            streamer_name = "na"
            title = "na"
            channel_url = "na"

            if not isIntro:
                name = len(uploadMp4.split("/"))
                new_name = (uploadMp4.split("/")[name - 1]).replace(".mp4", "")

                channel_url = f"https://www.twitch.tv/{new_name}"
                streamer_name = new_name

            wrapper = TwitchClipWrapper(id, url, streamer_name, title,
                                        channel_url)
            wrapper.mp4 = uploadMp4
            wrapper.vid_duration = uploadDuration
            wrapper.isIntro = isIntro
            wrapper.start_cut = start_cut
            wrapper.end_cut = end_cut
            wrapper.audio = audio
            wrapper.isUsed = used

            final_clips.append(wrapper)

    video = TwitchVideo(final_clips)
    video.colour1 = colour1
    video.colour2 = colour2
    video.audio_cat = music_cat
    video.background_volume = background_volume
    return video