2023-02-09, 13:47
Hi, I've attempted to write a script that starts a 'radio station' for a given song DBID, playing that song and then adding 25 songs with the same genre using a combination of JSON calls. The playlist looks ok from what I can see using Playlist.GetItems, but the first track in the playlist always fails to play back. Have I done something wrong with the JSON?
xml:
<onclick>RunScript(script.copacetic.helper,action=play_radio,id=$INFO[ListItem.DBID])</onclick>
python:
def play_radio(**kwargs):
clear_playlists()
dbid = kwargs.get('id', False)
genre = xbmc.getInfoLabel('ListItem.Genre')
#Get genre using dbid json call instead, then radio can be entirely based on the id parameter passed. Use getInfoLabel for the dbid and genre as fallback if now id parameter passed
if dbid:
json_call('Playlist.Add',
item={'songid': int(dbid)},
params={'playlistid': 0}
)
json_response = json_call('AudioLibrary.GetSongs',
params={'properties': ['genre']},
sort={'method': 'random'},
limit=25,
query_filter={'genre': genre}
)
for count in json_response['result']['songs']:
if count.get('songid', None):
songid = count['songid']
json_call('Playlist.Add',
item={'songid': int(songid)},
params={'playlistid': 0}
)
json_call('Playlist.GetItems',
params={'playlistid': 0}
)
json_call('Player.Open',
item={'playlistid': 0, 'position': 0}
)
json:
2023-02-09 12:00:09.864 T:7036 info <general>: script.copacetic.helper --> --> JSON CALL: {
"id": 1,
"jsonrpc": "2.0",
"method": "Playlist.GetItems",
"params": {
"playlistid": 0
}
}
2023-02-09 12:00:09.864 T:7036 info <general>: script.copacetic.helper --> --> JSON RESULT: {
"id": 1,
"jsonrpc": "2.0",
"result": {
"items": [
{
"id": 246,
"label": "The Doomsday Book",
"type": "song"
},
{
"id": 5627,
"label": "Brats",
"type": "song"
},
{
"id": 5518,
"label": "Traveling Light",
"type": "song"
},
{
"id": 8210,
"label": "The Number",
"type": "song"
},
{
"id": 5970,
"label": "Flash Burns From Flashbacks",
"type": "song"
},
{
"id": 9743,
"label": "The Placid Casual",
"type": "song"
}
],
"limits": {
"end": 6,
"start": 0,
"total": 6
}
}
}
2023-02-09 12:00:09.864 T:7036 info <general>: script.copacetic.helper --> --> JSON CALL: {
"id": 1,
"jsonrpc": "2.0",
"method": "Player.Open",
"params": {
"item": {
"playlistid": 0,
"position": 0
}
}
}
2023-02-09 12:00:09.864 T:7036 info <general>: script.copacetic.helper --> --> JSON RESULT: {
"id": 1,
"jsonrpc": "2.0",
"result": "OK"
}
2023-02-09 12:00:09.864 T:7036 debug <general>: CPythonInvoker(18, C:\Users\arash\AppData\Roaming\Kodi\addons\script.copacetic.helper\script.py): script successfully run
2023-02-09 12:00:09.864 T:7036 debug <general>: CPythonInvoker::onExecutionDone(18, C:\Users\arash\AppData\Roaming\Kodi\addons\script.copacetic.helper\script.py)
2023-02-09 12:00:09.924 T:11080 debug <general>: CPlayerCoreFactory::GetPlayers(musicdb://songs/246.flac)
2023-02-09 12:00:09.924 T:11080 debug <general>: CPlayerSelectionRule::GetPlayers: considering rule: system rules
2023-02-09 12:00:09.924 T:11080 debug <general>: CPlayerSelectionRule::GetPlayers: matches rule: system rules
2023-02-09 12:00:09.924 T:11080 debug <general>: CPlayerSelectionRule::GetPlayers: considering rule: mms/udp
2023-02-09 12:00:09.924 T:11080 debug <general>: CPlayerSelectionRule::GetPlayers: considering rule: lastfm/shout
2023-02-09 12:00:09.924 T:11080 debug <general>: CPlayerSelectionRule::GetPlayers: considering rule: rtmp
2023-02-09 12:00:09.924 T:11080 debug <general>: CPlayerSelectionRule::GetPlayers: considering rule: rtsp
2023-02-09 12:00:09.924 T:11080 debug <general>: CPlayerSelectionRule::GetPlayers: considering rule: streams
2023-02-09 12:00:09.924 T:11080 debug <general>: CPlayerSelectionRule::GetPlayers: considering rule: dvd
2023-02-09 12:00:09.924 T:11080 debug <general>: CPlayerSelectionRule::GetPlayers: considering rule: discimage
2023-02-09 12:00:09.924 T:11080 debug <general>: CPlayerSelectionRule::GetPlayers: considering rule: sdp/asf
2023-02-09 12:00:09.924 T:11080 debug <general>: CPlayerSelectionRule::GetPlayers: considering rule: nsv
2023-02-09 12:00:09.924 T:11080 debug <general>: CPlayerSelectionRule::GetPlayers: considering rule: radio
2023-02-09 12:00:09.924 T:11080 debug <general>: CPlayerCoreFactory::GetPlayers: matched 0 rules with players
2023-02-09 12:00:09.924 T:11080 debug <general>: CPlayerCoreFactory::GetPlayers: adding audiodefaultplayer (PAPlayer)
2023-02-09 12:00:09.924 T:11080 debug <general>: CPlayerCoreFactory::GetPlayers: for video=false, audio=true
2023-02-09 12:00:09.924 T:11080 debug <general>: CPlayerCoreFactory::GetPlayers: for video=true, audio=true
2023-02-09 12:00:09.924 T:11080 debug <general>: CPlayerCoreFactory::GetPlayers: adding player: VideoPlayer
2023-02-09 12:00:09.924 T:11080 debug <general>: CPlayerCoreFactory::GetPlayers: added 2 players
2023-02-09 12:00:09.924 T:16448 debug <general>: Thread PAPlayer start, auto delete: false
2023-02-09 12:00:09.924 T:2860 error <general>: VideoPlayerCodec::Init: Error opening file musicdb://songs/246.flac
2023-02-09 12:00:09.924 T:11080 debug <general>: CApplicationPlayerCallback::OnPlayBackStarted: CApplication::OnPlayBackStarted
2023-02-09 12:00:09.924 T:2860 error <general>: CAudioDecoder: Unable to Init Codec while loading file musicdb://songs/246.flac
2023-02-09 12:00:09.924 T:16448 debug <general>: PAPlayer:rocess - Playback started
2023-02-09 12:00:09.924 T:2860 warning <general>: PAPlayer::QueueNextFileEx - Failed to create the decoder
2023-02-09 12:00:09.924 T:2860 debug <general>: CApplicationPlayerCallback::OnAVStarted: CApplication::OnAVStarted
2023-02-09 12:00:09.924 T:2860 debug <general>: CApplicationPlayerCallback::OnQueueNextItem: CApplication::OnQueueNextItem
2023-02-09 12:00:09.986 T:11080 debug <general>: CMusicGUIInfo::InitCurrentItem(musicdb://songs/246.flac)
2023-02-09 12:00:09.990 T:11080 debug <general>: SELECT albumview.*,albumartistview.* FROM albumview JOIN albumartistview ON albumview.idAlbum = albumartistview.idAlbum WHERE albumview.idAlbum = 20 ORDER BY albumartistview.iOrder
2023-02-09 12:00:09.990 T:11080 debug <general>: Loading additional tag info for file smb://192.168.86.62/Music/And You Will Know Us By The Trail of Dead/2014 IX/Disc 1/01 ...And You Will Know Us by the Trail of Dead - The Doomsday Book.flac
2023-02-09 12:00:09.997 T:11080 debug <general>: unrecognized XipComment name: ACOUSTID_ID
2023-02-09 12:00:09.997 T:11080 debug <general>: unrecognized XipComment name: ASIN
2023-02-09 12:00:09.997 T:11080 debug <general>: unrecognized XipComment name: BARCODE
2023-02-09 12:00:09.997 T:11080 debug <general>: unrecognized XipComment name: CATALOGNUMBER
2023-02-09 12:00:09.997 T:11080 debug <general>: unrecognized XipComment name: DISCTOTAL
2023-02-09 12:00:09.997 T:11080 debug <general>: unrecognized XipComment name: ISRC
2023-02-09 12:00:09.997 T:11080 debug <general>: unrecognized XipComment name: MEDIA
2023-02-09 12:00:09.997 T:11080 debug <general>: unrecognized XipComment name: MUSICBRAINZ_RELEASETRACKID
2023-02-09 12:00:09.997 T:11080 debug <general>: unrecognized XipComment name: RELEASECOUNTRY
2023-02-09 12:00:09.997 T:11080 debug <general>: unrecognized XipComment name: SCRIPT
2023-02-09 12:00:09.997 T:11080 debug <general>: unrecognized XipComment name: TOTALDISCS
2023-02-09 12:00:09.997 T:11080 debug <general>: unrecognized XipComment name: TOTALTRACKS
2023-02-09 12:00:09.997 T:11080 debug <general>: unrecognized XipComment name: TRACKTOTAL
2023-02-09 12:00:09.997 T:11080 debug <general>: CPlayerGUIInfo::InitCurrentItem(musicdb://songs/246.flac)
2023-02-09 12:00:10.003 T:7036 debug <general>: Python interpreter stopped
2023-02-09 12:00:10.003 T:7036 debug <general>: Thread LanguageInvoker 7036 terminating
2023-02-09 12:00:10.016 T:2204 debug <general>: [plugin.video.tubed][lib][playback] Active monitor threads: []
2023-02-09 12:00:10.016 T:2204 debug <general>: [plugin.video.tubed][lib][playback] Playback monitoring failed to start, missing required {} ...
2023-02-09 12:00:10.099 T:11080 debug <general>: ------ Window Init (DialogBusy.xml) ------
2023-02-09 12:00:10.106 T:11080 debug <general>: ------ Window Deinit (DialogBusy.xml) ------
2023-02-09 12:00:10.108 T:11080 debug <general>: ------ Window Init (Custom_1109_Secondary_List_Taking_Focus.xml) ------
2023-02-09 12:00:10.145 T:2860 debug <general>: CDVDDemuxFFmpeg::Open - probing detected format [flac]
2023-02-09 12:00:10.146 T:2860 debug <general>: CDVDDemuxFFmpeg::Open - avformat_find_stream_info starting
2023-02-09 12:00:10.147 T:2860 debug <general>: CDVDDemuxFFmpeg::Open - av_find_stream_info finished
2023-02-09 12:00:10.147 T:2860 debug <general>: CDVDDemuxFFmpeg::AddStream ID: 0
2023-02-09 12:00:10.147 T:2860 debug <general>: CDVDDemuxFFmpeg::AddStream ID: 1
2023-02-09 12:00:10.147 T:2860 info <general>: CDVDAudioCodecFFmpeg::Open() Successful opened audio decoder flac
2023-02-09 12:00:10.150 T:2860 debug <general>: unrecognized XipComment name: ACOUSTID_ID
2023-02-09 12:00:10.150 T:2860 debug <general>: unrecognized XipComment name: ASIN
2023-02-09 12:00:10.150 T:2860 debug <general>: unrecognized XipComment name: BARCODE
2023-02-09 12:00:10.150 T:2860 debug <general>: unrecognized XipComment name: CATALOGNUMBER
2023-02-09 12:00:10.150 T:2860 debug <general>: unrecognized XipComment name: DISCTOTAL
2023-02-09 12:00:10.150 T:2860 debug <general>: unrecognized XipComment name: MEDIA
2023-02-09 12:00:10.150 T:2860 debug <general>: unrecognized XipComment name: MUSICBRAINZ_RELEASETRACKID
2023-02-09 12:00:10.150 T:2860 debug <general>: unrecognized XipComment name: RELEASECOUNTRY
2023-02-09 12:00:10.150 T:2860 debug <general>: unrecognized XipComment name: SCRIPT
2023-02-09 12:00:10.150 T:2860 debug <general>: unrecognized XipComment name: TOTALDISCS
2023-02-09 12:00:10.150 T:2860 debug <general>: unrecognized XipComment name: TOTALTRACKS
2023-02-09 12:00:10.150 T:2860 debug <general>: unrecognized XipComment name: TRACKTOTAL
2023-02-09 12:00:10.152 T:2860 debug <general>: CDVDDemuxFFmpeg::SeekTime - seek ended up on time 0
2023-02-09 12:00:10.237 T:11080 info <general>: Skipped 1 duplicate messages..
2023-02-09 12:00:10.237 T:11080 debug <general>: ------ Window Deinit (Custom_1107_Player_HasMedia.xml) ------
2023-02-09 12:00:10.265 T:2860 info <general>: AudioDecoder: File is queued
2023-02-09 12:00:10.267 T:2860 debug <general>: AudioDecoder::GetReplayGain - Final Replaygain applied: 1.000000, Track/Album Gain 89.000000, Peak 1.000000
2023-02-09 12:00:10.267 T:13744 debug <general>: CActiveAE::ClearDiscardedBuffers - buffer pool deleted
2023-02-09 12:00:10.281 T:2860 info <general>: PAPlayer:repareStream - Ready
2023-02-09 12:00:10.284 T:16448 debug <general>: CApplicationPlayerCallback::OnPlayBackStarted: CApplication::OnPlayBackStarted
2023-02-09 12:00:10.284 T:16448 debug <general>: CApplicationPlayerCallback::OnAVStarted: CApplication::OnAVStarted
2023-02-09 12:00:10.297 T:11080 debug <general>: CMusicGUIInfo::InitCurrentItem(musicdb://songs/5627.flac)