movies feature

This commit is contained in:
Justin 2023-01-09 16:16:18 +08:00 committed by GitHub
parent a803f7e2a0
commit b1eb43a563
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -68,22 +68,22 @@ class StockTicker():
'Daily Forecast':self.getDailyWeatherImage, 'Current Weather': self.getTodayWeatherImage, 'Daily Forecast':self.getDailyWeatherImage, 'Current Weather': self.getTodayWeatherImage,
'Sports (Team Stats)':lambda : self.getLeagueTableImage('premier_league'), 'Sports (Past Games)': lambda:self.getLeagueImage('NBA', 'past'), 'Sports (Team Stats)':lambda : self.getLeagueTableImage('premier_league'), 'Sports (Past Games)': lambda:self.getLeagueImage('NBA', 'past'),
'Sports (Upcoming Games)': lambda : self.getLeagueImage('NHL', 'future'), 'Sports (Live Games)': lambda: self.getLeagueImage('NBA', 'live'), 'Sports (Upcoming Games)': lambda : self.getLeagueImage('NHL', 'future'), 'Sports (Live Games)': lambda: self.getLeagueImage('NBA', 'live'),
'News':self.getNewsImage, 'Custom Messages': self.getUserMessages, 'Commodities': self.getCommoditiesImage, 'Indices': self.getIndicesImage, 'News':self.getNewsImage, 'Custom Messages': self.getUserMessages, 'Commodities': self.getCommoditiesImage, 'Indices': self.getIndicesImage, 'Movies': self.getMoviesImage,
'Stocks Prof': self.getStockProfessional, 'Crypto Prof': self.getCryptoProfessional, 'Forex Prof': self.getForexProfessional, 'Stocks Prof': self.getStockProfessional, 'Crypto Prof': self.getCryptoProfessional, 'Forex Prof': self.getForexProfessional,
'Current Weather Prof': self.getTodayWeatherProfessional, 'News Prof':self.getNewsProfessional, 'Commodities Prof':self.getCommoditiesProfessional, 'Indices Prof': self.getIndicesProfessional, 'Current Weather Prof': self.getTodayWeatherProfessional, 'News Prof':self.getNewsProfessional, 'Commodities Prof':self.getCommoditiesProfessional, 'Indices Prof': self.getIndicesProfessional,
'Daily Forecast Prof':self.getDailyWeatherProfessional, 'Sports (Team Stats) Prof':lambda : self.getLeagueTableProfessional('NHL'), 'Sports (Upcoming Games) Prof': lambda : self.getLeagueProfessional('NHL', 'future'), 'Daily Forecast Prof':self.getDailyWeatherProfessional, 'Sports (Team Stats) Prof':lambda : self.getLeagueTableProfessional('NHL'), 'Sports (Upcoming Games) Prof': lambda : self.getLeagueProfessional('NHL', 'future'),
'Sports (Past Games) Prof': lambda : self.getLeagueProfessional('NBA', 'past'), 'Custom Messages Prof': self.getUserMessagesProfessional, 'Custom Images Prof': self.getUserImagesProfessional} 'Sports (Past Games) Prof': lambda : self.getLeagueProfessional('NBA', 'past'), 'Custom Messages Prof': self.getUserMessagesProfessional, 'Custom Images Prof': self.getUserImagesProfessional, 'Movies Prof': self.getMoviesProfessional}
self.JSONs = {'Stocks': 'csv/stocks_settings.json', 'Crypto': 'csv/crypto_settings.json', 'Forex': 'csv/forex_settings.json', self.JSONs = {'Stocks': 'csv/stocks_settings.json', 'Crypto': 'csv/crypto_settings.json', 'Forex': 'csv/forex_settings.json',
'Daily Forecast':'csv/daily_weather.json', 'Current Weather': 'csv/current_weather.json', 'Commodities':'csv/commodities_settings.json', 'Indices': 'csv/indices_settings.json', 'Daily Forecast':'csv/daily_weather.json', 'Current Weather': 'csv/current_weather.json', 'Commodities':'csv/commodities_settings.json', 'Indices': 'csv/indices_settings.json',
'Sports (Team Stats)': 'csv/league_tables.json', 'Sports (Past Games)': 'csv/past_games.json', 'Sports (Team Stats)': 'csv/league_tables.json', 'Sports (Past Games)': 'csv/past_games.json',
'Sports (Upcoming Games)': 'csv/upcoming_games.json', 'Sports (Live Games)': 'csv/live_games.json', 'Sports (Upcoming Games)': 'csv/upcoming_games.json', 'Sports (Live Games)': 'csv/live_games.json', 'Movies': 'csv/movie_settings.json',
'News':'csv/news_settings.json', 'Custom Images': 'csv/image_settings.json', 'Custom GIFs': 'csv/GIF_settings.json', 'Custom Messages': 'csv/message_settings.json', 'News':'csv/news_settings.json', 'Custom Images': 'csv/image_settings.json', 'Custom GIFs': 'csv/GIF_settings.json', 'Custom Messages': 'csv/message_settings.json',
'Stocks Prof': 'csv/stocks_settings.json', 'Crypto Prof': 'csv/crypto_settings.json', 'Forex Prof': 'csv/forex_settings.json', 'Stocks Prof': 'csv/stocks_settings.json', 'Crypto Prof': 'csv/crypto_settings.json', 'Forex Prof': 'csv/forex_settings.json',
'Current Weather Prof': 'csv/current_weather.json', 'News Prof':'csv/news_settings.json', 'Commodities Prof':'csv/commodities_settings.json', 'Indices Prof': 'csv/indices_settings.json', 'Current Weather Prof': 'csv/current_weather.json', 'News Prof':'csv/news_settings.json', 'Commodities Prof':'csv/commodities_settings.json', 'Indices Prof': 'csv/indices_settings.json',
'Daily Forecast Prof':'csv/daily_weather.json', 'Sports (Team Stats) Prof': 'csv/league_tables.json', 'Sports (Upcoming Games) Prof': 'csv/upcoming_games.json', 'Sports (Past Games) Prof': 'csv/past_games.json', 'Custom Messages Prof': 'csv/message_settings.json', 'Custom Images Prof': 'csv/image_settings.json'} 'Daily Forecast Prof':'csv/daily_weather.json', 'Sports (Team Stats) Prof': 'csv/league_tables.json', 'Sports (Upcoming Games) Prof': 'csv/upcoming_games.json', 'Sports (Past Games) Prof': 'csv/past_games.json', 'Custom Messages Prof': 'csv/message_settings.json', 'Custom Images Prof': 'csv/image_settings.json', 'Movies Prof': 'csv/movie_settings.json'}
def openImage(self, image_file): def openImage(self, image_file):
@ -3529,6 +3529,140 @@ class StockTicker():
return GIFs return GIFs
def getMoviesImage(self):
f = open('csv/movie_settings.json', 'r')
all_movie_settings = json.load(f)
f.close()
if all_movie_settings['title']:
title_img = self.openImage('feature_titles/movies.png')
image_list = [title_img]
else:
image_list = []
font = ImageFont.load("./fonts/6x13.pil")
small_font = ImageFont.load("./fonts/5x8.pil")
for movie in all_movie_settings['movies']:
x_offset = 0
movie_title_img = self.textImage(movie['title'] + ' (' + movie['media_type'] + ')', font, r = 255, g = 180, b = 0)
lang_img = self.textImage('Lan:' + movie['language'], small_font, r = 255, g = 0, b = 100)
vote_img = self.textImage(movie['votes'], small_font, r = 255, g = 255, b = 255)
star_img = Image.open('logos/star.png').convert('RGB')
date_img = self.textImage(movie['date'], small_font, r = 0, g = 162, b = 255)
try:
logo = Image.open('logos/movies/' + movie['backdrop'])
logo.thumbnail((9000,32))
logo.convert('P')
except:
logo = self.textImage('No Logo', small_font, r=255, g=255, b=255)
x_offset += logo.size[0] + 3
genre_offset = 0
for genre in movie['genre']:
genre_img = self.textImage(genre + ',', small_font, r = 255, g = 255, b = 255)
genre_offset += genre_img.size[0]
img = Image.new('RGB', (max(x_offset + movie_title_img.size[0], x_offset + date_img.size[0] + 3 + star_img.size[0] + vote_img.size[0] + 3, x_offset + date_img.size[0] + 3 + genre_offset) + 15, 32))
img.paste(logo, (0, 0))
img.paste(movie_title_img, (x_offset,0))
img.paste(date_img, (x_offset, 14))
img.paste(lang_img, (x_offset, 23))
x_offset += max(date_img.size[0], lang_img.size[0]) + 3
x_offset2 = x_offset
img.paste(star_img, (x_offset2 , 14))
img.paste(vote_img, (x_offset2 + star_img.size[0] + 3, 14))
for genre in movie['genre'][:-1]:
genre_img = self.textImage(genre + ',', small_font, r = 255, g = 255, b = 255)
img.paste(genre_img, (x_offset2, 23))
x_offset2 += genre_img.size[0]
else:
genre_img2 = self.textImage(movie['genre'][-1], small_font, r = 255, g = 255, b = 255)
img.paste(genre_img2, (x_offset2, 23))
x_offset2 += genre_img2.size[0]
image_list.append(img)
return self.stitchImage(image_list)
def getMoviesProfessional(self):
f = open('csv/movie_settings.json', 'r')
all_movie_settings = json.load(f)
f.close()
if all_movie_settings['title']:
title_img = self.openImage('feature_titles/small_feature_titles/movies.png')
image_list = [title_img]
else:
image_list = []
font = ImageFont.load("./fonts/6x10.pil")
small_font = ImageFont.load("./fonts/4x6.pil")
for movie in all_movie_settings['movies']:
x_offset = 0
movie_title_img = self.textImage(movie['title'] + ' (' + movie['media_type'] + ')', font, r = 255, g = 180, b = 0)
lang_img = self.textImage('Lan:' + movie['language'], small_font, r = 255, g = 0, b = 100)
vote_img = self.textImage(movie['votes'], small_font, r = 255, g = 255, b = 255)
star_img = Image.open('logos/star.png').convert('RGB')
date_img = self.textImage(movie['date'], small_font, r = 0, g = 162, b = 255)
try:
logo = Image.open('logos/movies/' + movie['backdrop'])
logo.thumbnail((1000,16))
logo.convert('P')
except:
logo = self.textImage('No Logo', small_font, r=255, g=255, b=255)
x_offset += logo.size[0] + 3
genre_offset = 0
# img = Image.new('RGB', (200,16))
for genre in movie['genre']:
genre_img = self.textImage(genre + ',', small_font, r = 255, g = 255, b = 255)
genre_offset += genre_img.size[0]
img = Image.new('RGB', (max(x_offset + movie_title_img.size[0] + 3 + star_img.size[0] + 2 + vote_img.size[0] + 10, x_offset + date_img.size[0] + 7 + lang_img.size[0] + 7 + genre_offset + 10), 16))
img.paste(logo, (0, 0))
img.paste(movie_title_img, (x_offset,0))
x_offset2 = x_offset + movie_title_img.size[0] + 3
img.paste(star_img, (x_offset2, 1))
x_offset2 += star_img.size[0] + 2
img.paste(vote_img, (x_offset2, 2))
img.paste(date_img, (x_offset, 10))
x_offset += date_img.size[0] + 7
img.paste(lang_img, (x_offset, 10))
x_offset += lang_img.size[0] + 7
for genre in movie['genre'][:-1]:
genre_img = self.textImage(genre + ',', small_font, r = 255, g = 255, b = 255)
img.paste(genre_img, (x_offset, 10))
x_offset += genre_img.size[0]
else:
genre_img2 = self.textImage(movie['genre'][-1], small_font, r = 255, g = 255, b = 255)
img.paste(genre_img2, (x_offset, 10))
x_offset += genre_img2.size[0]
image_list.append(img)
return self.stitchImage(image_list)
def displayStocks(self): def displayStocks(self):
self.scrollImageTransition(['final.ppm', 'final.ppm'], offset_x = 0, offset_y = 0) self.scrollImageTransition(['final.ppm', 'final.ppm'], offset_x = 0, offset_y = 0)
@ -3545,6 +3679,7 @@ class StockTicker():
sports_stats = self.getLeagueTableProfessional() sports_stats = self.getLeagueTableProfessional()
sports_upcoming = self.getLeagueProfessional() sports_upcoming = self.getLeagueProfessional()
sports_past = self.getLeagueProfessional() sports_past = self.getLeagueProfessional()
movies = self.getMoviesProfessional()
messages = self.getUserMessagesProfessional() messages = self.getUserMessagesProfessional()
images = self.getUserImagesProfessional() images = self.getUserImagesProfessional()
@ -3569,6 +3704,8 @@ class StockTicker():
x_offset += sports_upcoming.size[0] x_offset += sports_upcoming.size[0]
news.paste(sports_past, (x_offset, 16)) news.paste(sports_past, (x_offset, 16))
x_offset += sports_past.size[0] x_offset += sports_past.size[0]
news.paste(movies, (x_offset, 16))
x_offset += movies.size[0]
news.paste(messages, (x_offset, 16)) news.paste(messages, (x_offset, 16))
x_offset += messages.size[0] x_offset += messages.size[0]
news.paste(images, (x_offset, 16)) news.paste(images, (x_offset, 16))
@ -3648,7 +3785,10 @@ class StockTicker():
self.scrollFunctionsAnimated(['commodities', 'commodities'],animation = 'traditional') self.scrollFunctionsAnimated(['commodities', 'commodities'],animation = 'traditional')
elif msg == 'WI': #indices elif msg == 'WI': #indices
self.scrollFunctionsAnimated(['indices', 'indices'],animation = 'traditional') self.scrollFunctionsAnimated(['indices', 'indices'],animation = 'traditional')
elif msg == 'MO': #movies
self.scrollFunctionsAnimated(['movies', 'movies'],animation = 'traditional')
elif msg == 'A': #everything elif msg == 'A': #everything