From c3b8aac622db9abf376e18fe7a1de29581306b9b Mon Sep 17 00:00:00 2001 From: Justin Date: Thu, 17 Aug 2023 18:48:42 +0800 Subject: [PATCH] place prof added --- stockTicker.py | 104 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 102 insertions(+), 2 deletions(-) diff --git a/stockTicker.py b/stockTicker.py index 9def5a3..692de6c 100755 --- a/stockTicker.py +++ b/stockTicker.py @@ -74,7 +74,7 @@ class StockTicker(): 'News':self.getNewsImage, 'Custom Messages': self.getUserMessages, 'Commodities': self.getCommoditiesImage, 'Indices': self.getIndicesImage, 'Movies': self.getMoviesImage, 'Gainers, Losers, Active': self.getMarketImage, 'Economic Calendar': self.getEconomicImage, 'IPO Calendar':self.getIpoImage, 'IPO Calendar Prof':self.getIpoProfessional, 'Economic Calendar Prof': self.getEconomicProfessional, 'Gainers, Losers, Active Prof': self.getMarketProfessional, - 'Stocks Prof': self.getStockProfessional, 'Crypto Prof': self.getCryptoProfessional, 'Forex Prof': self.getForexProfessional, 'Jokes Prof': self.getJokesProfessional, + 'Stocks Prof': self.getStockProfessional, 'Crypto Prof': self.getCryptoProfessional, 'Forex Prof': self.getForexProfessional, 'Jokes Prof': self.getJokesProfessional, 'Place (Reddit) Prof': self.getPlaceImageProfessional, 'Current Weather Prof': self.getTodayWeatherProfessional, 'News Prof':self.getNewsProfessional, 'Commodities Prof':self.getCommoditiesProfessional, 'Indices Prof': self.getIndicesProfessional, 'Sector Performance Prof': self.getSectorProfessional, '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, 'Movies Prof': self.getMoviesProfessional, 'Sports (Live Games) Prof': lambda : self.getLeagueProfessional('NBA', 'live')} @@ -87,7 +87,7 @@ class StockTicker(): 'Stocks Prof': 'csv/stocks_settings.json', 'Crypto Prof': 'csv/crypto_settings.json', 'Forex Prof': 'csv/forex_settings.json', 'Jokes Prof': 'csv/jokes_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', 'Movies Prof': 'csv/movie_settings.json', 'Sports (Live Games) Prof': 'csv/live_games.json', 'IPO Calendar Prof': 'csv/ipo_settings.json', 'Economic Calendar Prof': 'csv/economic_settings.json', - 'Gainers, Losers, Active':'csv/market_settings.json', 'Gainers, Losers, Active Prof':'csv/market_settings.json', 'Sector Performance':'csv/sector_settings.json', 'Sector Performance Prof':'csv/sector_settings.json', 'Place (Reddit)':'csv/place_settings.json'} + 'Gainers, Losers, Active':'csv/market_settings.json', 'Gainers, Losers, Active Prof':'csv/market_settings.json', 'Sector Performance':'csv/sector_settings.json', 'Sector Performance Prof':'csv/sector_settings.json', 'Place (Reddit)':'csv/place_settings.json', 'Place (Reddit) Prof':'csv/place_settings.json'} def openImage(self, image_file): @@ -5663,6 +5663,103 @@ class StockTicker(): return imgs + def getPlaceImageProfessional(self): + + f = open('csv/place_settings.json', 'r') + all_settings = json.load(f) + f.close() + + imgs = [] + feature_title = False + + for i,place in enumerate(all_settings['places']): + if (i == len(all_settings['places'])-1): + if "2017" in place: + try: + img = self.openImage('logos/r_place/r_place 2017.png') + if all_settings['title']: + feature_title = self.openImage('feature_titles/small_feature_titles/place2017.png') + except: + pass + elif "2022" in place: + try: + img = self.openImage('logos/r_place/r_place 2022.png') + if all_settings['title']: + feature_title = self.openImage('feature_titles/small_feature_titles/place2022.png') + except: + pass + elif "2023" in place: + try: + img = self.openImage('logos/r_place/r_place 2023.png') + if all_settings['title']: + feature_title = self.openImage('feature_titles/small_feature_titles/place2023.png') + except: + pass + try: + max_x = img.width - int(all_settings['width']) + max_y = img.height - 16 + x = random.randint(0, max_x) + y = random.randint(0, max_y) + snapshot = Image.new('RGB', (int(all_settings['width']) + 5, 32)) + snapshot2 = img.crop((x, y, x + int(all_settings['width']), y + 16)) + snapshot.paste(snapshot2, (0,0)) + try: + imgs.append(self.stitchImage([feature_title,snapshot])) + except: + imgs.append(snapshot) + img.close() + try: + feature_title.close() + except: + pass + except: + pass + else: + if "2017" in place: + try: + img = self.openImage('logos/r_place/r_place 2017.png') + if all_settings['title']: + feature_title = self.openImage('feature_titles/small_feature_titles/place2017.png') + except: + pass + elif "2022" in place: + try: + img = self.openImage('logos/r_place/r_place 2022.png') + if all_settings['title']: + feature_title = self.openImage('feature_titles/small_feature_titles/place2022.png') + except: + pass + elif "2023" in place: + try: + img = self.openImage('logos/r_place/r_place 2023.png') + if all_settings['title']: + feature_title = self.openImage('feature_titles/small_feature_titles/place2023.png') + except: + pass + try: + max_x = img.width - int(all_settings['width']) + max_y = img.height - 16 + x = random.randint(0, max_x) + y = random.randint(0, max_y) + snapshot = Image.new('RGB', (int(all_settings['width']) + 130, 32)) + snapshot2 = img.crop((x, y, x + int(all_settings['width']), y + 16)) + snapshot.paste(snapshot2, (0,0)) + try: + imgs.append(self.stitchImage([feature_title,snapshot])) + except: + imgs.append(snapshot) + img.close() + try: + feature_title.close() + except: + pass + except: + pass + + return self.stitchImage(imgs) + + + def getMoviesImage(self): f = open('csv/movie_settings.json', 'r') @@ -7167,6 +7264,7 @@ class StockTicker(): jokes = self.getJokesProfessional() market = self.getMarketProfessional() sector = self.getSectorProfessional() + place = self.getPlaceImageProfessional() x_offset = 0 news.paste(weather, (x_offset, 16)) @@ -7207,6 +7305,8 @@ class StockTicker(): x_offset += market.size[0] news.paste(sector, (x_offset, 16)) x_offset += sector.size[0] + news.paste(place, (x_offset, 16)) + x_offset += place.size[0] self.double_buffer = self.matrix.CreateFrameCanvas() while True: kill = stock_ticker.scrollImage(news, offset_x = 128)