MusicIP Mixer (MusicIP.com, similar to Last.fm)
#1
Lightbulb 
I'm not sure off hand about their licensing, but it would be cool to have the MusicIP Mixer plugin working for XBMC's music, where you select a song and based on some generated db of track info, it can generate a playlist "music like this".
I have the standalone player for the PC and and it's built into WinAMP (or is a plugin, I forget). I've seen requests for "smart" playlists, but I'm not sure if that's the same thing.
Reply
#2
Lightbulb 
Hi - I've been using the open source SwissCenter project for the ShowCenter 200, and they have a plugin that integrates MusicIP Mixer

It's pretty cool - basically profiles your music collection and can automatically construct play lists of similar tracks based on those profiles.

Has anyone looked at doing this for XBMC?
Reply
#3
Question 
Isn't XBMC's existing Last.FM feature similar to this?, ...in any case I am sure it could be nice to support both.

Please submit a feature request to trac for tracking purposes.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Reply
#4
Gamester17 Wrote:Isn't XBMC's existing Last.FM feature similar to this?,

In effect, it's similar, but the algo is very different. You also don't need a net connection for it to work.

I'll submit a trac anyway.
Reply
#5
Just looking at the trac and I, obviously, can't edit/comment on it on there but this got changed to Streaming and it's definitely not. There's a headless app you can run on your computer that will do all of the site identification and provide the playlists back to a program via their API without having to be connected to the internet.

The music itself is from your library - NOT streaming. That's what makes it so great.
Reply
#6
Smile 
MusicIP mixer works great!
I threw togheter a little script that uses the currently playing song to create a playlist.

Add the script to a remotekey or on your favourite dialog, and you've got a quick way of creating intelligent playlists. Big Grin

As you can see from the code, the port number for the MusicIP api is hardcoded to "1234", and the playlist size is "12". Change them as you feel.


Code:
# Import XBMC module
import xbmc,urllib,urllib2 , re, os
from string import split, replace, find

# Script constants
__scriptname__ = "Music MIX"

if xbmc.Player().isPlayingAudio() == False:
    self.close()

currentlyPlaying = xbmc.Player().getMusicInfoTag().getURL()
print currentlyPlaying
currentlyPlaying = currentlyPlaying.replace(":","%3A").replace(" ","+")

apiPath = 'http://localhost:1234/api/mix?song='
options = '&size=12&sizeType=tracks&content=text'

# The url in which to use
Base_URL = apiPath + currentlyPlaying + options
print Base_URL
#Pre-define global Lists
LinkURL = []

WebSock = urllib.urlopen(Base_URL)  # Opens a 'Socket' to URL
WebHTML = WebSock.read()            # Reads Contents of URL and saves to Variable
WebSock.close()                     # Closes connection to url


LinkURL = WebHTML.split("\n")
xbmc.PlayList(0).clear()
for l in LinkURL:
    if not l == "":
        xbmc.PlayList(0).add(l)
Reply
#7
I agree MusicIP is a great feature to integrate - and this script is a step forward to do that.

Unfortunately I can't get it to work under Ubuntu Jaunty. Would appreciate any help.

This is what I did:
* updated and saved the MusicIP library, and set the api.
* started mmserver at boot.
* confirmed it's operational by creating a playlist via api call using a web browser.
* adjusted your script localhost:XXXX entry to match my settings.
* set xbmc to run "musicip.py" script in 2 places: main menu and as a "lyrics" script (to see which one works).
* imported all music into the xbmc library.
* ran the script while a song was playing.

When I run the script, I get the following entry in my playlist: "MusicIP API error - invalid request or internal error."

I'm not sure how to debug this to work out where the error is being generated. I suspect it's the url location of the playing file.

I'd appreciate any help / debug tips.
Reply
#8
Your probably right about the url location being the culprit.
I'm not sure what Ubuntu paths look like. But I suggest you look in your xbmc.log.
The lines "print currentlyPlaying" and "print Base_URL
" in the script should be printing the path of the currently playing song to the log.
The latter, the complete url that's sent to the API.

You should check and see if the first path point to the correct song.
In windows I needed to do some replacing of this path to make it url freindly. Hence the "replace(":","%3A").replace(" ","+")
"

Hope this helps.
Reply
#9
Thanks for the script and debug support ErlendSB! All fixed now!

For others who experience the same problem - this was the issue... My music files are on an external/USB drive, which changes how the path appears in MusicIP for linux compared to how it appears in Ubuntu:

