Skip to content

Instantly share code, notes, and snippets.

@chezsick
Last active November 14, 2019 08:48
Show Gist options
  • Select an option

  • Save chezsick/cf858e9703791f13855e8ef7405b951c to your computer and use it in GitHub Desktop.

Select an option

Save chezsick/cf858e9703791f13855e8ef7405b951c to your computer and use it in GitHub Desktop.
Generate A Teletext Just For Fun ;;;;;;;;;;;;;;; args ::::::::::::::: url channelname output
import sys
import hashlib
import random
import os
from tempfile import mkstemp
a = mkstemp()[1]
b = mkstemp()[1]
f = mkstemp()[1]
syllab = "azertyuiopqsdfghjklmwxcvbn3"
font = "/usr/local/share/fonts/EuropeanTeletext.ttf"
url = str(sys.argv[1])
hash = hashlib.sha256()
hash.update(url)
reshash = hash.digest()
ofont = ord(reshash[0])
if ofont < 30:
font = "/usr/local/share/fonts/EuropeanTeletextNuevo.ttf"
import time
hashtwo = hashlib.sha256()
hashtwo.update("%s%s" %(reshash,int(time.time()/86400)))
hashday = hashtwo.digest()
random.seed(hashday)
syc = len(syllab)
word = ""
for m in range(random.randint(1,6)):
for n in range(random.randint(2,10)):
word += syllab[random.randint(0,syc-1)]
word += " "
words = ""
for m in range(random.randint(30,300)):
for n in range(random.randint(2,10)):
words += syllab[random.randint(0,syc-1)]
words += " "
fr = open(f,"w")
fr.write(words)
fr.close()
os.system("gm convert -font %s -pointsize 16 -background white -fill black -size 768x16 caption:'%s' miff:%s" %(font,word,a))
os.system("gm convert -font %s -pointsize 16 -background black -fill white -size 768x560 caption:'@%s' miff:%s" %(font,f,b))
os.system("gm convert -append miff:%s miff:%s png:-" %(a,b))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment