Page 48 of 57
Posted: Wed Nov 28, 2007 11:20 am
by Teknojnky
actually, to prevent confusion, scrobblerdj uses function URLEncode, whereas genrefinder uses fixurl (appears to be the same type of function? but different name.
Its not a drop in replacement either, due to variable naming differences.
Posted: Wed Nov 28, 2007 11:48 am
by Teknojnky
here is what appears to be working for me, a drop in replacement of the urlencode scrobblerdj function, along with the required other functions from trix's genrefinder and other scripts.
If there is a problem posting this, feel free to let me know and I will remove it, or mods can.
Code: Select all
Public Function URLEncode(sRawURL)
logme "* URLEncode has started with parameters " & sRawURL
Dim iLoop, sRtn, sTmp
Const sValidChars = "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\/&:"
Dim url : url = Replace(sRawURL,"+","%2B")
If UCase(Right(url,6)) = " (THE)" Then
url = "The "&Left(url,Len(url)-6)
End If
If UCase(Right(url,5)) = ", THE" Then
url = "The "&Left(url,Len(url)-5)
End If
If Len(url) > 0 Then
Dim i : i = 1
Do While i < Len(url)+1
Dim s : s = Mid(url,i,1)
If InStr(1,sValidChars,s,0) = 0 Then
Dim d : d = Asc(s)
If d = 32 Or d > 2047 Then
s = "+"
Else
If d < 128 Then
s = DecToHex(d)
Else
s = DecToUtf(d)
End If
End If
Else
Select Case s
Case "&"
s = "%2526"
Case "/"
s = "%252F"
Case "\"
s = "%5C"
Case ":"
s = "%3A"
End Select
End If
URLEncode = URLEncode&s
i = i + 1
SDB.ProcessMessages
Loop
End If
logme "* URLEncode will return " & sRtn & " and exit"
End Function
Function HexToDec(h)
HexToDec = 0
Dim i : i = 0
For i = Len(h) To 1 Step -1
Dim d : d = Mid(h,i,1)
d = Instr("0123456789ABCDEF",UCase(d))-1
If d >= 0 Then
HexToDec = HexToDec+(d*(16^(Len(h)-i)))
Else
HexToDec = 0
Exit For
End If
Next
End Function
Function DecToBin(intDec)
DecToBin = ""
Dim d : d = intDec
Dim e : e = 1024
While e >= 1
If d >= e Then
d = d - e
DecToBin = DecToBin&"1"
Else
DecToBin = DecToBin&"0"
End If
e = e / 2
Wend
End Function
Function BinToHex(strBin)
Dim d : d = 0
Dim i : i = 0
For i = Len(strBin) To 1 Step -1
Select Case Mid(strBin,i,1)
Case "0"
'do nothing
Case "1"
d = d + (2^(Len(strBin)-i))
Case Else
BinToHex = "00"
Exit Function
End Select
Next
BinToHex = DecToHex(d)
End Function
Function DecToHex(d)
If d < 16 Then
DecToHex = "0%"&CStr(Hex(d))
Else
DecToHex = "%"&CStr(Hex(d))
End If
End Function
Function DecToUtf(d)
Dim b : b = DecToBin(d)
Dim a : a = "110"&Left(b,5)
b = "10"&Mid(b,6)
DecToUtf = "%"&BinToHex(a)&"%"&BinToHex(b)
End Function
Posted: Wed Nov 28, 2007 12:17 pm
by trixmoto
Sorry, I assumed I kept his function name when I copied it!
It is of course fine to post my code tidied up to fit in with this script. Giving back to the script that taught me how it's done!

Posted: Tue Dec 11, 2007 4:11 pm
by Guest
what version of media monkey do you need for this script? does it support the latest?
Posted: Tue Dec 11, 2007 4:33 pm
by nohitter151
I believe it only supports MM2.5 at this point, and does not work with MM3.
Working version in MM3!
Posted: Wed Dec 12, 2007 6:43 am
by dressen
Hi everyone,
This is one my favorite scripts and I had to see it working in MM3. I'm pleased to say I've gotten it working (first real MM scripting I've done).
Here is a link to a working version of ScrobblerDJ.vbs for MM3:
http://www.mediafire.com/?bnbu3ythf0j
Install ScrobblerDj as normal, then overwrite ScrobblerDJ.vbs with this version and it should work.
This version is not backwards compatible and will not work with MM2.x.
I've placed the comment "MM3 " wherever I made a change.
Enjoy!
Posted: Thu Dec 13, 2007 8:05 am
by Kingmob
Great script!
I have a problem though, it seems to get stuck in a 'loop' for certain types of music. For instance, i have a lot of REM and U2 albums, with lots of top rated songs and it will alternate between the two artists indefinitely. In short, the "no same artist" option does not seem to work for me?
Posted: Thu Dec 13, 2007 11:27 am
by Teknojnky
the no same artist does not apply to the default playlist, if your default playlist includes alot of rem and u2, then you will hear alot of rem and u2.
try changing or modifying your default playlist to something that has not been played in a longer time or not played at all.
no related artist found (!?)
Posted: Thu Dec 13, 2007 7:11 pm
by ReVe
Hi,
First off, my thanks to psyXonova and Peke for this script. I really like it a lot! It feels like the musical equivalent of letting your mind wander; skipping from this idea to that, oftentimes pleasantly surprised by unexpected trains of thought, or memories you had half forgotten.
I have however noticed something strange. SDJ will sometimes say that it is unable to find a similar artist, and will play a song from the default playlist, while a quick check on Last.fm shows that there are plenty of similar artists that I have available (with high enough similarity; not having been played recently; high enough rating). This isn’t such a big problem (if you create/select a good default playlist, you’ll hardly notice anything), but a bit strange nonetheless.
Looking at the debug log and the code, I think I have an idea of what’s going wrong. The logs I made seemed to indicate that SDJ reverts to a song from the default playlist every time it finds an artist that has already recently been played.
I have virtually no experience in programming, so I don’t know what everything means exactly, but I think there’s probably something not right in this next part of the ScrobblerDJ.vbs code:
Code: Select all
Do
RNumber = Int(XDict.Count * Rnd)
logme "ParseXML will now call NotTooSoon with parameters " & XDict.Item(RNumber)
If Not NotTooSoon(XDict.Item(RNumber)) Then
ParseXML = "E2"
logme "** NotTooSoon was False. ParseXML will return E2 and Exit"
Exit Do
End If
logme "ParseXML will now call sub CheckExist with parameters " & XDict.Item(RNumber) & ", 0, " & out_type
res = CheckExist(XDict.Item(RNumber), 0, out_type)
logme "CheckExist returned " & res & " to ParseXML"
If res <> 0 Then
ParseXML = res & "|§|§|§" & XDict.Item(RNumber)
logme "** ParseXML will return " & ParseXML
Exit Do
End If
If i = n Then
logme "** ParseXML tried too many times (" & i & "). It will return E2 code and exit"
ParseXML = "E2"
Exit Do
End If
i = i + 1
TimerLoop = 0
SDB.ProcessMessages
Loop
If I understand it correctly, this is a loop that tries different artists from a Last.fm related artists list to see if they haven’t been played recently (NotTooSoon) and if you have them on your computer (CheckExist). However, when it finds an artist that has been played recently (so that NotTooSoon fails) then it exits the loop, instead of trying again with a new artist (until the counter (i) has reached a max (n)).
Changing the above code to the following (combining two If-Thens into a single new one) seems to actually solve this problem for me, while not producing any errors (at least so far).
Code: Select all
Do
RNumber = Int(XDict.Count * Rnd)
logme "ParseXML will now call NotTooSoon with parameters " & XDict.Item(RNumber)
logme "ParseXML will now call sub CheckExist with parameters " & XDict.Item(RNumber) & ", 0, " & out_type
res = CheckExist(XDict.Item(RNumber), 0, out_type)
logme "CheckExist returned " & res & " to ParseXML"
If NotTooSoon(XDict.Item(RNumber)) And res <> 0 Then
ParseXML = res & "|§|§|§" & XDict.Item(RNumber)
logme "** ParseXML will return " & ParseXML
Exit Do
End If
If i = n Then
logme "** ParseXML tried too many times (" & i & "). It will return E2 code and exit"
ParseXML = "E2"
Exit Do
End If
i = i + 1
TimerLoop = 0
SDB.ProcessMessages
Loop
Again, I don’t really know what I’m doing, so if I’ve completely misunderstood the script, or if this change will cause problems, or if there’s a better solution, please let me know. Also, I wasn’t able to find any posts in this discussion topic describing similar problems, so it might just have been a problem with my setup (I use the latest official SDJ 1.26 with MM 2.5.5.998). Then again, this might be useful for some, so I decided to share it with you anyway. Sorry about the long post, though.
scrobler - mixed mode
Posted: Thu Dec 13, 2007 9:47 pm
by riffcat
would it be possible to make the script operate in a "mixed" mode? By "mixed" mode i mean by - instead of the the script adding a recommended track when the last song is being played. Have the script add a recommended song "play next" at preset intervals. like every other song or every 5 songs. This way one could play a selected playlist and have it mixed up a bit yet still keeping to the general mood of the play list.
I really like this script but sometimes I feel it tends to extremely detour from my general mood of listening. If it added a recommended track at certain intervals then the playlist "mood" would still stay "on-track"
Re: Working version in MM3!
Posted: Thu Dec 13, 2007 11:11 pm
by drjboulder
dressen wrote:Hi everyone,
This is one my favorite scripts and I had to see it working in MM3. I'm pleased to say I've gotten it working (first real MM scripting I've done).
Here is a link to a working version of ScrobblerDJ.vbs for MM3:
http://www.mediafire.com/?bnbu3ythf0j
Install ScrobblerDj as normal, then overwrite ScrobblerDJ.vbs with this version and it should work.
Dressen you are my hero!!!
I put off upgrading to MM3 as long as possible solely because of lack of Scrobbler DJ. To now have it back has perfected the Monkey!
Cheers also to the original developer, psyXonova; his inspiration for the script, Trixmoto; Peke & Abrazor for their help and anyone else who contributed to one of the best ever scripts for the monkey
Posted: Fri Dec 14, 2007 12:02 am
by Peke
@riffcat
Both Things are very very possible.
@ReVe
Good point. SDJ needs little tiding. There is several important adds in MM3 that makes SDJs job little easier and less demanding.
Posted: Fri Dec 14, 2007 2:50 am
by Diabolic-Destiny
dressen so far your script has worked flawlessly for me nice work
Re: scrobler - mixed mode
Posted: Fri Dec 14, 2007 10:31 am
by Teknojnky
riffcat wrote:I really like this script but sometimes I feel it tends to extremely detour from my general mood of listening. If it added a recommended track at certain intervals then the playlist "mood" would still stay "on-track"
Did you try making the 'default' playlist more tailored to your mood?
Posted: Fri Dec 14, 2007 10:36 am
by Teknojnky
@ Reve, Yes I think you found a very old and overlooked bug. That always bothered the crap out of me when it says it couldn't find a track when I know I had something that should have been usable (my library is huge).
I had tried to comb thru the code at various times to try to figure out and better optimize it, but I never did figure out how.
Your explaination and understanding seem to make sense, I will try out your modification to see if it improves things for me as well.
There is/was also a problem with the urlencode, a fix which is posted a few posts ago, you should also check that out if you have problems with artists/tracks with non-ansi characters.
Cheers!