def home_page(): """ Displaying homepage """ title = "YDL | YouTube Downloader" if request.method == 'POST': attempted_url = request.form['url'] attempted_choice = int(request.form['submit']) title = [attempted_url, attempted_choice] if attempted_url != "": if verify(attempted_url): result_id = get_media(attempted_url, attempted_choice) session['url'] = attempted_url session['id'] = result_id session['choice'] = attempted_choice filename = fetch_name(attempted_url) session['filename'] = filename #return render_template('material-life.html', title = "Success {}".format(title)) # return render_template('material-life.html', title = result_id) return redirect(url_for('return_file')) else: return render_template('material-life.html', title="YDL | Doesn't belong to YouTube") else: return render_template('material-life.html', title="YDL | URL shouldn't be empty") return render_template('material-life.html', title=title)
def index(): """ Displaying homepage """ title = "YDL | YouTube Downloader" if request.method == "POST": attempted_url = request.form["url"] attempted_choice = int(request.form["submit"]) title = [attempted_url, attempted_choice] if attempted_url != "": result_id = get_media(attempted_url, attempted_choice) session["url"] = attempted_url session["id"] = result_id session["choice"] = attempted_choice filename = fetch_name(attempted_url) session["filename"] = filename return redirect(url_for("return_file")) else: return render_template( "index.html", title="YDL | URL shouldn't be empty" ) return render_template("index.html", title=title)
def home_page(): """ Displaying homepage """ title = "YDL" name_of_company = "YouTube Downloader" download_location = "YouTube URL" if request.method == 'POST': attempted_url = request.form['url'] CHOICES ={"Audio": 1, "Video": 2, "Audio Playlist": 3, "Video Playlist": 4 } attempted_choice = list(CHOICES.keys())[list(CHOICES.values()).index(int(request.form['submit']))] num_choice = CHOICES.get(attempted_choice) if verify(attempted_url) : result_id = get_media(attempted_url, num_choice) session['url'] = attempted_url session['id'] = result_id session['choice'] = num_choice #return render_template('index.html', title = result_id) return redirect(url_for('file_downloads')) return render_template('error_template.html' , title = "Invalid URL", message = "Are you being intentionally dense? Huh?", subline = "Invalid URL", image_location = url_for('static', filename = 'images/house-simpson.jpg')) return render_template('index.html', name_of_company = name_of_company, download_location = download_location, title = title)