KODI Notification for download finished

Come up with a useful post-processing script? Share it here!
Post Reply
Richard63
Newbie
Newbie
Posts: 17
Joined: January 18th, 2015, 3:58 pm

KODI Notification for download finished

Post by Richard63 »

Hello I made an script in python to notify KODI (or xbmc) the download has finished (shame it isnt in SABNzb as a standard)

Hope someone has a use for it or have remarks on it.

Code: Select all

#!/usr/bin/python
__author__ = 'Richard van Soest'
from urllib.request import urlopen
from urllib.request import Request
from urllib.parse import unquote
from urllib.parse import urlparse
import sys
import json
import urllib

total = len(sys.argv)
cmdargs = str(sys.argv)

# for debugging only
#print ("The total numbers of args passed to the script: %d " % total)
#print ("Args list: %s " % cmdargs)
##Pharsing args one by one 
#print ("Script name: %s" % str(sys.argv[0]))
#print ("First argument: %s" % str(sys.argv[1]))
#print ("Second argument: %s" % str(sys.argv[2]))
#print ("Third argument: %s" % str(sys.argv[3]))
#print ("Fourth argument: %s" % str(sys.argv[4]))
#print ("Fifth argument: %s" % str(sys.argv[5]))
#print ("Sixth argument: %s" % str(sys.argv[6]))
#print ("Seventh argument: %s" % str(sys.argv[7]))
#print ("----------------------")

sentence = sys.argv[3]

new = sentence.replace(" ", "%20")

#next line has to be in ONE line!!!
url = 'http://192.168.2.4/jsonrpc?request={%22jsonrpc%22:%222.0%22,%22method%22:%22GUI.ShowNotification%22,%22params%22:{%22displaytime%22:10000,%22title%22:%22SABNzbd%22,%22message%22:%22Finished%20'+new+'%22,%22image%22:%22http://sabnzbd.org/icon/sab2_512.png%22},%22id%22:1}'
response_stream = urlopen(url)

json_response = response_stream.read()

Post Reply