How do I get the 'AlbumArtist' property

Download and get help for different MediaMonkey for Windows 4 Addons.

Moderators: Peke, Gurus

Neil Sunderland
Posts: 2
Joined: Sun Aug 21, 2005 4:12 am
Location: Braunton, Devon

How do I get the 'AlbumArtist' property

Post by Neil Sunderland »

I've written the following script that writes the name, artist and album of the currently playing track to a text file; whenever I send an email that information is added to my .sig, and the recipient can then judge whether the music I'm listening to is affecting the tone of my message :)

Code: Select all

Sub Main()
Dim oFSO, oOutput, oTrack, oAlbum, sAlbumArtist

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oOutput = oFSO.CreateTextFile("CookieData.txt")

Set oTrack = SDB.Player.CurrentSong
Set oAlbum = oTrack.Album

'Need to get the AlbumArtist Property, not the Track Artist
AlbumArtist = oAlbum.Artist.Name

oOutput.Write "NP: " & oTrack.ArtistName & " - " & oTrack.Title
If (Instr(oTrack.AlbumName, "Best")=0 And Instr(oTrack.AlbumName, "Greatest")=0) Or _
    Instr(AlbumArtist, "Various")=0 Then
	oOutput.Write " (from the album " & Track.AlbumName & ")"
  End If

oOutput.Close()

Set oTrack = Nothing
Set oAlbum = Nothing
Set oOutput = Nothing
Set oFSO = Nothing

End Sub
I've set the AlbumArtist for multi-artist albums in my database to 'Various Artists'; I don't want to display the Album details for these, but I can't find the AlbumArtist property in the Online Help. The Album.Artist.Name is returning the Artist property for the track.

Am I missing something obvious?
tvjunky
Posts: 5
Joined: Sun Aug 21, 2005 12:58 pm

Post by tvjunky »

I think the property you're looking for is indeed "AlbumArtistName" from an "SDBSongData" object. I'm unable to find it in webhelp, however you can verify the property's existence in the downloadable .chm file.
To make your script work as intended (I just skimmed it) it is probably enough to change

Code: Select all

If (Instr(oTrack.AlbumName, "Best")=0 And Instr(oTrack.AlbumName, "Greatest")=0) Or _ 
    Instr(AlbumArtist, "Various")=0 Then 
   oOutput.Write " (from the album " & Track.AlbumName & ")" 
End If 
to

Code: Select all

If (Instr(oTrack.AlbumName, "Best")=0 And Instr(oTrack.AlbumName, "Greatest")=0) Or _ 
    Instr(oTrack.AlbumArtistName, "Various")=0 Then 
   oOutput.Write " (from the album " & Track.AlbumName & ")" 
End If 
hth, tvjunky
Neil Sunderland
Posts: 2
Joined: Sun Aug 21, 2005 4:12 am
Location: Braunton, Devon

How do I get the 'AlbumArtist' property

Post by Neil Sunderland »

That's perfect. Thank you!
milesy20

How are you adding this content to your email sig?

Post by milesy20 »

What email app are you using? Could you provide examples?

Thanks in advance!
kalex
Posts: 12
Joined: Fri Apr 14, 2006 2:27 pm
Location: Germany
Contact:

Post by kalex »

Please excuse the newbie question, this is exactly what I was looking for, but where do I put the script so that it automatically does its work when I play a song? Into the auto folder? Do I have to edit the script.ini as well?

[about the email app - I'm using "The Bat!" from Ritlabs, it has a template system for messages with a macro language that allows to include text files very easily, %INCLUDE("D:\nowplaying.txt") for example]

Thanks...
Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm

Post by Steegy »

Hi

The script has to be in MediaMonkey's "Scripts" folder, and you have to add an entry to the "Scripts.ini" file. See the example below:

Code: Select all

[SignatureWriter]
FileName=SignatureWriter.vbs
ProcName=Main
Order=1
DisplayName=SignatureWriter
Description=SignatureWriter
Language=VBScript
ScriptType=2
This supposes that you named the script text file "SignatureWriter.vbs".

BTW: ScriptType=2 means that the script will be launched each time a song starts playing.

More information: http://faq.mediamonkey.com/index.php?ac ... artlang=en

Cheers
Steegy
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
kalex
Posts: 12
Joined: Fri Apr 14, 2006 2:27 pm
Location: Germany
Contact:

Post by kalex »

Thanks, it works now. I got the RTFM hint. :-)

However (this question goes to the original script author), when I stop the song, or exit MM (though I have the feeling that is seldomly gonna happen, I start to rrrrreally like the program), the textfile remains. Seeing that there is no "stop" action in the scripts type, I wonder if its possible to delete the file when the song is stopped and/or MM is quit?
Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm

Post by Steegy »

Am I not good enough to answer your question??? :evil: :lol: :lol: :lol:

Anyway, the author hasn't been here in a long time, so maybe I can give an answer:

The script runs when a song starts playing, does it's work, and ends. The whole process shouldn't take more than a second. (i.e. creating/overwriting the text file and storing the song info in it).

That means that you can edit/delete/rename/... the text file always. *Except* at the moment when a song starts playing (and so the script runs). Then you'll have to wait a second for the script to finish.


Does the script work correctly? I mean, does it always contain one (or two) line(s) of text from the last played song?
If it doesn't, then change

Code: Select all

Set oOutput = oFSO.CreateTextFile("CookieData.txt")
to

Code: Select all

Set oOutput = oFSO.CreateTextFile("CookieData.txt", True)
The "True" makes sure that the file gets overwritten by a new version and so always contains the last played song.

Cheers
Steegy
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
kalex
Posts: 12
Joined: Fri Apr 14, 2006 2:27 pm
Location: Germany
Contact:

