Skip to content
Snippets Groups Projects
Commit b3781f82 authored by Andreas Valder's avatar Andreas Valder
Browse files

Initial commit

parent 3c04ad18
No related branches found
No related tags found
No related merge requests found
__pycache__
# PyWorker
## Abhängigkeiten
* python3
* python3-pillow
* python3-requests
File added
assets/lgog_embed.png

3.48 KiB

assets/lgog_embed2.png

5.24 KiB

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="299.99982"
height="300.00003"
id="svg2"
sodipodi:version="0.32"
inkscape:version="0.46"
sodipodi:docbase="C:\Eigene Dateien\Video AG"
sodipodi:docname="videoag.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape"
version="1.0">
<defs
id="defs4">
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 526.18109 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="744.09448 : 526.18109 : 1"
inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
id="perspective2501" />
<linearGradient
id="linearGradient2041">
<stop
style="stop-color:#ffffff;stop-opacity:1.0000000;"
offset="0.00000000"
id="stop2043" />
<stop
style="stop-color:#7d7d7d;stop-opacity:1.0000000;"
offset="1.0000000"
id="stop2045" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2041"
id="linearGradient2047"
x1="194.17578"
y1="139.59265"
x2="250.03906"
y2="139.59265"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(319,-51)" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1.1973674"
inkscape:cx="149.99991"
inkscape:cy="150.00002"
inkscape:document-units="px"
inkscape:current-layer="layer1"
inkscape:window-width="1024"
inkscape:window-height="721"
inkscape:window-x="154"
inkscape:window-y="154"
showgrid="false"
borderlayer="true"
showborder="true"
inkscape:showpageshadow="true"
units="px" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Ebene 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-440.99979,-5.3620164)">
<path
sodipodi:type="arc"
style="opacity:1;fill:#000000;fill-opacity:1;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0"
id="path1306"
sodipodi:cx="281.42856"
sodipodi:cy="270.93362"
sodipodi:rx="38.57143"
sodipodi:ry="44.285713"
d="M 319.99999,270.93362 A 38.57143,44.285713 0 1 1 242.85713,270.93362 A 38.57143,44.285713 0 1 1 319.99999,270.93362 z"
transform="matrix(0.972222,0,0,0.846774,266.7456,-145.7001)"
inkscape:export-filename="C:\Eigene Dateien\Video AG\logo.png"
inkscape:export-xdpi="90.000000"
inkscape:export-ydpi="90.000000" />
<text
xml:space="preserve"
style="font-size:72px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:url(#linearGradient2047);fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Arial Black"
x="513"
y="114.36218"
id="text1308"
sodipodi:linespacing="125%"
inkscape:export-filename="C:\Eigene Dateien\Video AG\logo.png"
inkscape:export-xdpi="90.000000"
inkscape:export-ydpi="90.000000"><tspan
sodipodi:role="line"
id="tspan1312"
x="513"
y="114.36218"
style="fill:url(#linearGradient2047);fill-opacity:1">V</tspan></text>
<path
sodipodi:type="arc"
style="opacity:1;fill:#000000;fill-opacity:1;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0"
id="path3517"
sodipodi:cx="454"
sodipodi:cy="112.36218"
sodipodi:rx="87"
sodipodi:ry="56"
d="M 541,112.36218 A 87,56 0 1 1 454,56.362183 L 454,112.36218 z"
transform="matrix(-1.977323e-3,-1.724137,2.678569,-3.071905e-3,290.9275,938.4654)"
sodipodi:start="0"
sodipodi:end="4.712389"
inkscape:export-filename="C:\Eigene Dateien\Video AG\logo.png"
inkscape:export-xdpi="90.000000"
inkscape:export-ydpi="90.000000" />
<text
xml:space="preserve"
style="font-size:28px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Arial Black"
x="600"
y="111.36218"
id="text2055"
sodipodi:linespacing="125%"
inkscape:export-filename="C:\Eigene Dateien\Video AG\logo.png"
inkscape:export-xdpi="90.000000"
inkscape:export-ydpi="90.000000"><tspan
sodipodi:role="line"
id="tspan2785"
x="600"
y="111.36218"
style="font-size:36px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Arial Black">ideo</tspan></text>
<text
xml:space="preserve"
style="font-size:100px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Arial Black"
x="513"
y="249.36218"
id="text2051"
sodipodi:linespacing="125%"
inkscape:export-filename="C:\Eigene Dateien\Video AG\logo.png"
inkscape:export-xdpi="90.000000"
inkscape:export-ydpi="90.000000"><tspan
sodipodi:role="line"
id="tspan2053"
x="513"
y="249.36218"
style="font-size:100px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;font-family:Arial Black">AG</tspan></text>
<text
xml:space="preserve"
style="font-size:72px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:0.25098039;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Arial Black"
x="473"
y="114.36218"
id="text4979"
sodipodi:linespacing="125%"
inkscape:export-filename="C:\Eigene Dateien\Video AG\logo.png"
inkscape:export-xdpi="90.000000"
inkscape:export-ydpi="90.000000"><tspan
sodipodi:role="line"
id="tspan4981"
x="473"
y="114.36218">V</tspan></text>
</g>
</svg>
intro 0 → 100755
#!/usr/bin/env python3
from util import ping_job, getcurjobid, getjobdata, buildpath, job_failed
from PIL import Image, ImageFont, ImageDraw
import traceback
import sys
import json
import os
def centerText(img, draw, fnt, top, msg, color='white'):
iw, ih = img.width, img.height
tw, th = draw.textsize(msg, font=fnt)
draw.text(((iw-tw)/2, top), msg, font=fnt, fill=color)
def main():
if not len(sys.argv) == 5:
exit(1)
data = getjobdata()
outputfile = buildpath(os.environ.get('WORKER_RELEASED'), data['path']);
data = data['metadata']
with Image.new("RGB",(1920,1080),"black") as img:
fontpath = 'assets/LiberationSans-Regular.ttf'
draw = ImageDraw.Draw(img)
fnt = ImageFont.truetype(fontpath, 92)
centerText(img, draw, fnt, 270, data.get('album', ''))
fnt = ImageFont.truetype(fontpath, 69)
centerText(img, draw, fnt, 500, data.get('artist', ''))
fnt = ImageFont.truetype(fontpath, 72)
centerText(img, draw, fnt, 710, '{} vom {}'.format(data.get('title', ''), data.get('date', '').replace('/', '.')))
fnt = ImageFont.truetype(fontpath, 36)
centerText(img, draw, fnt, 910, 'Video erstellt von der Video AG der Fachschaft I/1')
linkblue = (81, 122, 231)
fnt = ImageFont.truetype(fontpath, 38)
centerText(img, draw, fnt, 950, 'https://video.rwth-aachen.de/', color=linkblue)
centerText(img, draw, fnt, 990, 'video@fsmpi.rwth-aachen.de', color=linkblue)
with Image.open('assets/lgog_embed2.png') as logo:
img.paste(logo,(1722, 924))
img.save(outputfile, "PNG")
ping_job('finished')
exit(0)
if __name__ == '__main__':
try:
main()
except Exception as e:
try:
job_failed(str(e))
except:
traceback.print_exc()
exit(3)
from .api import *
from .buildpath import *
import requests
import os
import json
import sys
from socket import gethostname
apikey = os.environ.get('WORKER_APIKEY', 'empty')
apibase = os.environ.get('WORKER_APIBASE', 'http://127.0.0.1:999999/nourl')
def getcurjobid():
return int(sys.argv[1])
def ping_job(state, status={'log': ''}):
r = requests.post('{}/internal/jobs/api/job/{}/ping'.format(apibase, getcurjobid()), data={'apikey': apikey, 'state': state, 'host': gethostname(), 'status': json.dumps(status)})
if not r.status_code in [200, 205]:
raise Exception('API call to "{}" failed: {}'.format(r.url, r.text))
return r.status_code == 200
def getjobdata():
return json.loads(sys.argv[4])
def job_failed(msg=''):
ping_job('failed', {'reason': msg, 'log': ''})
exit(2)
import os
def buildpath(root, path):
if not root:
root = ''
if not path:
raise Exception('Cannot build path: Value is empty')
return os.path.join(root, path)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment