Kodi Notification Enhancement

Hi,
Just switched over from SickRage due to Sonarr being able to prioritize (and wait X amount of time before going to) Torrents vs Usenet.

My request is, when Sonarr sends the notification of grab/download/rename to Kodi, it uses its own thumbnail in the Kodi notification.

Given that Sonarr already knows the poster for the season (and as a fallback, the show), can it show the Show’s season (and if not available Series) poster instead?

I coded this in Python for sickbeard/SickRage and it a nice bit of detail. Hoping it can be implemented in Sonarr.

Thanks!

The problem is Sonarr tells Kodi to load the image via a URL, which needs to be accessible from where ever Kodi is running, Sonarr doesn’t know where its running from/which address its accessible from unless its told, which puts extra burden on the user and is another source of support when people can’t get it working correctly.

This should be possible to do in Sonarr via a custom script though.

Thank you for taking the time to respond!

Good point with respect to using the Sonarr pics.

Would it be possible to use the Art that Kodi houses then? This (see below) is actually how I coded it in Python (please excuse the horrible code, as Python isn’t in my top 5 languages used. It was a quick hack to get the desired result).

In short, the below Python code will:

  1. Find the show in Kodi
  2. Find the current season’s Art (if not found, get the show’s “overall” Art (as known by Kodi)
  3. Pop a notification with the URL we retrieved/built from Kodi’s responses
        #Get the show
        showDetailsRequest='{"jsonrpc": "2.0", "method": "VideoLibrary.GetTVShows", "params": {"properties": ["title","thumbnail"], "sort": {"order": "descending", "method": "lastplayed"}, "filter":{"field":"title","operator":"startswith","value":"'+showName+'"}} , "id": 1}'
        showDetailsRequest_enc=urlStr+urllib.quote(showDetailsRequest)

        try:
            fileHandle = urllib2.urlopen(showDetailsRequest_enc)
            showDetails_response = fileHandle.read()
            fileHandle.close()
        except IOError:
            print 'Cannot <strong class="highlight">open</strong> <strong class="highlight">URL</strong> %s for reading' % urlPayload
    
        showDetails_response='['+showDetails_response+']'
        showDetails_response = unicode(showDetails_response, 'utf-8', errors='ignore')
        json_response=simplejson.loads(showDetails_response)

        masterThumbnail = ""
        if json_response[0]['result'].has_key('tvshows'):
            item = json_response[0]['result']['tvshows']
            tvshowid = item[0]['tvshowid']
            tvshowid_str=str(tvshowid)
            masterThumbnail = item[0]['thumbnail']
        else:
            return
    

        #Get the season details for show
        #We need to limit the search so we only get the season we're interested in back    
        prevseasonnumber=seasonnumber - 1    
        prevseasonnumber_str=str(prevseasonnumber)
    
        showSeasonsRequest='{"jsonrpc": "2.0", "method": "VideoLibrary.GetSeasons", "params": {"properties": ["season", "thumbnail"], "tvshowid":'+tvshowid_str+',"limits":{"start":'+prevseasonnumber_str+',"end":'+seasonnumber_str+'}}, "id": 1}'
        showSeasonsRequest_enc=urlStr+urllib.quote(showSeasonsRequest)
        showSeasonsRequest_enc = unicode(showSeasonsRequest_enc, 'utf-8', errors='ignore')
    
        try:
            fileHandle = urllib2.urlopen(showSeasonsRequest_enc)
            showSeasons_response = fileHandle.read()
            fileHandle.close()
        except IOError:
            print 'Cannot <strong class="highlight">open</strong> <strong class="highlight">URL</strong> %s for reading' % urlPayload

        showSeasons_response='['+showSeasons_response+']'
        showSeasons_response = unicode(showSeasons_response, 'utf-8', errors='ignore')
        json_response=simplejson.loads(showSeasons_response)


        seasonThumbnail = ""  
        try:
            if json_response[0]['result'].has_key('seasons'):
                seasonThumbnail = item[0]['thumbnail']
        except:
            print 'Exception Error reading XML - Likely no Seasons element'
        

        if seasonThumbnail <> "":
                urlImage = seasonThumbnail
        else:
                urlImage = masterThumbnail


        #ImagePath = re.search('%s(.*)%s' % ('image://', ''), urlImage).group(1)
        #Remove trailing '/' if any...  (Just startd appearing)...
        urlImage=urlImage.rstrip('/')
    

        #Need to remove the image:// or XBMC doesn't show the picture           
        urlImage = re.sub('image://','',urlImage, flags=re.IGNORECASE)
    
        if urlImage<>'':
            urlImage='http://127.0.0.1:8080/image/'+urlImage
            showAddedRequest='{"jsonrpc":"2.0","method":"GUI.ShowNotification","params":{"title":"Just Added","message":"'+episodeMsg+'","image":"'+urlImage+'","displaytime":20000},"id":1}'
        else:
            showAddedRequest='{"jsonrpc":"2.0","method":"GUI.ShowNotification","params":{"title":"Just Added","message":"'+episodeMsg+'","displaytime":20000},"id":1}'

        showAddedRequest_enc=urllib.quote(showAddedRequest)
        showAddedRequest_enc = unicode(showAddedRequest_enc, 'utf-8', errors='ignore')
    
        print urlImage
        print showAddedRequest


        urlPayload=urlStr+showAddedRequest_enc
                  
        try:
            fileHandle = urllib2.urlopen(urlPayload)
            fileHandle.close()
          
        except IOError:
            print 'Cannot <strong class="highlight">open</strong> <strong class="highlight">URL</strong> %s for reading' % urlPayload
        str1 = 'error!'
    
        return None

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.