Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: JScript Panel 2.0 and Powershell to extract cover art from youtube or audio file (Read 2643 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

JScript Panel 2.0 and Powershell to extract cover art from youtube or audio file

hi
i there an easier way to download coverart from youtube or extract from audio files to another folder while playing?
maybe someone know how to do that powershell thin in the panel script?

i am using this plugins...
https://github.com/marc2k3/foo_jscript_panel
https://fy.3dyd.com/download/
http://skipyrich.com/wiki/Foobar2000:Now_Playing_Simple
https://github.com/farpenoodle/FB2KNowPlayingOverlay

this is my panel script it triggers a powershell script which is placed in the root of  FB2KNowPlayingOverlay
Code: [Select]
function on_playback_new_track(metadb) {
WSH = new ActiveXObject("WScript.Shell");
var path = fb.TitleFormat("%path%").Eval(true)
fb.Pause()
WSH.run("powershell.exe -ExecutionPolicy ByPass -f D:\\OBS\\plugins\\nowplaying0.1\\reader.ps1 \"" + path + "\"",0,true);
fb.play()
}

reader.ps1 powershell script
Code: [Select]
$ErrorActionPreference = 'SilentlyContinue'
Import-Module BitsTransfer
Push-Location $PSScriptRoot
if ($args.count -gt 0) {
remove-item "$PSScriptRoot\images\1.jpg" -force
$path = $args[0]
if ($path -like "*youtube*") {
$ytID = $path.split("=")[1]
$output = "$PSScriptRoot\images\1.jpg"
$checkURL = try {Invoke-WebRequest -Uri "https://img.youtube.com/vi/$ytID/maxresdefault.jpg" -Method 'HEAD'} catch {$false}
if ($checkURL) {
$url = "https://img.youtube.com/vi/$ytID/maxresdefault.jpg"
} else {
$url = "https://img.youtube.com/vi/$ytID/hqdefault.jpg"
}
Start-BitsTransfer -Source $url -Destination $output
} else {
.\ffmpeg.exe -hide_banner -loglevel panic -i $path -c:v copy "$PSScriptRoot\images\1.jpg" -y
}
}
Pop-Location

also tried this solution https://sometings.wordpress.com/2016/11/17/executing-powershell-encoded-within-a-vbscript/
but not tested much because jpanal crashed everytime :/

kind regards
beth

Re: JScript Panel 2.0 and Powershell to extract cover art from youtube or audio file

Reply #1
2.0 is still in beta which might explain the crashes. Did you try 1.3.3.2?

 

Re: JScript Panel 2.0 and Powershell to extract cover art from youtube or audio file

Reply #2
it works but its a bit slow. i am not familar with vbs (wsh).
ihe solution in the last link is a bit strange because you translate the wohle code in a short string and execute it with powershell.exe. i dont know if this works in fb2k wsh :-)
my intention to post my code was maybe someone had an idea to do this in wsh without powershell or somebody know another method to extract the coverart while playing to another folder that the OBS plugin cann grab it an show it in my stream :-)

Re: JScript Panel 2.0 and Powershell to extract cover art from youtube or audio file

Reply #3
You'll never be able to do it in raw javascript which is what JScript/WSHPanel uses. There might be a method without powershell, but I don't know what it is.