update
This commit is contained in:
@@ -9,17 +9,20 @@ VIDEOS_DIR = "/videos"
|
||||
MIN_VALID_SIZE = 1024 * 100 # 100 KB
|
||||
|
||||
|
||||
def downloadAsync(videoId: int, youtubeUrl: str):
|
||||
threading.Thread(target=downloadVideo, args=(videoId, youtubeUrl)).start()
|
||||
def downloadAsync(videoId: int, youtubeUrl: str, maxHeight: int = 1080):
|
||||
threading.Thread(target=downloadVideo, args=(videoId, youtubeUrl, maxHeight)).start()
|
||||
|
||||
|
||||
def downloadVideo(videoId: int, youtubeUrl: str):
|
||||
def downloadVideo(videoId: int, youtubeUrl: str, maxHeight: int = 1080):
|
||||
outputPath = f"{VIDEOS_DIR}/{videoId}.mp4"
|
||||
formatFilter = f"bestvideo[ext=mp4][vcodec^=avc][height<={maxHeight}]+bestaudio[ext=m4a]/best[ext=mp4]"
|
||||
|
||||
subprocess.run(
|
||||
[
|
||||
"yt-dlp",
|
||||
"-f", "bestvideo[ext=mp4][vcodec^=avc]+bestaudio[ext=m4a]/best[ext=mp4]",
|
||||
"--cookies", "/app/cookies.txt",
|
||||
"--remote-components", "ejs:github",
|
||||
"-f", formatFilter,
|
||||
"-o", outputPath,
|
||||
"--merge-output-format", "mp4",
|
||||
"--force-overwrites",
|
||||
|
||||
Reference in New Issue
Block a user