From: Skullheadx <94652084+Skullheadx@users.noreply.github.com> Date: Mon, 14 Oct 2024 18:13:21 +0000 (-0400) Subject: -d works X-Git-Url: http://git.skullheadx.com/?a=commitdiff_plain;h=6fd1d7aadec20c07da9bc1cea959f10c1f9e76fe;p=youtube-downloader.git -d works --- diff --git a/README.md b/README.md index d94755b..60e0dc8 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ downloads the audio and video and stitches it together in the current directory. # TODO: - [x] add video only - [x] add audio + video separate -- [ ] add stitched together +- [x] add stitched together - [x] add force replace - [ ] add album name +- [ ] add force replace check for audio and video only \ No newline at end of file diff --git a/ytdl/__pycache__/funcmodule.cpython-312.pyc b/ytdl/__pycache__/funcmodule.cpython-312.pyc index d4a2042..f626c54 100644 Binary files a/ytdl/__pycache__/funcmodule.cpython-312.pyc and b/ytdl/__pycache__/funcmodule.cpython-312.pyc differ diff --git a/ytdl/funcmodule.py b/ytdl/funcmodule.py index 9e68365..56c08e4 100644 --- a/ytdl/funcmodule.py +++ b/ytdl/funcmodule.py @@ -48,7 +48,7 @@ def download(link, mode, force=False): download_thumbnail(yt.thumbnail_url, thumbnail_filename) if mode == '-a' or mode == '-v': - download_single_stream(yt, filename,thumbnail_filename, mode) + download_single_stream(yt, filename, thumbnail_filename, mode) elif mode == '-av' or mode == '-d': download_double_stream(yt, filename, thumbnail_filename, mode) @@ -90,7 +90,7 @@ def download_single_stream(yt, filename, thumbnail_filename, mode): os.remove(default_filename) -def download_double_stream(yt, filename,thumbnail_filename, mode): +def download_double_stream(yt, filename, thumbnail_filename, mode): print(f"Fetching streams for {yt.title}") assert len(yt.streams.filter(only_audio=True)) > 0, "No available audio streams" audio_stream = yt.streams.filter(only_audio=True).order_by("abr").last() @@ -123,11 +123,39 @@ def download_double_stream(yt, filename,thumbnail_filename, mode): ] subprocess.run(command) elif mode == '-d': - pass - + command = [ + 'ffmpeg', + '-i', audio_default_filename, + '-i', video_default_filename, + '-map', '0', + '-map', '1', + '-c', 'copy', + '-disposition:v:1', 'attached_pic', + '-metadata', f'title={filename}', + '-metadata', f'artist={yt.author}', + '-metadata', f'comment={big_num_format(yt.views) + " views"}', + '-metadata', f'date={yt.publish_date}', + filename + "tmp" + ".mp4", + '-y' + ] + subprocess.run(command) + + command = [ + 'ffmpeg', + '-i', filename + "tmp" + ".mp4", + '-i', thumbnail_filename, + '-map', '0', + '-map', '1', + '-c', 'copy', + '-disposition:v:1', 'attached_pic', + filename + ".mp4", + '-y' + ] + subprocess.run(command) + + os.remove(filename + "tmp" + ".mp4") # clean up tmp files os.remove(thumbnail_filename) os.remove(audio_default_filename) os.remove(video_default_filename) -