-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [dl-downer] add YouTube support
- Loading branch information
1 parent
4b501ad
commit cf5aea9
Showing
3 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ pywidevine==1.8.0 | |
playwright==1.42.0 | ||
python-dotenv | ||
psycopg2-binary | ||
yt-dlp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import os | ||
import subprocess | ||
|
||
from loguru import logger | ||
|
||
from ..models.dl_request import DLRequest | ||
|
||
def YOUTUBE_DL(dl_request: DLRequest): | ||
|
||
command = [ 'yt-dlp', | ||
'--yes-playlist', | ||
'-N', '4', | ||
'--restrict-filenames', | ||
'--write-subs', | ||
'--sub-langs', 'all', | ||
'--merge-output-format', 'mkv', | ||
] | ||
|
||
if dl_request.preferred_quality_matcher: | ||
p = dl_request.preferred_quality_matcher | ||
command.extend([ '-f', f'bv[height<={p}]+ba/b[height<={p}]' ]) | ||
|
||
filename = '%(title)s.%(ext)s' | ||
if dl_request.output_filename: | ||
filename = f'{dl_request.output_filename}.%(ext)s' | ||
file_path = os.path.join( | ||
os.getenv('DOWNLOADS_FOLDER', './downloads'), | ||
dl_request.platform, | ||
filename, | ||
) | ||
|
||
command.extend([ '-o', file_path ]) | ||
command.extend([ dl_request.video_page_or_manifest_url ]) | ||
|
||
logger.debug(f'Running command: {command}') | ||
subprocess.run(command) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters