コード例 #1
0
def vid_splitter():
    from modules import VideoEditor
    from werkzeug.utils import secure_filename
    from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip
    import tempfile
    
    tempdirectory = tempfile.gettempdir()    
    print(str(tempdirectory))
    data = utils.pre_load("Online-Video-Editor","Online Video Splitter in Python","Online Video Splitter")
    data['result'] = ""
    data["file_download"] = ""
    data["intervals"] = ""
    vid_form = VideoEditor.VidForm()
    if request.method == "POST":
        if vid_form.file_download.data != "":
            from flask import send_file
            return send_file(os.path.join('../', str(vid_form.file_download.data)), as_attachment=True)
            #os.remove(str(vid_form.file_download.data))

        try:            
            file = request.files['target_file']
            data["intervals"] = vid_form.intervals.data
            intervals = vid_form.intervals.data.split(",")
            
            filename = secure_filename(file.filename)
            file.save(os.path.join(tempdirectory, filename))

            #file.save(filename)                  
            splits_files = []
            
            for interval in intervals:
                start, end = interval.split(":")
                file_path_op = os.path.join(tempdirectory, filename.split(".")[0]+start+"-"+end+".mp4")
                ffmpeg_extract_subclip(os.path.join(tempdirectory,filename), int(start), int(end), targetname=file_path_op)
                splits_files.append(file_path_op)
                
            file_path_zip =  os.path.join(tempdirectory, filename.split(".")[0]+".zip")
            import zipfile
            with zipfile.ZipFile(file_path_zip, 'w') as myzip:
                for each_path in splits_files:
                    myzip.write(each_path)
                    os.remove(each_path)
            os.remove(os.path.join(tempdirectory,filename))
            data['result'] = "Split operation completed successfully. Please click the below button to download."
            data["file_download"] = file_path_zip
            return render_template('Video-Splitter.html', data=data, vid_form = vid_form)
            
        except  Exception as e:
            print(e)
            data["result"] = "Exception: "+str(e)
            return render_template('Video-Splitter.html', data=data, vid_form = vid_form)

    return render_template('Video-Splitter.html', data=data, vid_form = vid_form)
コード例 #2
0
def update_elite_list():
    cat = ['R','Linux', 'SQL', 'Python', 'VIM','Spark','Raspberry-Pi','Java']
    data = utils.pre_load("Elite List Updation","Portal to update Elite List","Elite List Update")
    if request.method == "POST":
        cat = request.form.get('cat')
        topic = request.form.get('topic')
        sol = request.form.get('sol')
        comment = request.form.get('comment')
        new_entry = E_List(topic, sol, comment, cat)
        db.session.add(new_entry)
        db.session.commit()
        return render_template('Update_E_List.html', data=data)
    return render_template('Update_E_List.html', data=data, cat=cat)
コード例 #3
0
def det_mat():
    from modules import DetMat
    gen_form = DetMat.GenForm()
    data = utils.pre_load("Online Matrix Determinant Calculator","Perform matrix operation - determinant","Determinant of Matrix")
    data["n_val"] = 0
    data["det"] = -1
    if request.method == "POST":
        if gen_form.validate_on_submit():
            try:
                data["n_val"] = gen_form.n_val.data
                if "ip_0" in request.form:
                    mat =[]
                    for i in range(data["n_val"]):
                        e_row = request.form.get('ip_'+str(i))
                        e_row = [float(s) for s in e_row.split(',')]
                        mat.append(e_row)
                    import numpy as np
                    data["det"] = round(np.linalg.det(mat),2)
            except:
                data["det"] = "Error, please check the input."        
        return render_template('Det_Matrix.html', data=data, gen_form=gen_form)
    return render_template('Det_Matrix.html', data=data, gen_form=gen_form)
コード例 #4
0
def index():
    return render_template('Index.html', data=utils.pre_load("The Beginner's Arsenal","Home Page of The Beginner's Arsenal",""))
コード例 #5
0
def el_gen(list_cat):
    con = E_List.query.filter_by(cat=list_cat)
    return render_template('EL_Template.html', data=utils.pre_load(list_cat, list_cat+" Tips, Errors and Solutions", list_cat+" - The Elite List"), con=con)
コード例 #6
0
def el_home():
    return render_template('EL_Home.html', data=utils.pre_load("The Elite List Home","Homepage for all technical handbooks","The Elite List | Home"))
コード例 #7
0
def bmi_cal():
    return render_template('Online_BMI_Calculator.html', data=utils.pre_load("Online-BMI-Calculator","BMI calculator online from height and weight","BMI Calculator"))
コード例 #8
0
def nz_postcode_finder():
    return render_template('NZ_PostCode_Finder.html', data=utils.pre_load("Find New Zealand Post Codes Online","Find Postal Codes in New Zealand Suburbs","Post Code Finder - New Zealand"))
コード例 #9
0
def morse_code_gen():
    return render_template('Morse_Code_Generator.html', data=utils.pre_load("Text to Morse Code Converter Online","Generate Morse Code Online","Text to Morse Code Online"))
コード例 #10
0
def perm_comb():
    return render_template('Perm_Comb.html', data=utils.pre_load("Find Permutation and Combination Online","Calculate Permutations and Combinations of two numbers online","Permutation & Combination Finder"))
コード例 #11
0
def extract_email():
    return render_template('Extract_Emails.html', data=utils.pre_load("Extract Emails from Text Online","Extract emails from text - Online","Emails from Text"))
コード例 #12
0
def bar_code_gen():
    return render_template("Bar_Code.html", data=utils.pre_load("Generate Bar Code Online for Free","Online Bar Code Generator","Bar Code Generator"))
コード例 #13
0
def qr_code_gen():
    return render_template("QR_Code.html", data=utils.pre_load("Generate QR Code Online","Generate and download QR code","QR Code Generator"))
コード例 #14
0
def page_not_found(e):
    return render_template('404.html',data=utils.pre_load("Page not found | TheBeArsenal","he requested page is not present in the application","Page Not Found")), 404