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: foo_run and dynamic track titles (Read 3586 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

foo_run and dynamic track titles

I'm using foo_run and this command which works well for normal mp3 files. It opens my browser and expands %artist% and %title% variables correctly.
Code: [Select]
http://www.lastfm.de/music/$replace(%artist%, ,+)/_/$replace(%title%, ,+)

But it's not working for online radio streams with dynamic track titles  (option under networking is enabled) because foo_run (and most other 3rd plugins) haven't implemented support for dynamic track titles.
The plugin just uses the radio URL instead of the artist and title. So far I only know Columns_UI and Panels_UI who support dynamic track titles.

Back in 2007 foo_run's developer foosion explained that it is too difficult to add support for dynamic track titles in plugins.
Maybe something has changed in this regards since 2007?

Is there any work-around for opening last.fm with %artist% and %title% grabbed from a dynamic source?

 

foo_run and dynamic track titles

Reply #1
foo_run is developed by Florian. 

also, i think you've misinterpreted foosion's reply in that thread.

Quote
All components have access to these fields. It just depends on how they use the foobar2000 SDK. If they are not made to show dynamic tags, they won't.


Quote
It's just as difficult (or easy) as reacting to normal playback events. If any developer has questions regarding the technical details, they should post in the development forum.


bold emphasis is mine.

as we haven't seen Florian around for quite some time, it's unlikely foo_run will be updated - but assuming you don't mind using buttons, i've made a script for WSH panel mod that can launch various websites using dynamic track titles. it looks like this...



the script is named web links inside this package. check the readme first. https://dl.dropboxusercontent.com/u/22801321/wsh/samples.zip


foo_run and dynamic track titles

Reply #2
Looks promising. One more question:

With foo_run I use something like
Code: [Select]
"D:\Audio Tools\MP3 Tag\Mp3tag.exe" "$directory_path(%path%)"

to open local software from within foobar

Can I do this with WSH panel mod too? So I can trash foo_run completely.
I only found "Add support to run main menu and context menu command." in the wiki.
But this would mean, I have to use foo_run and WSH panel mod simultaneously.

foo_run and dynamic track titles

Reply #3
yup, that's certainly possible. rather than explain how to create it from scratch, here's how to extend the web links script i posted. on line 12, replace the entire b.update function with this....

Code: [Select]
b.update = function() {
    if (!p.metadb) return;
    var artist = encodeURIComponent(p.eval("%artist%"));
    var title = encodeURIComponent(p.eval("%title%"));
    var mp3tag = p.eval("\"D:\\Audio Tools\\MP3 Tag\\Mp3tag.exe\" \"$directory_path(%path%)\"");
    var google = "https://www.google.co.uk/search?q=" + artist;
    var myspace = "http://www.myspace.com/search/music?q=" + artist;
    var lastfm = "http://www.last.fm/music/" + artist + "/_/" + title;
    var youtube = "http://www.youtube.com/results?search_query=" + artist + "+" + title;
    var discogs = "http://www.discogs.com/search?q=" + artist;
    var allmusic = "http://www.allmusic.com/search/artists/" + artist;
    b.buttons = {
        google: new button(0, 0, 32, 32, {normal: "google.png", hover: "google_h.png"}, function() { p.browser(google); }, google),
        myspace: new button(32, 0, 32, 32, {normal: "myspace.png", hover: "myspace_h.png"}, function() { p.browser(myspace); }, myspace),
        lastfm: new button(64, 0, 32, 32, {normal: "lastfm.png", hover: "lastfm_h.png"}, function() { p.browser(lastfm); }, lastfm),
        youtube: new button(96, 0, 32, 32, {normal: "youtube.png", hover: "youtube_h.png"}, function() { p.browser(youtube); }, youtube),
        discogs: new button(128, 0, 32, 32, {normal: "discogs.png", hover: "discogs_h.png"}, function() { p.browser(discogs); }, discogs),
        allmusic: new button(160, 0, 32, 32, {normal: "allmusic.png", hover: "allmusic_h.png"}, function() { p.browser(allmusic); }, allmusic),
        mp3tag: new button(192, 0, 32, 32, {normal: "mp3tag.png", hover: "mp3tag_h.png"}, function() { p.run(mp3tag); }, "Mp3Tag")
    }
    window.Repaint();
}

obviously this needs the images creating and saved inside your foobar profile\marc2003\images folder. the filenames are in the 2nd to last line of code. one is a standard image and the other is the hover image - what you see when your mouse is over the button. this hover image is optional. if you want to just use the one image, the line of code can be re-written like this....

Code: [Select]
mp3tag: new button(192, 0, 32, 32, {normal: "mp3tag.png"}, function() { p.run(mp3tag); }, "Mp3Tag")

also, just to explain how that function is constructed:

the first number, 192, is the x co-ordinate in pixels from the top left. note how each button increments by 32 as that is my button size
the second number 0 is the y co-ordinate
the 3rd and 4th are the button width/height
the next argument is the image to use. as mentioned above, it's expected to be inside the marc2003\images folder.
next is the function to run when the button is clicked.
last is the tooltip that gets displayed when you hover your mouse over the button.

if you want to add/remove buttons, notice how each one is separated with a comma at the end of the line of code.

foo_run and dynamic track titles

Reply #4
Hey marc,

I got everything I need, thank you very much.
This is my own "b.update" function. The escaping was driving me crazy \(ಠ ὡ ಠ )/

Code: [Select]
b.update = function() {
    if (!p.metadb) return;
    var artist = encodeURIComponent(p.eval("%artist%"));
    var title = encodeURIComponent(p.eval("%title%"));    
    var lastfm = "http://www.lastfm.de/music/" + artist + "/_/" + title;            
    var google = "http://www.google.de/search?tbm=isch&biw=1766&bih=871&q=" + artist + "+" + title + "+Cover";
    var albumcover = p.eval("\"Powershell\" \"-File\" \"FoobarScripts\\exiftool.ps1\" \"%path%\" \"%filename%\"");
    var mrtzcmp3 = "http://www.mrtzcmp3.net/" + artist + "_" + title + "_1s.html"    
    var mp3tag = p.eval("'\"..\\..\\Audio Tools\\MP3 Tag [Portable]\\Mp3tag.exe\"' \"$directory_path(%path%)\"");          
    var audacity = p.eval("'\"..\\..\\Audio Tools\\Audacity [Portable]\\AudacityPortable.exe\"' \"%path%\"");
    var mp3gain = p.eval("\"FoobarScripts\\mp3gain\\mp3gain.cmd\" \"%path%\"");    
    var streamripper = p.eval("\"FoobarScripts\\streamripper\\streamripper.exe\" \"%path%\" \"-r\" \"-z\" \"-u\" \"-d 2.0\" \"FreeAmp/2.x\" \"-d\" \"C:\\Users\\nixdagibts\\Desktop\"");    
    
    b.buttons = {
        lastfm: new button(0, 0, 32, 32, {normal: "lastfm.png", hover: "lastfm_h.png"}, function() { p.browser(lastfm); }, "Lastfm"),
        google: new button(32, 0, 32, 32, {normal: "google.png", hover: "google_h.png"}, function() { p.browser(google); }, "Google"),
        albumcover: new button(64, 0, 32, 32, {normal: "albumcover.png", hover: "albumcover_h.png"}, function() { p.run(albumcover); }, "AlbumCover"),
        mrtzcmp3: new button(96, 0, 32, 32, {normal: "mrtzcmp3.png", hover: "mrtzcmp3_h.png"}, function() { p.browser(mrtzcmp3); }, "mrtzcmp3"),
        mp3tag: new button(128, 0, 32, 32, {normal: "mp3tag.png", hover: "mp3tag_h.png"}, function() { p.run(mp3tag); }, "Mp3Tag"),        
        audacity: new button(160, 0, 32, 32, {normal: "audacity.png", hover: "audacity_h.png"}, function() { p.run(audacity); }, "Audacity"),
        mp3gain: new button(192, 0, 32, 32, {normal: "mp3gain.png", hover: "mp3gain_h.png"}, function() { p.run(mp3gain); }, "mp3gain"),    
        streamripper: new button(224, 0, 32, 32, {normal: "streamripper.png", hover: "streamripper_h.png"}, function() { p.run(streamripper); }, "Streamripper")        
    }
    window.Repaint();
}



function albumcover: calls a Powershell script which uses exiftool to extract the embedded album cover. After that, it takes the resulting png and uploads it to Google images to search for similar images.
function mrtzcmp3: calls a website with the current selected artist and title and does bad things
function mp3tag: opens mp3tag for extensive tag editing (rarely used since masstager scripts can do most of this too), uses relative pathes. As a bonus, it looks for the directory of the currently selected song and open the whole folder in mp3tag
function audacity: opens audacity for music editing with the current selected track using mp3gain from commandline
function mp3gain: opens the following CMD script which normalizes the current selected track to 91 dB
Code: [Select]
@ECHO OFF
FoobarScripts\mp3gain\mp3gain.exe /r /p /s s %1
FoobarScripts\mp3gain\mp3gain.exe /g 2 /p /s s %1

function streamripper: ripps a playing online radio (automatic downloading, renaming+ tagging of files)