Emotional Code|

Nolca

园龄:6年9个月粉丝:12关注:9

2020-06-06 17:54阅读: 562评论: 0推荐: 0

Youtube-dl批处理 & ytb-dlp

@echo off
title [调试]
cmd
cls

要建一个ytb-onlyShorts.txt,只放shorts的后缀
配合vscode-macros宏插件手动爬虫

"pickUpShorts":[
// {
// "command": [
"editor.action.nextMatchFindAction",
"workbench.action.focusFirstEditorGroup",
"editor.action.clipboardCopyAction",
"workbench.action.focusSecondEditorGroup",
"editor.action.clipboardPasteAction",
{"command": "type",
"args": {
"text": "\n",
// "times": 10
}},
"workbench.action.focusFirstEditorGroup",
// ]
// "args": {
// "times": 50
// }
// }
],
1list.bat
@echo off
setlocal enabledelayedexpansion
chcp 65001
if not "%~1"=="" (set p=%~1 & goto abc)
set /p p=文件夹名(这会覆盖merge.txt):
:abc
cd %p%
cd . >.\merge.txt
dir /oen/b | find ".mp4">.\merge_0.txt
for /f "delims=" %%i in (.\merge_0.txt) do (
echo file '%%i'>>.\merge.txt
)
start notepad.exe .\merge.txt
del .\merge_0.txt
2merge.bat
@echo off
setlocal enabledelayedexpansion
chcp 65001
cd dsand00
..\ffmpeg -f concat -safe 0 -i merge.txt -c copy -y ..\o1.mp4
echo 若遇到错误,请尝试重命名文件名!防止特殊字符导致ffmpeg报错!
title 按任意键尝试有损合并模式
echo 按任意键尝试有损合并模式
pause>nul
..\ffmpeg -f concat -safe 0 -i merge.txt -y ..\o1_loss.mp4
pause>nul
you-dlp (python)
@echo off
setlocal enabledelayedexpansion
:begin
set exe=yt-dlp.exe
echo ____
( set /p pm= & set /p pm2= & set /p url=)<bat.inf
title 视频、封面、字幕下载
echo 指令:(回车)继续上次下载 o.仅后缀(Shorts) f.提取音频 s.设置 h.帮助
echo 上次下载:%url%
set /p u=地址:
if "%u%"=="" set u=%url%
if "%u%"=="o" goto lists
if "%u%"=="f" goto ffmpeg
if "%u%"=="s" goto setting
if "%u%"=="h" goto help
set /p="%pm%"<nul>bat.inf
echo.>>bat.inf
set /p="%pm2%"<nul>>bat.inf
echo.>>bat.inf
set /p="%u%"<nul>>bat.inf
%exe% %pm% %u% --downloader aria2c --downloader-args "-x 16 -k 2M --check-certificate=false"
title OK
pause
goto begin
:lists
set /p="%pm%"<nul>bat.inf
echo.>>bat.inf
set /p="%pm2%"<nul>>bat.inf
echo.>>bat.inf
for /f %%i in (.\ytb-onlyshorts.txt) do (title %%i & %exe% %pm% https://www.youtube.com/watch?v=%%i --downloader aria2c --downloader-args "-x 16 -k 2M --check-certificate=false")
title OK
pause
goto begin
:setting
set pm=
( set /p pm= & set /p pm2=)<bat.inf
echo _______
echo 当前参数:%pm%
echo 1.默认参数 2.代理 3.格式/清晰度 4.下载线程 5.字幕 9.清空参数 0.返回
choice /c 1234590 >nul
if %errorlevel%==1 (
if not "!pm!"=="" (echo 已有参数! & goto setting)
set /p="--proxy 127.0.0.1:7890 -f "best/bestvideo+bestaudio" --merge-output-format mp4 --write-subs --write-auto-subs --sub-format "ass/srt/best" --sub-langs "zh-Han.*,en.*" --write-thumbnail --no-overwrites -o ".\%%^(uploader^)s\^%%^(title^)s_^%%^(id^)s.%%^(ext^)s"" <nul>>bat.inf
)
if %errorlevel%==2 (
netsh winhttp import proxy source=ie|findstr /i "代理服务器:" && (
set /p port=手动输入端口号(添加一次即可):
set /p="--proxy 127.0.0.1:!port!"<nul>>bat.inf
)
)
if %errorlevel%==3 echo 参见官网说明文档,readme.md
if %errorlevel%==4 echo "-x 线程数 -k 文件分块大小"
if %errorlevel%==5 echo --write-sub --sub-lang zh-Hans,zh-Hant,en
if %errorlevel%==6 set /p=<nul >bat.inf
if %errorlevel%==7 ( cls & goto begin)
goto setting
:ffmpeg
set /p file=拖拽视频:
ffmpeg.exe -i %file% -vn -sn -c:a copy -y -map 0:a:0 "提取音频.aac"
goto begin
:help
echo _______
echo Nolca诺卡自用。
echo 1.官网 2. 3. 4. 5. 9.版本更新 0.返回
choice /c 1234590 >nul
if %errorlevel%==1 goto help
if %errorlevel%==2 goto help
if %errorlevel%==3 goto help
if %errorlevel%==4 goto help
if %errorlevel%==5 goto help
if %errorlevel%==6 (
set /p="当前版本:"<nul
%exe% --version
choice /m 升级
if !errorlevel!==1 %exe% -U --proxy 127.0.0.1:1021
)
if %errorlevel%==7 goto begin
goto help
youtube-dl旧版
@echo off
setlocal enabledelayedexpansion
:begin
echo ____
( set /p pm= & set /p pm2= & set /p url=)<bat.inf
title 视频、封面、字幕下载
echo 指令:(回车)继续上次下载 f.提取音频 s.设置 h.帮助
echo 上次下载:%url%
set /p u=地址:
if "%u%"=="" set u=%url%
if "%u%"=="f" goto ffmpeg
if "%u%"=="s" goto setting
if "%u%"=="h" goto help
set /p="%pm%"<nul>bat.inf
echo.>>bat.inf
set /p="%pm2%"<nul>>bat.inf
echo.>>bat.inf
set /p="%u%"<nul>>bat.inf
youtube-dl.exe %pm% %u% --external-downloader aria2c --external-downloader-args "-x 4 -k 1M"
title OK
pause
goto begin
:setting
set pm=
( set /p pm= & set /p pm2=)<bat.inf
echo _______
echo 当前参数:%pm%
echo 1.默认参数 2.代理 3.格式/清晰度 4.下载线程 5.字幕 9.清空参数 0.返回
choice /c 1234590 >nul
if %errorlevel%==1 (
if not "!pm!"=="" (echo 已有参数! & goto setting)
set /p="--proxy 127.0.0.1:1021 -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best" --merge-output-format mp4 --no-post-overwrites --write-sub --sub-lang zh-Hans,en --write-auto-sub --write-thumbnail"<nul>>bat.inf
)
if %errorlevel%==2 (
netsh winhttp import proxy source=ie|findstr /i "代理服务器:" && (
set /p port=手动输入端口号(添加一次即可):
set /p="--proxy 127.0.0.1:!port!"<nul>>bat.inf
)
)
if %errorlevel%==3 echo 参见官网说明文档,readme.md
if %errorlevel%==4 echo "-x 线程数 -k 文件分块大小"
if %errorlevel%==5 echo --write-sub --sub-lang zh-Hans,zh-Hant,en
if %errorlevel%==6 set /p=<nul >bat.inf
if %errorlevel%==7 ( cls & goto begin)
goto setting
:ffmpeg
set /p file=拖拽视频:
ffmpeg.exe -i %file% -vn -sn -c:a copy -y -map 0:a:0 "提取音频.aac"
goto begin
:help
echo _______
echo Nolca诺卡自用。
echo 1.官网 2. 3. 4. 5. 9.版本更新 0.返回
choice /c 1234590 >nul
if %errorlevel%==1 goto help
if %errorlevel%==2 goto help
if %errorlevel%==3 goto help
if %errorlevel%==4 goto help
if %errorlevel%==5 goto help
if %errorlevel%==6 (
set /p="当前版本:"<nul
youtube-dl --version
choice /m 升级
if !errorlevel!==1 youtube-dl -U --proxy 127.0.0.1:1021
)
if %errorlevel%==7 goto begin
goto help

本文作者:Nolca

本文链接:https://www.cnblogs.com/nolca/p/13055656.html

版权声明:本作品采用 收益分享revenue sharing 许可协议进行许可。

posted @   Nolca  阅读(562)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起
  1. 1 ⏩intro 山姆精
  2. 2 🎸吉他 马叉
  3. 3 ☁升调 山姆精
  4. 4 🐦Flutter Virtual Riot/Madi
  5. 5 🎶纯律 山姆精
  6. 6 👻yeah~Color Bass! VR
⏩intro - 山姆精
00:00 / 00:00
An audio error has occurred, player will skip forward in 2 seconds.