I was trying to print info of a video in Youtube using yt-dlp and want to do stuff with it in PowerShell
Command:
yt-dlp.exe --print "{'domain': '%(webpage_url_domain)s', 'uploader': '%(uploader_id)s', 'status': '%(live_status)s', 'title': '%(title)s'}" https://www.youtube.com/live/nxbSLFv2JAs --ignore-no-formats-error
Output:
{'domain': 'youtube.com', 'uploader': '@AiraniIofifteen', 'status': 'was_live',
'title': '【 Minecraft 】イオそらとえーちゃん仲良く大作戦【 iofi / hololive 】'}
but when i want to convert it using ConvertFrom-Json the Japanese characters and those【】gone.
Command:
yt-dlp.exe --print "{'domain': '%(webpage_url_domain)s', 'uploader': '%(uploader_id)s', 'status': '%(live_status)s', 'title': '%(title)s'}" https://www.youtube.com/live/nxbSLFv2JAs --ignore-no-formats-error | ConvertFrom-Json
Output:
domain uploader status title
------ -------- ------ -----
youtube.com @AiraniIofifteen was_live Minecraft iofi / hololive
Because when it's fine when i don't use ConvertFrom-Json i don't think it's yt-dlp problem. I also tried using some alternative way to do it and it doesn't seem to meet bright light.
Then I found out that do this (put previous command inside parenthesis)
(yt-dlp.exe --print "{'domain': '%(webpage_url_domain)s', 'uploader': '%(uploader_id)s', 'status': '%(live_status)s', 'title': '%(title)s'}" https://www.youtube.com/live/nxbSLFv2JAs --ignore-no-formats-error)
Already throw Japanese characters and the【】
Output:
{'domain': 'youtube.com', 'uploader': '@AiraniIofifteen', 'status': 'was_live',
'title': ' Minecraft iofi / hololive '}
I have searched many solution regarding this matter but nothing solved this problem.
Stuff like chcp, $OutputEncoding, [System.Console]::OutputEncoding, [System.Console]::InputEncoding, [System.Text.Encoding]::UTF8. Didn't solve my problem. Or maybe because i don't really understand these things so i can't solve my problem.
I almost certain this question is a duplicate question, but the thing is I am not familiar with this stuff and so i don't know what to search to solve this specific problem.
Few stuff I've tried:
$OutputEncoding = [System.Console]::OutputEncoding = [System.Console]::InputEncoding = [System.Text.Encoding]::UTF8
$PSDefaultParameterValues['*:Encoding'] = 'utf8'
$OutputEncoding = [Console]::OutputEncoding = [Console]::InputEncoding = (new-object System.Text.UTF8Encoding $false)
I also tried some other solution but i don't include it here because almost no way those solution will fix this problem