Some cleanup

This commit is contained in:
warwickh 2021-09-28 10:18:59 +10:00
parent f7e3d18b5b
commit 5fa93a9830
2 changed files with 19 additions and 33 deletions

View File

@ -228,15 +228,15 @@ class Connection(object):
"""
methodName = 'ping'
viewName = '%s.view' % methodName
print("test")
req = self._getRequest(viewName)
print("Pinging %s"%str(req.full_url))#,#xbmc.logDEBUG)
#xbmc.log("Pinging %s"%str(req.full_url),#xbmc.logDEBUG)
#print("Pinging %s"%str(req.full_url)),xbmc.logDEBUG)
#xbmc.log("Pinging %s"%str(req.full_url),xbmc.logDEBUG)
try:
res = self._doInfoReq(req)
print(res)
#print(res)
except Exception as e:
print("Ping failed %s"%e)
#print("Ping failed %s"%e)
xbmc.log("Ping failed %s"%e,xbmc.logDEBUG)
return False
if res['status'] == 'ok':
return True
@ -898,7 +898,7 @@ class Connection(object):
'converted': converted})
req = self._getRequest(viewName, q)
##xbmc.log("Requesting %s"%str(req.full_url),#xbmc.logDEBUG)
##xbmc.log("Requesting %s"%str(req.full_url),xbmc.logDEBUG)
return_url = req.full_url
if self._insecure:
return_url += '|verifypeer=false'
@ -947,7 +947,7 @@ class Connection(object):
q = self._getQueryDict({'id': aid, 'size': size})
req = self._getRequest(viewName, q)
##xbmc.log("Requesting %s"%str(req.full_url),#xbmc.logDEBUG)
##xbmc.log("Requesting %s"%str(req.full_url),xbmc.logDEBUG)
return_url = req.full_url
if self._insecure:
return_url += '|verifypeer=false'
@ -1999,7 +1999,7 @@ class Connection(object):
q['musicFolderId'] = musicFolderId
req = self._getRequest(viewName, q)
#xbmc.log("Requesting %s"%str(req.full_url),#xbmc.logDEBUG)
#xbmc.log("Requesting %s"%str(req.full_url),xbmc.logDEBUG)
res = self._doInfoReq(req)
self._checkStatus(res)
return res
@ -2491,8 +2491,8 @@ class Connection(object):
req = self._getRequest(viewName, q)
res = self._doInfoReq(req)
print(req.get_full_url())
print(res)
#print(req.get_full_url())
#print(res)
self._checkStatus(res)
return res
@ -2817,7 +2817,7 @@ class Connection(object):
if(self._useGET or ('getCoverArt' in viewName) or ('stream' in viewName)):
url += '?%s' % urlencode(qdict)
#xbmc.log("UseGET URL %s"%(url), xbmc.logDEBUG)
print(url)
#print(url)
req = urllib.request.Request(url)
return req

30
main.py
View File

@ -746,7 +746,7 @@ def get_entry_playlist(item,params):
menu_id= params.get('menu_id')
),
'info': {'music': { ##http://romanvm.github.io/Kodistubs/_autosummary/xbmcgui.html#xbmcgui.ListItem.setInfo
'info': {'music': {
'title': item.get('name'),
'count': item.get('songCount'),
'duration': item.get('duration'),
@ -760,18 +760,11 @@ def get_image(item):
try:
if Addon().get_setting('enhanced_info'):
image = db.get_value(item.get('id'), 'wikipedia_image')[0][0]
print("Checking image type %s %s %s"%(item.get('id'), image, type(image)))
#print("Checking image type %s %s %s"%(item.get('id'), image, type(image)))
if (image is None) or (image =='') or (image =='None'):
connection = get_connection()
print("Using coverart tag from item %s is it same as %s ?"%(item.get('coverArt'),item.get('id')))
image = connection.getCoverArtUrl(item.get('coverArt'))
print("got %s from lastfm for %s"%(image,item.get('name')))
print("If I user id instead I would get %s"%connection.getCoverArtUrl(item.get('id')))
#Might fall back to album art if necessary - disabled no extra results
if "blah&id=" not in image:
album_id = connection.getArtist(item.get('id')).get('artist').get('album')[0].get('coverArt')
image = connection.getCoverArtUrl(album_id)
print("got %s from lastfm - first album for artist %s"%(image,item.get('name')))
#print("Using coverart tag from item %s is it same as %s ?"%(item.get('coverArt'),item.get('id')))
image = connection.getCoverArtUrl(item.get('coverArt'))
return image
except:
return image
@ -809,8 +802,7 @@ def get_entry_artist(item,params):
artist_lbl = '%s' % (item.get('name'))
else:
artist_lbl = '%s - %s' % (item.get('name'),artist_info)
print("Using label %s"%artist_lbl)
#artist_bio = artist_info.get('biography')
#print("Using label %s"%artist_lbl)
fanart = image
return {
'label': get_starred_label(item.get('id'),item.get('name')),
@ -824,15 +816,9 @@ def get_entry_artist(item,params):
menu_id= params.get('menu_id')
),
'info': {
'music': { ##http://romanvm.github.io/Kodistubs/_autosummary/xbmcgui.html#xbmcgui.ListItem.setInfo
'music': {
'count': item.get('albumCount'),
'artist': artist_lbl,
#'title': 'testtitle',
#'album': 'testalbum',
#'comment': 'testcomment',
#'label' : 'testlabel',
#'label2' : 'testlabel2',
#'title': artist_info
}
}
}
@ -852,7 +838,7 @@ def get_entry_album(item, params):
menu_id= params.get('menu_id')
),
'info': {
'music': { ##http://romanvm.github.io/Kodistubs/_autosummary/xbmcgui.html#xbmcgui.ListItem.setInfo
'music': {
'count': item.get('songCount'),
'date': convert_date_from_iso8601(item.get('created')), #date added
'duration': item.get('duration'),
@ -894,7 +880,7 @@ def get_entry_track(item,params):
),
'is_playable': True,
'mime': item.get("contentType"),
'info': {'music': { #http://romanvm.github.io/Kodistubs/_autosummary/xbmcgui.html#xbmcgui.ListItem.setInfo
'info': {'music': {
'title': item.get('title'),
'album': item.get('album'),
'artist': item.get('artist'),