In Ubuntu (as shown in xbmc.log after the script failed)= /media/My Music/Album...
In MusicIP (as shown by viewing "song information" in MusicIP)= /media/My Music/./Album...

As suggested by ErlendSB, I simply amended the script to suit my system. In this case, the added "/./" in the file path for MusicIP. The line I amended is as follows:

currentlyPlaying = currentlyPlaying.replace("/My Music/","/My+Music/./").replace(" ","+")

I tested the need for the extra "/./" in the path by doing a direct call via web browser:
http:// localhost:XXXX/api/mix?song=/media/My+Music/./Album...&size=12&sizeType=tracks&content=text

(Where XXXX is my local api setting; and /Album... was the full path to the file I wanted to create a mix from).

For a while there I was afraid I'd have to move back to Windows to make use of MusicIP. This script, combined with XBMC, is better than the setup I had previously under Windows. And free I tells ya...
Reply
#10
Big Grin 
And it works - using the "install from zip" under program addons.

https://gavdocs.s3.amazonaws.com/xbmcmusicip_dharma.zip

It's your script EriendSB, someone who knows how should extend it to give it a nice config interface Big Grin and then go through the rigamarole of a submission to the addons repo...

Meanwhile, this zip "works". It expects musicip server running on localhost and at port 10002 (the default as installed, I think).

Cheers,

G
Reply
#11
Gamester17 Wrote:Isn't XBMC's existing Last.FM feature similar to this?, ...in any case I am sure it could be nice to support both.

I have been using an itunes / winamp alternative call MusicBee (Windows only) for some time now that has an AutoDJ feature that can use either Last.fm or a local install MusicIP to generate auto playlist. I assumed that xbmc's party mode would include something like this, but it purely file / tag property filtering only. Musicbee has a nice feature where the AutoDJ can add new tracks only based on the seed track, or add new tracks always based on the currently playing track to allow for drift.

As far as I understand, xbmc's current Last.fm implementation only supports using tracks served up by Last.fm. MusicBee's implementation uses Last.fm to find other similar artists to the currently playing track that are within you local library. Please see the attached image for the range of options that Musicbee provides in AutoDJ.
Image

It would be awesome to build this functionality into the Party mode of xbmc. Of course I'm not a developer, so please only take these as suggestions for someone who wants to take up such a project. The developer of MusicBee is highly responsive and I'm sure would be glad to provide advice on implementing these features in xbmc.
Reply
#12
Has anyone this script working on Frodo or a similar addon?
I´m running XBMC on Linux (Ubuntu) and mmserver is running on the right default 10002 Port.
Reply
#13
(2009-08-15, 12:59)ErlendSB Wrote: MusicIP mixer works great!
I threw togheter a little script that uses the currently playing song to create a playlist.

Add the script to a remotekey or on your favourite dialog, and you've got a quick way of creating intelligent playlists. Big Grin

As you can see from the code, the port number for the MusicIP api is hardcoded to "1234", and the playlist size is "12". Change them as you feel.


Code:
# Import XBMC module
import xbmc,urllib,urllib2 , re, os
from string import split, replace, find

# Script constants
__scriptname__ = "Music MIX"

if xbmc.Player().isPlayingAudio() == False:
    self.close()

currentlyPlaying = xbmc.Player().getMusicInfoTag().getURL()
print currentlyPlaying
currentlyPlaying = currentlyPlaying.replace(":","%3A").replace(" ","+")

apiPath = 'http://localhost:1234/api/mix?song='
options = '&size=12&sizeType=tracks&content=text'

# The url in which to use
Base_URL = apiPath + currentlyPlaying + options
print Base_URL
#Pre-define global Lists
LinkURL = []

WebSock = urllib.urlopen(Base_URL)  # Opens a 'Socket' to URL
WebHTML = WebSock.read()            # Reads Contents of URL and saves to Variable
WebSock.close()                     # Closes connection to url


LinkURL = WebHTML.split("\n")
xbmc.PlayList(0).clear()
for l in LinkURL:
    if not l == "":
        xbmc.PlayList(0).add(l)

I've been using this script for ages but found it was behaving a bit oddly since Kodi arrived. Simply put, if I was playing track 7 of an album and generated a musicIP mix from that track, the script would correctly generate a mix but only play it from track 8. I've fixed that and I've also altered the script so it copes with URL unsafe characters (", &, + etc.) in music paths and so it pops up a notification to give the user some feedback that a mix has been generated.

