It looks possible using the OnTrackAdded event. Here's a rough version of the script that seems to be working.
Code: Select all
'
' MediaMonkey Script
'
' NAME: Growl for Windows Notification v1.4b
'
' AUTHOR: eriqjaffe, although 95% of this script is taken verbatim from "Now Playing FTP" by trixmoto (http://trixmoto.net)
' DATE : 12/01/09
'
Option Explicit
Sub OnStartup
Call Script.RegisterEvent(SDB,"OnPlay","Event_OnPlay")
Call Script.RegisterEvent(SDB,"OnStop","Event_OnStop")
Call Script.RegisterEvent(SDB,"OnShutdown","Event_OnShutdown")
Call Script.RegisterEvent(SDB,"OnPause","Event_OnPause")
Call Script.RegisterEvent(SDB,"OnTrackAdded","PodcastCheck")
End Sub
Sub Event_OnPlay()
Call SendInfo(0)
End Sub
Sub Event_OnStop()
Call SendInfo(1)
End Sub
Sub Event_OnShutdown()
Call SendInfo(2)
End Sub
Sub Event_OnPause()
Call SendInfo(3)
End Sub
' Sub Event_OnTrackAdded()
' Call PodcastCheck()
' End Sub
Sub SendInfo(mode)
Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
Dim wsh : Set wsh = CreateObject("WScript.Shell")
If mode = 0 Then
'get current song
Dim cur : Set cur = SDB.Player.CurrentSong
If cur Is Nothing Then
Exit Sub
End If
'get settings
Dim site : site = ""
Dim user : user = ""
Dim pass : pass = ""
Dim path : path = ""
Dim arti : arti = ""
Dim albu : albu = ""
Dim year : year = ""
Dim name : name = ""
Dim secs : secs = ""
Dim genr : genr = ""
Dim dnum : dnum = ""
Dim tnum : tnum = ""
Dim artw : artw = ""
Dim recs : recs = ""
Dim aart : aart = ""
Dim rati : rati = ""
Dim temp : temp = ""
Dim arr
Dim tmp2 : tmp2 = ""
Dim rndm : rndm = ""
Dim cmd : cmd = ""
Dim foo : foo = wsh.ExpandEnvironmentStrings("%TEMP%")&"\cover_growl.jpg"
Dim bar : bar = wsh.ExpandEnvironmentStrings("%TEMP%")&"\cover_growl.png"
Dim loc : loc = SDB.ApplicationPath & "\scripts\auto"
'check songlength
Dim msec : msec = 0
If IsNumeric(secs) Then
msec = secs*1000
End If
If cur.SongLength < msec Then
Exit Sub
End If
'create file
If Not (cur Is Nothing) Then
name = cur.Title
arti = cur.ArtistName
albu = cur.AlbumName
year = cur.Year
genr = cur.Genre
dnum = cur.DiscNumberStr
tnum = cur.TrackOrderStr
aart = cur.AlbumArtistName
rati = cur.Rating
path = cur.Path
artw = GetAlbumArt(cur,0)
If HtmlEncode(Mid(artw,InStrRev(artw,"\")+1)) = "np.jpg" Then
temp = "embedded"
artw = wsh.ExpandEnvironmentStrings("%TEMP%")&"\np.jpg"
Else
arr = Split(path,"\")
temp = "linked"
dim y : y = Ubound(arr) - 1
dim x : for x = 0 to y
tmp2 = tmp2 + arr(x) + "\"
next
artw = tmp2&Mid(artw,InStrRev(artw,"\")+1)
End If
If fso.FileExists(artw) Then
fso.CopyFile artw,wsh.ExpandEnvironmentStrings("%TEMP%")&"\cover_growl.jpg"
bar = wsh.ExpandEnvironmentStrings("%TEMP%")&"\cover_growl.jpg"
'resizeImage foo,100,100,bar
Else
'fso.CopyFile wsh.ExpandEnvironmentStrings("%PROGRAMFILES%")&"\mediamonkey\scripts\auto\mm3.png",bar
fso.CopyFile loc&"\mm3.png",bar
End If
End If
'cmd = chr(34)&wsh.ExpandEnvironmentStrings("%PROGRAMFILES%")&"\mediamonkey\scripts\auto\growlnotify.exe"&chr(34)&" /t:"&chr(34)&"MediaMonkey"&chr(34)&" /i:"&chr(34)&bar&chr(34)&" "&chr(34)&arti&"\n"&"''"&name&"''\n"&albu&chr(34)
cmd = chr(34)&loc&"\growlnotify.exe"&chr(34)&" /t:"&chr(34)&"MediaMonkey"&chr(34)&" /i:"&chr(34)&bar&chr(34)&" "&chr(34)&arti&"\n"&"''"&name&"''\n"&albu&chr(34)
wsh.Run cmd,2,0
set wsh = Nothing
end if
End Sub
Sub PodcastCheck(track)
Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
Dim wsh : Set wsh = CreateObject("WScript.Shell")
Dim loc : loc = SDB.ApplicationPath & "\scripts\auto"
Dim cmd : cmd = ""
if InStr(UCase(track.Genre),"PODCAST") > 0 Then
cmd = chr(34)&loc&"\growlnotify.exe"&chr(34)&" /t:"&chr(34)&"MediaMonkey"&chr(34)&" /i:"&chr(34)&loc&"\mm3.png"&chr(34)&" "&chr(34)&track.Title&"\nHas been downloaded"&chr(34)
wsh.Run cmd,2,0
set wsh = Nothing
end if
End Sub
Function GetAlbumArt(track,num)
GetAlbumArt = Replace(Script.ScriptPath,"chromeoutput.vbs","default.jpg")
Dim fso : Set fso = SDB.Tools.FileSystem
Dim wsh : Set wsh = CreateObject("WScript.Shell")
Dim str : str = "\np.jpg"
If num > 0 Then
str = "\np"&num&".jpg"
End If
Dim temp : temp = wsh.ExpandEnvironmentStrings("%TEMP%")&str
Dim pics : Set pics = track.AlbumArt
If Not (pics Is Nothing) Then
Dim i : i = 0
For i = 0 To pics.Count-1
If (pics.Item(i).ItemStorage = 0) Or (num > 0) Then
Dim img : Set img = pics.Item(i).Image
If Not (img Is Nothing) Then
Dim outimg : Set outimg = fso.CreateTextFile(temp,True)
If Not (outimg Is Nothing) Then
Call outimg.WriteData(img.ImageData,img.ImageDataLen)
outimg.Close
GetAlbumArt = temp
Exit Function
End If
End If
Else
GetAlbumArt = pics.Item(i).PicturePath
Exit Function
End If
Next
End If
End Function
Function HtmlEncode(str)
HtmlEncode = SDB.toAscii(str)
HtmlEncode = Replace(HtmlEncode,"&","&")
HtmlEncode = Replace(HtmlEncode,"""",""")
HtmlEncode = Replace(HtmlEncode,"<","<")
HtmlEncode = Replace(HtmlEncode,">",">")
End Function
I can't get it to report anything other than the podcast's title, though. I thought I could just do track.Artist or track.Album as well, but that throws up an error.
Feel free to give this a try and see if you have any luck with it.