-
Notifications
You must be signed in to change notification settings - Fork 285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
不能https://www.bilibili.com/video/BV1LM411d7qg/?spm_id_from=333.999.0.0 #633
Comments
实在没空搞,阿b我现在都直接调 yt-dlp。 |
好的,谢谢回复! |
class MpvFD(ExternalFD):
AVAILABLE_OPT = '--version'
def _make_cmd(self, tmpfilename, info_dict):
proxy = self.params.get('proxy')
cmd = [self.exe, ]
if proxy:
cmd += ['--http-proxy='+proxy]
if info_dict.get('http_headers') is not None:
for key, val in info_dict['http_headers'].items():
cmd += ['--http-header-fields='+f'{key}: {val}']
cmd += [ info_dict['url']]
return cmd |
From 2625ed71a3e33fc6853ce5e16e31d7ebe261f99c Mon Sep 17 00:00:00 2001
From: Zhang Ning <[email protected]>
Date: Sun, 7 Apr 2024 20:31:16 +0800
Subject: [PATCH] add mpv postprocessor
Signed-off-by: Zhang Ning <[email protected]>
---
yt_dlp/postprocessor/__init__.py | 1 +
yt_dlp/postprocessor/mpv.py | 37 ++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+)
create mode 100644 yt_dlp/postprocessor/mpv.py
diff --git a/yt_dlp/postprocessor/__init__.py b/yt_dlp/postprocessor/__init__.py
index bfe9df733..3736b0238 100644
--- a/yt_dlp/postprocessor/__init__.py
+++ b/yt_dlp/postprocessor/__init__.py
@@ -3,6 +3,7 @@
from .common import PostProcessor
from .embedthumbnail import EmbedThumbnailPP
from .exec import ExecAfterDownloadPP, ExecPP
+from .mpv import MpvPP
from .ffmpeg import (
FFmpegConcatPP,
FFmpegCopyStreamPP,
diff --git a/yt_dlp/postprocessor/mpv.py b/yt_dlp/postprocessor/mpv.py
new file mode 100644
index 000000000..300eebbe0
--- /dev/null
+++ b/yt_dlp/postprocessor/mpv.py
@@ -0,0 +1,37 @@
+from .common import PostProcessor
+from ..utils import Popen, PostProcessingError, encodeArgument
+
+
+class MpvPP(PostProcessor):
+
+ def run(self, info):
+ formats = info.get("formats")
+ best_audio = ""
+ best_video = ""
+ aid = ""
+ vid = ""
+ headers = ""
+
+ for f in formats:
+ audio_ext = f.get("audio_ext")
+ video_ext = f.get("video_ext")
+ if audio_ext != "none":
+ best_audio = f.get("url")
+ aid = f.get("format_id");
+ if video_ext != "none":
+ best_video = f.get("url")
+ vid = f.get("format_id");
+ headers = f.get("http_headers")
+ cmd = ["mpv", best_video]
+ for key, val in headers.items():
+ cmd += ['--http-header-fields='+f'{key}: {val}']
+
+ if best_video != best_audio and best_audio != "":
+ cmd += [ '--audio-file='+best_audio ]
+
+ encoded_cmd = [encodeArgument(a) for a in cmd ]
+ _, _, return_code = Popen.run(encoded_cmd, text=True)
+ if return_code != 0:
+ raise PostProcessingError(f'Command returned error code {return_code}')
+ return [], info
+
--
2.44.0 |
type ytp 使用 |
哥,MPV 内置有支持脚本,不需要自己写啊。默认关闭 |
没有编译Lua. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No description provided.
The text was updated successfully, but these errors were encountered: