Compare commits

2 Commits

Author SHA1 Message Date
Oli
0efec7f4db Adding some more code that doesnt work yet
this is what i thought i had pushed the other night
2018-01-22 20:10:29 +00:00
Oli
db2cdd6737 [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
2018-01-20 16:07:09 +00:00
7 changed files with 75 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"?>
<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>
<import addon="xbmc.python" version="2.1.0"/>
<import addon="script.module.pil" version="1.1.7"/>

View File

@@ -13,6 +13,8 @@ import xbmcgui
import os.path
from random import randint
from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw
from datetime import datetime as date
from threading import Timer
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,73 @@ import urlparse
import os
import sys
from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw
from xml.dom import minidom
# ============================================================
# Create lowerthird banners from API sent text
# Won't work yet...
# ============================================================
class RealTimeNotifications
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')
def DisplayLowerThird(displaytime, position):
global myWidget
global intYOffset
global __addon__
__addon__ = xbmcaddon.Addon(id='service.lowerthird')
ActWin = xbmcgui.getCurrentWindowId()
myWidget = OverlayText(ActWin)
myWidget.show()
if position == 'top':
myWidget.imageBottom.setImage("")
myWidget.imageCenter.setImage("")
myWidget.imageTop.setImage("sample-out.jpg")
elif position == 'bottom':
myWidget.imageBottom.setImage("sample-out.jpg")
myWidget.imageCenter.setImage("")
myWidget.imageTop.setImage("")
else:
myWidget.imageBottom.setImage("")
myWidget.imageCenter.setImage("sample-out.jpg")
myWidget.imageTop.setImage("")
image = Image.open(open("sample-out.jpg", 'rb'))
width, height = image.size
myWidget.scaleimage(width, height, intYOffset)
xbmc.log('BANNERS >> STANDALONE INITIALIZING OVERLAY')
xbmc.sleep(displaytime)
try:
myWidget._close()
except Exception:
pass
myWidget = None
# ============================================================
# Define Overlay Class
# ============================================================
@@ -174,18 +239,20 @@ if __name__ == '__main__':
try:
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])
position = params.get('position', None)[0]
except Exception:
imageloc = None
displaytime = None
position = None
notitxt = None
if imageloc and displaytime and position:
if imageloc and displaytime and position and notitxt:
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))
displayBanner(imageloc, displaytime, position)
else: