Resetting/Updating the Music Playlist
#1
I have a small script (with borrowed code from a few other scripts, shown below) that will take the currently playing song, pass it to another app I have, which returns a new playlist based on the ‘seed’ song.

The problem I have is;

Assume I’m listening to the 4th track in the currently playing playlist.

When I run my code, it does everything correctly, except, XBMC still thinks it’s playing the 4th track, so the next track played is number 5. The seed song is listed as the first track in the playlist.

Any thoughts?

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

# Script constants
__scriptname__ = "MusicIP Mix"

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

currentlyPlaying = xbmc.Player().getMusicInfoTag().getURL()
print currentlyPlaying
currentlyPlaying = currentlyPlaying.replace("smb:","").replace(" ","+")

apiPath = 'http://192.168.1.73:10002/api/mix?song='
#options = '&size=50&sizeType=tracks&content=text'
options = '&size=50&sizeType=tracks&content=text&style=100&variety=3'

# 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)


# acknowledge track selection, ask to view playlist

dialog = xbmcgui.Dialog()
i = dialog.yesno("Song added to MusicIP Mixer", "Would you like to view the new Playlist?")

if i == 1:
xbmc.executebuiltin( "XBMC.ActivateWindow(10500)" )
Reply
#2
(2013-08-07, 20:53)phreaq Wrote: I have a small script (with borrowed code from a few other scripts, shown below) that will take the currently playing song, pass it to another app I have, which returns a new playlist based on the ‘seed’ song.

The problem I have is;

Assume I’m listening to the 4th track in the currently playing playlist.

When I run my code, it does everything correctly, except, XBMC still thinks it’s playing the 4th track, so the next track played is number 5. The seed song is listed as the first track in the playlist.

Any thoughts?
Quote:# Import XBMC module
import xbmc,urllib,urllib2 , re, os, xbmcgui
from string import split, replace, find

# Script constants
__scriptname__ = "MusicIP Mix"

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

currentlyPlaying = xbmc.Player().getMusicInfoTag().getURL()
print currentlyPlaying
currentlyPlaying = currentlyPlaying.replace("smb:","").replace(" ","+")

apiPath = 'http://192.168.1.73:10002/api/mix?song='
#options = '&size=50&sizeType=tracks&content=text'
options = '&size=50&sizeType=tracks&content=text&style=100&variety=3'

# 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)


# acknowledge track selection, ask to view playlist

dialog = xbmcgui.Dialog()
i = dialog.yesno("Song added to MusicIP Mixer", "Would you like to view the new Playlist?")

if i == 1:
xbmc.executebuiltin( "XBMC.ActivateWindow(10500)" )

Did you ever sort this out? I'm curious. I'm gearing up to improve this addon. It's now living here: https://github.com/bernd-wechner/script.audio.musicip

and I'm trying to work a few things out about Kodi Addon development before I get some much needed tweaks implemented on that. Not least the very one you touched on there, except I won't be doing it with a  a dialog, I think it's a danged safe assumption that if I just built a playlist I want to see it! And further, you need to look at it int he Kodi GUI before the Kore and the Chorus views get any metadata updates on the playlist (prior to that they just display lists of file paths!).
Reply

Logout Mark Read Team Forum Stats Members Help
Resetting/Updating the Music Playlist0