홈>
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 : 일대다 관계 flask-sqlalchemy를 식별하는 적절한 방법입니까?
- javascript : Flask는 페이지를 새로 고칠 때 게시 요청 상태를 제거합니다.
- python : Cloud Run Flask 애플리케이션의 비디오 업로드는 해당 파일 또는 디렉토리를 제공하지 않습니다.
- python : 반환 후/반환과 함께 code를 실행하기 위해 스레드를 사용하는 플라스크
- python : 플라스크 앱을 실행할 때 상위 폴더에서 모듈 가져오기가 작동하지 않음
- python : 플라스크를 사용하여 heroku bert pytorch 모델에 배포: 오류: _pickle.UnpicklingError: 잘못된 로드 키, 'v'
- python : 'function' 개체에는 JSON에 'load' 속성이 없습니다.
- python : 일대다 관계 플라스크
- python : Flask babel 인라인 변수
- Google Cloud Run에서 스레딩을 사용하는 Python Flask 앱의 일관되지 않은 성능
pytube
를 사용할 수 있습니다youtube-dl
에 의존하는 모듈 . 앱을 만드는 것 같지만 동영상 URL을 사용하면 아래의 한 줄짜리 라이너를 사용하여 동영상을 다운로드 할 수 있습니다.