Я написал сценарий PowerShell для выполнения постобработки звука, загруженного youtube-dl, и пытаюсь использовать флаг --exec
для его автоматического вызова. Проблема в том, что я не знаю, как правильно это сделать, чтобы он работал со всеми возможными именами файлов.
Команда, которая работает, за исключением заголовков видео с '
или ()
в них:
PS > youtube-dl -i -f bestaudio --exec 'powershell -ExecutionPolicy RemoteSigned D:\PowerShell\ConvertAndNormalize.ps1 "{}"' https://youtu.be/zRunkRiylvM
[youtube] zRunkRiylvM: Downloading webpage
[youtube] zRunkRiylvM: Downloading video info webpage
[download] Dream Big, Princess – Live Your Story (Official Lyric Video) _ Disney-zRunkRiylvM.webm has already been downloaded
[download] 100% of 3.14MiB
[exec] Executing command: powershell -ExecutionPolicy RemoteSigned D:\PowerShell\ConvertAndNormalize.ps1 "Dream Big, Princess – Live Your Story (Official Lyric Video) _ Disney-zRunkRiylvM.webm"
Official : The term 'Official' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:78
+ ... Normalize.ps1 Dream Big, Princess – Live Your Story (Official Lyric V ...
+ ~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Official:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
ERROR: Command returned error code 1
PS > youtube-dl -i -f bestaudio --exec 'powershell -ExecutionPolicy RemoteSigned D:\PowerShell\ConvertAndNormalize.ps1 "{}"' https://youtu.be/tTuwo_TqlhQ
[youtube] tTuwo_TqlhQ: Downloading webpage
[youtube] tTuwo_TqlhQ: Downloading video info webpage
[download] Destination: Tangled Lyric Video _ I've Got A Dream _ Sing Along-tTuwo_TqlhQ.m4a
[download] 100% of 3.05MiB in 00:00
[ffmpeg] Correcting container in "Tangled Lyric Video _ I've Got A Dream _ Sing Along-tTuwo_TqlhQ.m4a"
[exec] Executing command: powershell -ExecutionPolicy RemoteSigned D:\PowerShell\ConvertAndNormalize.ps1 "Tangled Lyric Video _ I've Got A Dream _ Sing Along-tTuwo_TqlhQ.m4a"
The string is missing the terminator: '.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : TerminatorExpectedAtEndOfString
ERROR: Command returned error code 1
И команда, которая разбивает только видео с '
в названии:
PS > youtube-dl -i -f bestaudio --exec "powershell -ExecutionPolicy RemoteSigned D:\PowerShell\ConvertAndNormalize.ps1 '{}'" https://youtu.be/tTuwo_TqlhQ
[youtube] tTuwo_TqlhQ: Downloading webpage
[youtube] tTuwo_TqlhQ: Downloading video info webpage
[download] Tangled Lyric Video _ I've Got A Dream _ Sing Along-tTuwo_TqlhQ.m4a has already been downloaded
[download] 100% of 3.05MiB
[ffmpeg] Correcting container in "Tangled Lyric Video _ I've Got A Dream _ Sing Along-tTuwo_TqlhQ.m4a"
[exec] Executing command: powershell -ExecutionPolicy RemoteSigned D:\PowerShell\ConvertAndNormalize.ps1 '"Tangled Lyric Video _ I've Got A Dream _ Sing Along-tTuwo_TqlhQ.m4a"'
The string is missing the terminator: '.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : TerminatorExpectedAtEndOfString
ERROR: Command returned error code 1
Как я могу заставить его работать с этими и, возможно, другими крайними случаями, которые я мог пропустить?