-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUtils.py
517 lines (488 loc) · 25.2 KB
/
Utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
import urllib, xbmc, xbmcaddon,xbmcgui,xbmcvfs,datetime
import os,sys,time
if sys.version_info < (2, 7):
import simplejson
else:
import json as simplejson
__addon__ = xbmcaddon.Addon()
__addonid__ = __addon__.getAddonInfo('id')
__language__ = __addon__.getLocalizedString
Addon_Data_Path = os.path.join( xbmc.translatePath("special://profile/addon_data/%s" % __addonid__ ).decode("utf-8") )
Window = 10000
locallist = []
def AddArtToLibrary( type, media, folder, limit , silent = False):
json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.Get%ss", "params": {"properties": ["art", "file"], "sort": { "method": "label" } }, "id": 1}' % media.lower())
json_query = unicode(json_query, 'utf-8', errors='ignore')
json_response = simplejson.loads(json_query)
if (json_response['result'] != None) and ('%ss' % (media.lower()) in json_response['result']):
# iterate through the results
if silent == False:
progressDialog = xbmcgui.DialogProgress(__language__(32016))
progressDialog.create(__language__(32016))
for count,item in enumerate(json_response['result']['%ss' % media.lower()]):
if silent == False:
if progressDialog.iscanceled():
return
path= media_path(item['file']).encode("utf-8") + "/" + folder + "/"
file_list = xbmcvfs.listdir(path)[1]
for i,file in enumerate (file_list):
if i + 1 > limit:
break
if silent == False:
progressDialog.update( (count * 100) / json_response['result']['limits']['total'] , __language__(32011) + ' %s: %s %i' % (item["label"],type,i + 1))
if progressDialog.iscanceled():
return
file_path = path + "/" + file
if xbmcvfs.exists(file_path) and item['art'].get('%s%i' % (type,i),'') == "" :
xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.Set%sDetails", "params": { "%sid": %i, "art": { "%s%i": "%s" }}, "id": 1 }' %( media , media.lower() , item.get('%sid' % media.lower()) , type , i + 1, file_path))
def import_skinsettings():
importstring = read_from_file()
if importstring:
progressDialog = xbmcgui.DialogProgress(__language__(32010))
progressDialog.create(__language__(32010))
xbmc.sleep(200)
for count, skinsetting in enumerate(importstring):
if progressDialog.iscanceled():
return
if skinsetting[1].startswith(xbmc.getSkinDir()):
progressDialog.update( (count * 100) / len(importstring) , __language__(32011) + ' %s' % skinsetting[1])
setting = skinsetting[1].replace(xbmc.getSkinDir() + ".","")
if skinsetting[0] == "string":
if skinsetting[2] <> "":
xbmc.executebuiltin( "Skin.SetString(%s,%s)" % (setting,skinsetting[2]) )
else:
xbmc.executebuiltin( "Skin.Reset(%s)" % setting )
elif skinsetting[0] == "bool":
if skinsetting[2] == "true":
xbmc.executebuiltin( "Skin.SetBool(%s)" % setting )
else:
xbmc.executebuiltin( "Skin.Reset(%s)" % setting )
xbmc.sleep(30)
xbmcgui.Dialog().ok(__language__(32005),__language__(32009))
else:
log("backup not found")
def export_skinsettings():
from xml.dom.minidom import parse
# Set path
guisettings_path = xbmc.translatePath( 'special://profile/guisettings.xml' ).decode("utf-8")
# Check to see if file exists
if xbmcvfs.exists( guisettings_path ):
log("guisettings.xml found")
doc = parse( guisettings_path )
skinsettings = doc.documentElement.getElementsByTagName( 'setting' )
newlist = []
for count, skinsetting in enumerate(skinsettings):
if skinsetting.childNodes:
value = skinsetting.childNodes [ 0 ].nodeValue
else:
value = ""
if skinsetting.attributes[ 'name' ].nodeValue.startswith(xbmc.getSkinDir()):
newlist.append((skinsetting.attributes[ 'type' ].nodeValue,skinsetting.attributes[ 'name' ].nodeValue,value))
if save_to_file(newlist,xbmc.getSkinDir() + ".backup"):
xbmcgui.Dialog().ok(__language__(32005),__language__(32006))
else:
xbmcgui.Dialog().ok(__language__(32007),__language__(32008))
log("guisettings.xml not found")
def create_musicvideo_list():
musicvideos = []
json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMusicVideos", "params": {"properties": ["artist", "file"], "sort": { "method": "artist" } }, "id": 1}')
json_query = unicode(json_query, 'utf-8', errors='ignore')
json_response = simplejson.loads(json_query)
if "result" in json_response and ("musicvideos" in json_response['result']):
# iterate through the results
for item in json_response['result']['musicvideos']:
artist = item['artist']
title = item['label']
path = item['file']
musicvideos.append((artist,title,path))
return musicvideos
else:
return False
def create_movie_list():
movies = []
json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": {"properties": ["year", "file", "art", "genre", "director","cast","studio","country","tag"], "sort": { "method": "random" } }, "id": 1}')
json_query = unicode(json_query, 'utf-8', errors='ignore')
json_query = simplejson.loads(json_query)
if json_query['result'] != None and "movies" in json_query["result"]:
return json_query
else:
return False
def create_channel_list():
channels = []
json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "PVR.GetChannels", "params": {"properties": ["thumbnail","channeltype", "hidden", "locked", "channel", "lastplayed"], "channelgroupid": "alltv" }, "id": 1}')
json_query = unicode(json_query, 'utf-8', errors='ignore')
json_query = simplejson.loads(json_query)
prettyprint(json_query)
if json_query['result'] != None and "movies" in json_query["result"]:
return json_query
else:
return False
def GetXBMCArtists():
filename = Addon_Data_Path + "/XBMCartists.txt"
if xbmcvfs.exists(filename) and time.time() - os.path.getmtime(filename) < 0:
return read_from_file(filename)
else:
json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "AudioLibrary.GetArtists", "params": {"properties": ["musicbrainzartistid"]}, "id": 1}')
json_query = unicode(json_query, 'utf-8', errors='ignore')
json_query = simplejson.loads(json_query)
save_to_file(json_query,"XBMCartists",Addon_Data_Path)
return json_query
def GetSimilarArtistsInLibrary(id):
from OnlineMusicInfo import GetSimilarById
simi_artists = GetSimilarById(id)
if simi_artists == None:
log('Last.fm didn\'t return proper response')
return None
xbmc_artists = GetXBMCArtists()
artists = []
for (count, simi_artist) in enumerate(simi_artists):
for (count, xbmc_artist) in enumerate(xbmc_artists["result"]["artists"]):
if xbmc_artist['musicbrainzartistid'] != '':
if xbmc_artist['musicbrainzartistid'] == simi_artist['mbid']:
artists.append(xbmc_artist)
elif xbmc_artist['artist'] == simi_artist['name']:
json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "AudioLibrary.GetArtistDetails", "params": {"properties": ["genre", "description", "mood", "style", "born", "died", "formed", "disbanded", "yearsactive", "instrument", "fanart", "thumbnail"], "artistid": %s}, "id": 1}' % str(xbmc_artist['artistid']))
json_query = unicode(json_query, 'utf-8', errors='ignore')
json_response = simplejson.loads(json_query)
item = json_response["result"]["artistdetails"]
newartist = {"Title" : item['label'],
"Genre" : " / ".join(item['genre']),
"Thumb" : item['thumbnail'], #remove
"Fanart" : item['fanart'], #remove
"Art(thumb)" : item['thumbnail'],
"Art(fanart)" : item['fanart'],
"Description" : item['description'],
"Born" : item['born'],
"Died" : item['died'],
"Formed" : item['formed'],
"Disbanded" : item['disbanded'],
"YearsActive" : " / ".join(item['yearsactive']),
"Style" : " / ".join(item['style']),
"Mood" : " / ".join(item['mood']),
"Instrument" : " / ".join(item['instrument']),
"LibraryPath" : 'musicdb://2/' + str(item['artistid']) + '/' }
artists.append(newartist)
log(newartist)
log('%i of %i artists found in last.FM is in XBMC database' % (len(artists), len(simi_artists)))
return artists
def create_light_movielist():
# if xbmcvfs.exists(filename) and time.time() - os.path.getmtime(filename) < 1:
# return read_from_file(filename)
if True:
a = datetime.datetime.now()
json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": {"properties": ["set", "originaltitle", "imdbnumber", "file"], "sort": { "method": "random" } }, "id": 1}')
json_query = unicode(json_query, 'utf-8', errors='ignore')
json_query = simplejson.loads(json_query)
b = datetime.datetime.now() - a
log('Processing Time for fetching JSON light movielist: %s' % b)
a = datetime.datetime.now()
b = datetime.datetime.now() - a
log('Processing Time for save light movielist: %s' % b)
return json_query
def GetSimilarFromOwnLibrary(dbid):
movies = []
# # if xbmcvfs.exists(filename) and time.time() - os.path.getmtime(filename) < 1:
# return read_from_file(filename)
if True:
json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovieDetails", "params": {"properties": ["genre","director","country","year","mpaa"], "movieid":%s }, "id": 1}' % dbid)
json_query = unicode(json_query, 'utf-8', errors='ignore')
json_response = simplejson.loads(json_query)
if "moviedetails" in json_response['result']:
id = json_response['result']['moviedetails']['movieid']
genres = json_response['result']['moviedetails']['genre']
year = int(json_response['result']['moviedetails']['year'])
countries = json_response['result']['moviedetails']['country']
directors = json_response['result']['moviedetails']['director']
mpaa = json_response['result']['moviedetails']['mpaa']
json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": {"properties": ["genre","director","mpaa","country","year"], "sort": { "method": "random" } }, "id": 1}')
json_query = unicode(json_query, 'utf-8', errors='ignore')
json_query = simplejson.loads(json_query)
if "movies" in json_query['result']:
quotalist= []
for item in json_query['result']['movies']:
difference = int(item['year']) - year
hit = 0.0
miss = 0.0
quota = 0.0
for genre in genres:
if genre in item['genre']:
hit += 1.0
else:
miss += 1.0
miss += 0.00001
if hit > 0.0:
quota = float(hit) / float(hit + miss)
if genres[0] == item['genre'][0]:
quota += 0.3
if difference < 6 and difference > -6:
quota += 0.15
if difference < 3 and difference > -3:
quota += 0.15
if countries[0] == item['country'][0]:
quota += 0.4
if mpaa == item['mpaa']:
quota += 0.4
if directors[0] == item['director'][0]:
quota += 0.6
quotalist.append((quota,item["movieid"]))
if True:
quotalist = sorted(quotalist, key=lambda quota: quota[0],reverse=True)
count = 1
for list_movie in quotalist:
if id <> list_movie[1]:
json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovieDetails", "params": {"properties": ["imdbnumber","genre","year", "art", "rating"], "movieid":%s }, "id": 1}' % str(list_movie[1]))
json_query = unicode(json_query, 'utf-8', errors='ignore')
json_response = simplejson.loads(json_query)
movie = json_response["result"]["moviedetails"]
newmovie = {'Art(fanart)': movie["art"].get('fanart',""),
'Art(poster)': movie["art"].get('poster',""),
'Title': movie.get('label',""),
'OriginalTitle': movie.get('originaltitle',""),
'ID': movie.get('imdbnumber',""),
'Path': "",
'Play': "",
'DBID': "",
'Rating': str(round(float(movie['rating']),1)),
'Premiered':movie.get('year',"") }
movies.append(newmovie)
count += 1
if count > 20:
break
return movies
def media_streamdetails(filename, streamdetails):
info = {}
video = streamdetails['video']
audio = streamdetails['audio']
if '3d' in filename:
info['videoresolution'] = '3d'
elif video:
videowidth = video[0]['width']
videoheight = video[0]['height']
if (video[0]['width'] <= 720 and video[0]['height'] <= 480):
info['videoresolution'] = "480"
elif (video[0]['width'] <= 768 and video[0]['height'] <= 576):
info['videoresolution'] = "576"
elif (video[0]['width'] <= 960 and video[0]['height'] <= 544):
info['videoresolution'] = "540"
elif (video[0]['width'] <= 1280 and video[0]['height'] <= 720):
info['videoresolution'] = "720"
elif (video[0]['width'] >= 1281 or video[0]['height'] >= 721):
info['videoresolution'] = "1080"
else:
info['videoresolution'] = ""
elif (('dvd') in filename and not ('hddvd' or 'hd-dvd') in filename) or (filename.endswith('.vob' or '.ifo')):
info['videoresolution'] = '576'
elif (('bluray' or 'blu-ray' or 'brrip' or 'bdrip' or 'hddvd' or 'hd-dvd') in filename):
info['videoresolution'] = '1080'
else:
info['videoresolution'] = '1080'
if video:
info['videocodec'] = video[0]['codec']
if (video[0]['aspect'] < 1.4859):
info['videoaspect'] = "1.33"
elif (video[0]['aspect'] < 1.7190):
info['videoaspect'] = "1.66"
elif (video[0]['aspect'] < 1.8147):
info['videoaspect'] = "1.78"
elif (video[0]['aspect'] < 2.0174):
info['videoaspect'] = "1.85"
elif (video[0]['aspect'] < 2.2738):
info['videoaspect'] = "2.20"
else:
info['videoaspect'] = "2.35"
else:
info['videocodec'] = ''
info['videoaspect'] = ''
if audio:
info['audiocodec'] = audio[0]['codec']
info['audiochannels'] = audio[0]['channels']
else:
info['audiocodec'] = ''
info['audiochannels'] = ''
return info
def GetXBMCAlbums():
albums = []
json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "AudioLibrary.GetAlbums", "params": {"properties": ["title"]}, "id": 1}')
json_query = unicode(json_query, 'utf-8', errors='ignore')
json_query = simplejson.loads(json_query)
if "result" in json_query and "albums" in json_query['result']:
return json_query['result']['albums']
else:
return []
def media_path(path):
# Check for stacked movies
try:
path = os.path.split(path)[0].rsplit(' , ', 1)[1].replace(",,",",")
except:
path = os.path.split(path)[0]
# Fixes problems with rared movies and multipath
if path.startswith("rar://"):
path = [os.path.split(urllib.url2pathname(path.replace("rar://","")))[0]]
elif path.startswith("multipath://"):
temp_path = path.replace("multipath://","").split('%2f/')
path = []
for item in temp_path:
path.append(urllib.url2pathname(item))
else:
path = [path]
return path[0]
def CompareWithLibrary(onlinelist):
global locallist
if not locallist:
locallist = create_light_movielist()
a = datetime.datetime.now()
log("startin compare")
for onlineitem in onlinelist:
for localitem in locallist["result"]["movies"]:
comparators = [localitem["originaltitle"],localitem["label"]]
if onlineitem["OriginalTitle"] in comparators or onlineitem["Title"] in comparators:
log("compare success" + onlineitem["Title"])
json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovieDetails", "params": {"properties": ["streamdetails","year"], "movieid":%s }, "id": 1}' % str(localitem["movieid"]))
json_query = unicode(json_query, 'utf-8', errors='ignore')
json_response = simplejson.loads(json_query)
if "moviedetails" in json_response["result"] and "Premiered" in onlineitem:
difference = int(onlineitem["Premiered"][:4]) - int(json_response['result']['moviedetails']['year'])
if difference >-2 and difference <2:
streaminfo = media_streamdetails(localitem['file'].encode('utf-8').lower(), json_response['result']['moviedetails']['streamdetails'])
log(localitem)
onlineitem.update({"Play": localitem["movieid"]})
onlineitem.update({"DBID": localitem["movieid"]})
onlineitem.update({"Path": localitem["movieid"]})
onlineitem.update({"VideoCodec": streaminfo["videocodec"]})
onlineitem.update({"VideoResolution": streaminfo["videoresolution"]})
onlineitem.update({"VideoAspect": streaminfo["videoaspect"]})
onlineitem.update({"AudioCodec": streaminfo["audiocodec"]})
onlineitem.update({"AudioChannels": str(streaminfo["audiochannels"])})
break
b = datetime.datetime.now() - a
log('Processing Time for comparing: %s' % b)
return onlinelist
def CompareAlbumWithLibrary(onlinelist):
global locallist
if not locallist:
locallist = GetXBMCAlbums()
a = datetime.datetime.now()
log("startin compare")
for onlineitem in onlinelist:
for localitem in locallist:
if onlineitem["name"] == localitem["title"]:
log("compare success: " + onlineitem["name"])
json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "AudioLibrary.GetAlbumDetails", "params": {"properties": ["thumbnail"], "albumid":%s }, "id": 1}' % str(localitem["albumid"]))
json_query = unicode(json_query, 'utf-8', errors='ignore')
json_query = simplejson.loads(json_query)
album = json_query["result"]["albumdetails"]
onlineitem.update({"DBID": album["albumid"]})
onlineitem.update({"Path": 'XBMC.RunScript(service.skin.widgets,albumid=' + str(album["albumid"]) + ')'})
if album["thumbnail"]:
log("updating " + album["thumbnail"])
onlineitem.update({"thumb": album["thumbnail"]})
onlineitem.update({"Icon": album["thumbnail"]})
# onlineitem.update({"Path": localitem["movieid"]})
break
b = datetime.datetime.now() - a
log('Processing Time for comparing: %s' % b)
return onlinelist
def GetStringFromUrl(encurl):
doc = ""
succeed = 0
while succeed < 5:
try:
f = urllib.urlopen( encurl)
doc = f.read()
f.close()
return str(doc)
except:
log("could not get data from %s" % encurl)
xbmc.sleep(1000)
succeed += 1
return ""
def log(txt):
if isinstance(txt, str):
txt = txt.decode("utf-8")
message = u'%s: %s' % (__addonid__, txt)
xbmc.log(msg=message.encode("utf-8"), level=xbmc.LOGDEBUG)
def get_browse_dialog( default="", heading="", dlg_type=3, shares="files", mask="", use_thumbs=False, treat_as_folder=False ):
""" shows a browse dialog and returns a value
- 0 : ShowAndGetDirectory
- 1 : ShowAndGetFile
- 2 : ShowAndGetImage
- 3 : ShowAndGetWriteableDirectory
"""
dialog = xbmcgui.Dialog()
value = dialog.browse( dlg_type, heading, shares, mask, use_thumbs, treat_as_folder, default )
return value
def save_to_file(content, filename, path = "" ):
import xbmcvfs
if True:
if path == "":
text_file_path = get_browse_dialog() + filename + ".txt"
else:
if not xbmcvfs.exists(path):
xbmcvfs.mkdir(path)
text_file_path = os.path.join(path,filename + ".txt")
log("save to textfile:")
log(text_file_path)
text_file = open(text_file_path, "w")
simplejson.dump(content,text_file)
text_file.close()
return True
else:
return False
def read_from_file(path = "" ):
import xbmcvfs
log("trying to load " + path)
# Set path
if path == "":
path = get_browse_dialog(dlg_type=1)
# Check to see if file exists
if xbmcvfs.exists( path ):
with open(path) as f: fc = simplejson.load(f)
log("loaded textfile " + path)
if True:
return fc
else:
log("error when loading file")
log(fc)
return []
else:
return False
def ConvertYoutubeURL(string):
import re
if 'youtube.com/v' in string:
vid_ids = re.findall('http://www.youtube.com/v/(.{11})\??', string, re.DOTALL )
for id in vid_ids:
convertedstring = 'plugin://plugin.video.youtube/?action=play_video&videoid=%s' % id
return convertedstring
if 'youtube.com/watch' in string:
vid_ids = re.findall('youtube.com/watch\?v=(.{11})\??', string, re.DOTALL )
for id in vid_ids:
convertedstring = 'plugin://plugin.video.youtube/?action=play_video&videoid=%s' % id
return convertedstring
return ""
def ExtractYoutubeID(string):
import re
if 'youtube.com/v' in string:
vid_ids = re.findall('http://www.youtube.com/v/(.{11})\??', string, re.DOTALL )
for id in vid_ids:
return id
if 'youtube.com/watch' in string:
vid_ids = re.findall('youtube.com/watch\?v=(.{11})\??', string, re.DOTALL )
for id in vid_ids:
return id
return ""
def Notify(header, line='', line2='', line3=''):
xbmc.executebuiltin('Notification(%s,%s,%s,%s)' % (header, line, line2, line3) )
def GetMovieSetName(dbid):
json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovieDetails", "params": {"properties": ["setid"], "movieid":%s }, "id": 1}' % dbid)
json_query = unicode(json_query, 'utf-8', errors='ignore')
json_response = simplejson.loads(json_query)
if "moviedetails" in json_response["result"]:
dbsetid = json_response['result']['moviedetails'].get('setid',"")
if dbsetid:
json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovieSetDetails", "params": {"setid":%s }, "id": 1}' % dbsetid)
json_query = unicode(json_query, 'utf-8', errors='ignore')
json_response = simplejson.loads(json_query)
return json_response['result']['setdetails'].get('label',"")
return ""
def prettyprint(string):
log(simplejson.dumps(string, sort_keys=True, indent=4, separators=(',', ': ')))