2013-08-07, 20:53
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?
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)" )