]> Skullheadx's Git Forge - youtube-downloader.git/commitdiff
-d works
authorSkullheadx <94652084+Skullheadx@users.noreply.github.com>
Mon, 14 Oct 2024 18:13:21 +0000 (14:13 -0400)
committerSkullheadx <94652084+Skullheadx@users.noreply.github.com>
Mon, 14 Oct 2024 18:13:21 +0000 (14:13 -0400)
README.md
ytdl/__pycache__/funcmodule.cpython-312.pyc
ytdl/funcmodule.py

index d94755b52df218707135a16bade4437a4282f0c6..60e0dc8dcb87106f13901ac2a080e42f0be9a181 100644 (file)
--- 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
index d4a204210f42dc90979a8808ab074e056acb1c42..f626c540c08a40ca5875a81d5178bb0b3c1d4285 100644 (file)
Binary files a/ytdl/__pycache__/funcmodule.cpython-312.pyc and b/ytdl/__pycache__/funcmodule.cpython-312.pyc differ
index 9e683651123a38c1be06f7daa2ecef24d8029b12..56c08e4eb1eddf1a6300d55eb343676d1ecf827a 100644 (file)
@@ -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)
-