Post by kalex »

Steegy wrote:Am I not good enough to answer your question??? :evil: :lol: :lol: :lol:
Hehe. Don't worry - I just didn't want to bother you too much.

The problem is not that that the script will be locked, or something. I have to explain the details a little more, I think.

I've added some simply "code" into the templates of my email program. It checks for the existence of the "now playing" file. If its there, it is added below my signature to the message. If its NOT there, a random tagline ("cookie") is added, instead.

As it is now the file stays there for all eternity. Even if I wouldn't play a song with MM the whole month (which is hardly going to happen, but anyway), my email program would still show that I'm listening to... Ozzy Osbourne, or whatever, in an infinite loop. :)

So, what I'm looking for would be an additional functionality that deletes the created textfile (or empties its contents, either way) as soon as I press stop, or before I exit MM.

You see, thats why I didn't want to bother you too much with it! :wink:

A happy easter & thanks for the help you already provided.
Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm

Post by Steegy »

Happy easter too.

This is an improved version.

It has to be placed in MediaMonkey's Scripts\Auto folder, and you will have to remove the entry you previously made in the Scripts.ini file (you can remove the other script file in the Scripts folder too).

It will create a file NowPlayingSignature.txt in MediaMonkey's Scripts\Auto folder.
When playback stops, or you shut down MediaMonkey, the file will be deleted.

Code: Select all

Option Explicit

Dim oFSO
Set oFSO = CreateObject("Scripting.FileSystemObject")

Dim sSignatureFileName
sSignatureFileName = SDB.ApplicationPath & "Scripts\Auto\NowPlayingSignature.txt"


Sub OnStartUp

  Script.RegisterEvent SDB, "OnPlay", "WriteSignatureFile"
  Script.RegisterEvent SDB, "OnStop", "DeleteSignatureFile"
  Script.RegisterEvent SDB, "OnShutDown", "DeleteSignatureFile"
  
End Sub



Sub WriteSignatureFile

  On Error Resume Next

  Dim oSignatureFile, oTrack, sAlbumArtist
	
  Set oSignatureFile = oFSO.CreateTextFile(sSignatureFileName, True)
  Set oTrack = SDB.Player.CurrentSong
	
  oSignatureFile.Write "NP: " & oTrack.ArtistName & " - " & oTrack.Title
  If (Instr(oTrack.AlbumName, "Best")=0 And Instr(oTrack.AlbumName, "Greatest")=0) _
      Or Instr(oTrack.AlbumArtistName, "Various")=0 Then
    oSignatureFile.Write " (from the album " & oTrack.AlbumName & ")"
  End If
	
  oSignatureFile.Close()
	
End Sub



Sub DeleteSignatureFile

  On Error Resume Next
  
  oFSO.DeleteFile(sSignatureFileName)
  
End Sub
Cheers
Steegy
Last edited by Steegy on Sun May 14, 2006 2:57 pm, edited 1 time in total.
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
kalex
Posts: 12
Joined: Fri Apr 14, 2006 2:27 pm
Location: Germany
Contact:

Post by kalex »

Yeeehaa! Send me a PM with your address. This deserves some beer sent to you - awesome, man.

One minor glitch: I'm working with a limited user account - no administrative rights, no write access to the SDB.ApplicationPath directory. I changed it to my user profile path & everything is just fine.

Thanks a million, Steegy!
pepoluan
Posts: 17
Joined: Mon Jan 30, 2006 1:59 am
Location: Jakarta, Indonesia
Contact:

Error #438?

Post by pepoluan »

I got an error #438 - Microsoft VBScript runtime error
Object doesn't support this property or method: 'Script.RegisterEvent'
I am a Vorbis zealot.
Nobody is perfect. I am nobody.
Reading gives you knowledge. Knowledge is power. Power corrupts. Corruption is evil. Therefore, reading makes you evil.
I use ISO8601. How about you? Use this date format: Y-m-d H:iO
Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm

Post by Steegy »

You'll need a newer version of MediaMonkey, to be able to run this script (and many other scripts on this site). I think you need at least version 2.5.2

Cheers
Steegy
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
pepoluan
Posts: 17
Joined: Mon Jan 30, 2006 1:59 am
Location: Jakarta, Indonesia
Contact:

Post by pepoluan »

I *am* using the latest version :(
Or must I use the Gold (i.e. paid) version?

Edit: Whoa. On second check, I'm still using 2.5.1. I could've sworn I've installed 2.5.2 :-? Will try reinstalling 2.5.2

Edit2: Yup. That's the problem. Thanks for the wonderful script! Now I can wow my penpals *does a little dance of joy* :D
I am a Vorbis zealot.
Nobody is perfect. I am nobody.
Reading gives you knowledge. Knowledge is power. Power corrupts. Corruption is evil. Therefore, reading makes you evil.
I use ISO8601. How about you? Use this date format: Y-m-d H:iO
pepoluan
Posts: 17
Joined: Mon Jan 30, 2006 1:59 am
Location: Jakarta, Indonesia
Contact:

Error when changing properties

Post by pepoluan »

I experience error with this script installed:

When music is playing, I right-click and edit the property, click OK, an error pops up:
Error executing script event.

Click OK, and another error pops up:
Error executing script event.

But in the background, the music plays, but starts from the beginning.

Click OK, and the music resumes playing where it was before I edit the property.

Not fatal, but rather annoying.

FYI I am using MM 2.5.3.959 (beta)
I am a Vorbis zealot.
Nobody is perfect. I am nobody.
Reading gives you knowledge. Knowledge is power. Power corrupts. Corruption is evil. Therefore, reading makes you evil.
I use ISO8601. How about you? Use this date format: Y-m-d H:iO
Post Reply