-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6fab489
commit d45fb81
Showing
14 changed files
with
179 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
output =[] | ||
f = open('Shows.txt', 'r') | ||
|
||
|
||
|
||
for line in f: | ||
output.append(line) | ||
f.close() | ||
|
||
for i in range(0,len(output)): | ||
output[i] = output[i].rstrip('\n') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
''' | ||
To Do: | ||
- Centre Text to middle of box, depending on number of lines of text. | ||
- Should Name the file differently with only alpha numeric characters. | ||
- Should email/ log error if show name is uncompatable. | ||
''' | ||
|
||
from PIL import Image | ||
from PIL import ImageFont | ||
from PIL import ImageDraw | ||
from random import randint | ||
|
||
def add_text(showName): | ||
""" | ||
Args: | ||
showName (str): Show name to add to image. | ||
Output: | ||
The function outputs a JPG image to a sub folder called ShowImages. | ||
""" | ||
print(showName) #Prints to the console which show is being processed. | ||
|
||
# This looks at the name of the show weather it is a flagship or not. | ||
if showName == '': | ||
raise Exception("No show name provided.") | ||
elif showName[:10] == 'URY Brunch': #AM Flagship | ||
img = Image.open("AMFlagshipBackground.png") | ||
elif showName[:6] == 'URY:PM': #PM Flagship | ||
img = Image.open("PMFlagshipBackground.png") | ||
|
||
# If the show is not flagship, there is a list of backgrounds to randomly generate a show image. | ||
else: | ||
rGI = randint(0,7) | ||
RandomBackgrounds = ["Other1.png","Other2.png","Other3.png","Other4.png","Other5.png","Other6.png","Other7.png","Other8.png"] #List of different backgrounds. | ||
img = Image.open(RandomBackgrounds[rGI]) | ||
|
||
#This works out if the show name will fit neatly on the image, if the show name is less than 14 characters the normalize function will not be called. | ||
if len(showName) <= 14: | ||
prshowName = showName | ||
else: | ||
prshowName = normalize(showName) | ||
|
||
#Adds the text to the selected image. | ||
font_size = 85 | ||
# font = ImageFont.truetype(<font-file>, <font-size>) | ||
font = ImageFont.truetype("Raleway-SemiBoldItalic.ttf", font_size) | ||
draw = ImageDraw.Draw(img) | ||
w, h = draw.textsize(prshowName) | ||
# draw.text((x, y),"Sample Text",(r,g,b)) | ||
draw.text((60, 60),prshowName,(255,255,255),font) | ||
img.save('Showimages/%s.jpg' %showName) | ||
|
||
def normalize(input): | ||
""" | ||
Args: | ||
input (str): Takes in a string for a show name. | ||
Returns: | ||
A string containg line breaks so the text is not longer that 14 characters (including spaces) | ||
""" | ||
output = [] | ||
for word in input.split(" "): | ||
if len(word) > 14: | ||
raise Exception("Word too long for image. Contact DCM.") | ||
elif len(output) > 0 and (len(output[-1]) + len(word) < 14): | ||
output[-1] += " " + word | ||
else: | ||
output.append(word) | ||
|
||
if len(output) > 4: | ||
raise Exception("Spans too many lines for image. Contact DCM bitches.") | ||
|
||
return "".join(item + "\n" for item in output) | ||
|
||
################ | ||
#### Tests ##### | ||
################ | ||
#add_text('URY Brunch Some Show Name') | ||
#add_text('URY:PM Some Show Name') | ||
#add_text('Some Show Name') | ||
#add_text('Building Bridges - TheRoadtoRockandRoll and Roll') | ||
#print(normalize("Building Bridges - The Road to Rock and Roll")) | ||
|
||
|
||
## This runs through a file to generate show images. | ||
output =[] | ||
f = open('Shows.txt', 'r') | ||
for line in f: | ||
output.append(line) | ||
f.close() | ||
for i in range(0,len(output)): | ||
output[i] = output[i].rstrip('\n') | ||
for el in output: | ||
add_text(el) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
Things Can Only Get Bitter | ||
No Ducks Given | ||
Georgie and Angie's Book Corner | ||
What's That Topic? | ||
Stage | ||
Hidden Gems | ||
The Breakz Showcase | ||
Grumpy Youngish Men | ||
URY:PM - No Ducks Given | ||
York Sport Report | ||
URY:PM - Roku Radio | ||
URY:PM - URY Chart Show | ||
Grandad's Jazz | ||
URY Brunch - We're All Ears | ||
The Late Night Bass Podcast | ||
Catchy Chunes | ||
DESERT ISLAND DISCO | ||
Roger That | ||
URY Brunch: The Saturday Lie-In | ||
The Alternative Music Show | ||
The Eclectic Mix | ||
Go Funk Yourself | ||
Diggin' Deep | ||
Star Struck Jack and The Mystery Cat | ||
The Brighter Side of Life | ||
The Night Call | ||
URY Brunch - Amateur Hour | ||
Topics & Tunes | ||
InsomniHour | ||
Pardon my French | ||
Your Opinion is Wrong | ||
URY Newshour | ||
RapChat | ||
Tales from the Phantasmagoria | ||
URY:PM - Peculiarities | ||
No DLC Required | ||
These Charming Girls | ||
Retrospectre! | ||
Peck's Picks | ||
Dylan with a Mike! | ||
URY Brunch: Star-Struck Jack and the Mystery Cat | ||
(Deeper) Into the Void | ||
The Gatehouse Show | ||
Fringe: Full Metal Racket | ||
The Right Faces For Radio | ||
Toons in the Afternoons | ||
Leckie's listeners | ||
URY:PM (( URY Music )) | ||
URY Brunch - Breakfast Club | ||
Barry Tomes | ||
URY Brunch - Smile! | ||
Midweek Marauders | ||
URY Brunch - The Culture Show | ||
URY Whisper Show | ||
URY:PM with K-Spence | ||
Screen | ||
Cream Cheese | ||
#URYonTOUR: Freshers' 2016 | ||
URY:PM - Willis Weekly | ||
Almost Audible | ||
Building Bridges - The Road to Rock and Roll | ||
Indie Unearthed | ||
Gully Riddems | ||
In Between Days | ||
What's on my playlist? | ||
Castle Sessions | ||
New Music Mondays | ||
Your Weekend | ||
Kick back Sundays with Kate | ||
Formula 1 Analysis | ||
Morning Glory | ||
AM-bassador | ||
Liv and the guy |