This is my first delve into the python XBMC API, it would be cool to turn it into an addon - but I've no idea how to do that. Also, I've been using this for a few days and have tested the various edge scenarios I can think of and the script behaves fine, but there may still be bugs in it. I'm open to suggestions Smile

PS - the notification includes a high res musicIP icon that I can't attach to this post, so I've uploaded it to a random image hosting website here. The script will need pointing to wherever you put this (edit the last line).

Code:
# Import XBMC module
import xbmc,urllib,urllib2 , re, os
from string import split, replace, find


# Script constants
__scriptname__ = "Music MIX"

if xbmc.Player().isPlayingAudio() == False:
    self.close()

currentlyPlaying = xbmc.Player().getMusicInfoTag().getURL()
currentlyPlaying = urllib.quote_plus(currentlyPlaying)


tag = xbmc.Player().getMusicInfoTag()
artist = tag.getArtist()
title = tag.getTitle()

size=str(25)
apiPath = 'http://localhost:10002/api/mix?song='
options = '&size='+size+'&sizeType=tracks&content=text'

# The url in which to use
Base_URL = apiPath + currentlyPlaying + options
#Pre-define global Lists
LinkURL = []

WebSock = urllib.urlopen(Base_URL)  # Opens a 'Socket' to URL
WebHTML = WebSock.read()            # Reads Contents of URL and saves to Variable
WebSock.close()                     # Closes connection to url


LinkURL = WebHTML.split("\n")
playList = xbmc.PlayList(0)
currentPos = playList.getposition()
if playList.size()>1 and currentPos < playList.size()-1: #Since Kodi playlist clear would leave the new play list playing at oldplaylist.position, this code fixes that
        for i in range (currentPos+1, playList.size()):
                playList.remove(playList[currentPos+1].getfilename())

first = True #first item returned from musicIP is the item currently playing, so don't add that to playlist.

for l in LinkURL:
    if not l == "":
                if not (first):
                        playList.add(url=l)
                first=False
xbmc.executebuiltin('Notification(Playlist Generated,'+size +' songs like the current coming up...,5000,d:\scripts\musicip.png)')
Reply
#14
OMG, I competely forgot about that script and I miss MusicIP MIxer so much. This is a godsend and I will try it asap. Thanks a million for sharing.
Reply
#15
Bug 
I've fixed a problem with the script. It used to fall over on special Latin characters in file names/paths (Björk, for example). It now encodes the ö and other characters properly so that the MusicIP web interface understands them. It doesn't support non-Latin characters though, so no Japanese or Cyrillic etc. - this is a limitation of the MusicIP web interface so I don't think there's anything that can be done about it.

Code:
# Import XBMC module
import xbmc,re, os, urllib
from string import split, replace, find
from urllib2 import quote
# Script constants
__scriptname__ = "Music MIX"

if xbmc.Player().isPlayingAudio() == False:
    self.close()

currentlyPlaying = unicode(xbmc.Player().getMusicInfoTag().getURL(),'utf-8')

tag = xbmc.Player().getMusicInfoTag()
artist = tag.getArtist()
title = tag.getTitle()

size=str(25)
apiPath = 'http://localhost:10002/api/mix?song='
options = '&size='+size+'&sizeType=tracks&content=text'

# The url in which to use
Base_URL = apiPath + quote(currentlyPlaying.encode('iso-8859-1')) + options
#Pre-define global Lists
LinkURL = []

WebSock = urllib.urlopen(Base_URL)  # Opens a 'Socket' to URL
WebHTML = WebSock.read()            # Reads Contents of URL and saves to Variable
WebSock.close()                     # Closes connection to url


LinkURL = WebHTML.split("\n")
playList = xbmc.PlayList(0)
currentPos = playList.getposition()
if playList.size()>1 and currentPos < playList.size()-1: #Since Kodi, playlist clear would leave the new play list playing at oldplaylist.position, this code fixes that
        for i in range (currentPos+1, playList.size()):
                playList.remove(playList[currentPos+1].getfilename())

first = True #first item returned from musicIP is the item currently playing, so don't add that to playlist.

for l in LinkURL:
    if not l == "":
                if not (first):
                        playList.add(url=l)
                first=False
Reply

Logout Mark Read Team Forum Stats Members Help
MusicIP Mixer (MusicIP.com, similar to Last.fm)2