[Broken Dev WIP] RealTime Notifications

Take text from JSON API Call 'notitxt' and then write that text onto a pre-defined background image 'sample-in.jpg' and write it out to 'sample-out.jpg'
Copypasta of another def later in the code to display just that sample-out file.
It's a mess, won't work but its a starting point
This commit is contained in:
Oli
2018-01-20 16:07:09 +00:00
parent 8b432bc93d
commit db2cdd6737
7 changed files with 34 additions and 5 deletions

3
.gitignore vendored
View File

@@ -1 +1,2 @@
_repo_xml_generator.py _repo_xml_generator.py
plugin.video.blackhatconf.zip

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="service.lowerthird" name="LowerThird" version="0.1.1" provider-name="Double T"> <addon id="service.lowerthird" name="LowerThird" version="0.1.2" provider-name="Double T">
<requires> <requires>
<import addon="xbmc.python" version="2.1.0"/> <import addon="xbmc.python" version="2.1.0"/>
<import addon="script.module.pil" version="1.1.7"/> <import addon="script.module.pil" version="1.1.7"/>

View File

@@ -13,6 +13,8 @@ import xbmcgui
import os.path import os.path
from random import randint from random import randint
from PIL import Image from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw
from datetime import datetime as date from datetime import datetime as date
from threading import Timer from threading import Timer
from xml.dom import minidom from xml.dom import minidom

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 KiB

Binary file not shown.

View File

@@ -15,8 +15,32 @@ import urlparse
import os import os
import sys import sys
from PIL import Image from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw
from xml.dom import minidom from xml.dom import minidom
# ============================================================
# Create lowerthird banners from API sent text
# Won't work yet...
# ============================================================
def CreateLowerThird
# define the font path as local fonts dir in prj root
fonts_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'fonts')
font = ImageFont.truetype(os.path.join(fonts_path, 'sans_serif.ttf'), 24)
# font = ImageFont.truetype(<font-file>, <font-size>)
# font-file should be present in provided path.
font = ImageFont.truetype("sans-serif.ttf", 16)
img = Image.open("sample_in.jpg")
draw = ImageDraw.Draw(img)
# font = ImageFont.truetype(<font-file>, <font-size>)
font = ImageFont.truetype("sans-serif.ttf", 16)
# draw.text((x, y),"Sample Text",(r,g,b))
draw.text((0, 0),notitxt,(255,255,255),font=font)
img.save('sample-out.jpg')
# ============================================================ # ============================================================
# Define Overlay Class # Define Overlay Class
# ============================================================ # ============================================================
@@ -174,18 +198,20 @@ if __name__ == '__main__':
try: try:
params = urlparse.parse_qs('&'.join(sys.argv[1:])) params = urlparse.parse_qs('&'.join(sys.argv[1:]))
imageloc = params.get('imageloc', None)[0] notitxt = params.get('notitxt', None)[0]
imageloc = params.get('imageloc', None)[0]
displaytime = int(params.get('displaytime', None)[0]) displaytime = int(params.get('displaytime', None)[0])
position = params.get('position', None)[0] position = params.get('position', None)[0]
except Exception: except Exception:
imageloc = None imageloc = None
displaytime = None displaytime = None
position = None position = None
notitxt = None
if imageloc and displaytime and position: if imageloc and displaytime and position and notitxt:
success = xbmcvfs.exists(imageloc) success = xbmcvfs.exists(imageloc)
if success and displaytime > 1000 and displaytime < 60000 and (position == 'top' or position == 'bottom' or position == 'center'): if success and displaytime > 1000 and displaytime < 300001 and (position == 'top' or position == 'bottom' or position == 'center'):
xbmc.log("BANNERS >> STANDALONE DISPLAY IMAGE: " + str(imageloc) + " >> TIMEOUT: " + str(displaytime) + " >> POSITION: " + str(position)) xbmc.log("BANNERS >> STANDALONE DISPLAY IMAGE: " + str(imageloc) + " >> TIMEOUT: " + str(displaytime) + " >> POSITION: " + str(position))
displayBanner(imageloc, displaytime, position) displayBanner(imageloc, displaytime, position)
else: else: