홈>
youtube-dl (프론트 엔드 다운로드-WEB UI)을 통해 YouTube 및 기타 웹 사이트 비디오 및 오디오 파일을 다운로드하는 방법
프론트 엔드를 통해 비디오를 검색하고 다운로드하십시오.
필자는 파이썬과 플라스크입니다-
from flask import (
Flask, Response,
render_template,
request,
redirect,
flash,
url_for,
send_file,
session,
)
import subprocess
from ydl import get_media, verify, fetch_name
from zipper import zipping
import os
app = Flask(__name__)
app.secret_key = "supposed to be a secret"
@app.route("/return-file/")
def return_file():
import pdb
#pdb.set_trace()
num_choice = session.get("choice")
filename = session.get("filename")
url = session.get("url")
if num_choice == 1:
filename_formatted = filename + ".mp3"
location = "media/Audio downloads/{}.mp3".format(session.get("id"))
if num_choice == 2:
#filename_formatted = filename + ".mp4"
#cc = get_media(url, num_choice)
print(url)
print('==============================================================================')
#"youtube-dl", "--get-url", url
#subprocess.run(["youtube-dl", "--no-check-certificate", "--get-url", url])
#subprocess.run(["youtube-dl", "--no-check-certificate", url])
test = subprocess.run(["youtube-dl", "--no-check-certificate", "--get-filename", url])
print(test)
csv = '1,2,3\n4,5,6\n'
return Response(
csv,
mimetype="text/csv",
headers={"Content-disposition":
"attachment; filename=test"})
#return send_file('', attachment_filename="myplot.csv")
print('==============================================================================')
#subprocess.run(["youtube-dl", "--no-check-certificate", url])
#location = "media/{}.mp4".format(session.get("id"))
#if os.path.isdir(location):
#print('True')
if num_choice == 3 or num_choice == 4:
filename_formatted = filename + ".zip"
location = "media/{}.zip".format(session.get("id"))
#return send_file(
#location, attachment_filename=filename_formatted, as_attachment=True
#)
@app.route("/", methods=["GET", "POST"])
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)
@app.errorhandler(404)
def page_not_found(error):
"""
for anyone trying different links or searching for images within the server
"""
return (
render_template(
"error_template.html",
title="404 bud",
message="Time to make the chimi-fuckin'-changas. ",
subline="404, not there",
image_location=url_for("static", filename="images/deadpool-funny.jpg"),
),
404,
)
@app.errorhandler(400)
def bad_request(error):
"""
For handling situations where the server doesn't know what to do with the browser's request
"""
return (
render_template(
"error_template.html",
title="Aaaah ...",
message="나는 이해하지 못한다.",
subline="Yeah, the server couldn't understand what you asked for, Sorry",
image_location=url_for("static", filename="images/simpson-gangam.jpg"),
),
400,
)
if __name__ == "__main__":
app.run(debug=True)
- 콘솔 기본 다운로드 작업 중 ... 프런트 엔드를 통해 다운로드하고 싶습니다 ... 저장하지 않고 직접 다운로드
-
답변 # 1
관련 자료
- linux - wget을 사용하여 확장자 및 파일 이름의 특정 텍스트와 일치하는 파일 다운로드
- streaming - http에서 VLC를 사용하여 비디오를 다른 컴퓨터로 스트리밍하는 방법
- Android에서 ffmpeg를 사용하여 비디오가 주어진 경로를 저장하지 않는 이유는 무엇입니까?
- winscp get 명령을 사용하여 날짜 범위 내에서 파일을 다운로드하는 방법
- Python Selenium을 사용하여 Chrome에서 파일을 다운로드하려고 할 때 오류가 발생하는 이유
- dropbox - 명령 줄을 사용하여 zip 파일을 다운로드하는 방법
- http - Google API를 사용하여 YouTube에 동영상을 업로드하는 방법 도서관없이
- express - 백엔드에서 excel4node를 사용하여 프론트 엔드에서 엑셀 파일 다운로드
- amazon web services - 람다에서 nodejs를 사용하여 AWS 비디오 트랜스 코더를 구현하는 방법
- PHP를 사용하여 Facebook 페이지에 비디오를 업로드 할 수 없지만 curl을 사용할 수 있음
- windows 7 - AVS Video Converter 및 FreeMakeVideo Converter를 사용하여 변환 한 후 오디오가 없음
관련 질문
- python - 플라스크 - 경로가 없지만 동일한 오류가 계속 발생합니다
- javascript - Flask 양식으로 추가 데이터를 보내 시나요?
- python - 플라스크 SQL-Alchmey가 쿼리하는 동안 사전을 반환하지 않음
- 파이썬 플라스크에서 현재 날짜 시간을 얻는 방법
- python - Linux 서버의 flask에서 파일을 다운로드 할 때 오류 발생
- python - typeerror - product ()에 예기치 않은 키워드 인수 'product_id'가 있습니다
- python - 새 페이지 링크를 만들기 위해 목록을 반복하는 For In 루프를 Flask에서 코딩하는 방법은 무엇입니까?
- python - 플라스크 앱에서 pytesseract를 사용하는 방법
- python - Flask 서버가 오디오 파일을로드하지 않음
- python - Flask 코드를 다른 파일로 분할
pytube
를 사용할 수 있습니다youtube-dl
에 의존하는 모듈 . 앱을 만드는 것 같지만 동영상 URL을 사용하면 아래의 한 줄짜리 라이너를 사용하여 동영상을 다운로드 할 수 있습니다.