From 228ae9bdf05213c1de220e0c14fb0999a26d6115 Mon Sep 17 00:00:00 2001 From: Justin Date: Thu, 17 Aug 2023 13:12:38 +0800 Subject: [PATCH] rplace added --- stockTicker.py | 50 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 3 deletions(-) diff --git a/stockTicker.py b/stockTicker.py index 8b8f41d..178b0c7 100755 --- a/stockTicker.py +++ b/stockTicker.py @@ -67,7 +67,7 @@ class StockTicker(): self.points = True # display crypto change in points or percent self.functions = {'Stocks': self.getStockImage, 'Crypto': self.getCryptoImage, 'Forex': self.getForexImage, 'Sector Performance': self.getSectorImage, - 'Daily Forecast':self.getDailyWeatherImage, 'Current Weather': self.getTodayWeatherImage, 'Jokes': self.getJokesImage, + 'Daily Forecast':self.getDailyWeatherImage, 'Current Weather': self.getTodayWeatherImage, 'Jokes': self.getJokesImage, 'r/place (Reddit)': self.getPlaceImage, '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'), 'News':self.getNewsImage, 'Custom Messages': self.getUserMessages, 'Commodities': self.getCommoditiesImage, 'Indices': self.getIndicesImage, 'Movies': self.getMoviesImage, 'Gainers, Losers, Active': self.getMarketImage, @@ -86,7 +86,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'} + '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', 'r/place (Reddit)':'csv/place_settings.json'} def openImage(self, image_file): @@ -296,7 +296,7 @@ class StockTicker(): for option in options: - if option not in ['Custom GIFs', 'Custom Images', 'Custom Messages']: # these images are already saved in user uploads, dodnt need to update them + if option not in ['Custom GIFs', 'Custom Images', 'Custom Messages', 'r/place (Reddit)']: # these images are already saved in user uploads, dodnt need to update them img = self.functions[option]() img.save('./display_images/'+ option+ '.ppm') @@ -359,6 +359,9 @@ class StockTicker(): if options[i % len(options)] == 'Custom Images': images = self.getUserImages() + + elif options[i % len(options)] == 'r/place (Reddit)': + images = self.getPlaceImage() elif options[i % len(options)] == 'Custom GIFs': images = self.getUserGIFs() @@ -5589,7 +5592,44 @@ class StockTicker(): return GIFs + + + def getPlaceImage(self): + f = open('csv/place_settings.json', 'r') + all_settings = json.load(f) + f.close() + + imgs = [] + + for place in all_settings['places']: + if "2017" in place: + try: + img = self.openImage('logos/r_place/r_place 2017.png') + except: + pass + elif "2022" in place: + try: + img = self.openImage('logos/r_place/r_place 2022.png') + except: + pass + elif "2023" in place: + try: + img = self.openImage('logos/r_place/r_place 2023.png') + except: + pass + try: + max_x = img.width - int(all_settings['width']) + max_y = img.height - 32 + x = random.randint(0, max_x) + y = random.randint(0, max_y) + snapshot = img.crop((x, y, x + snapshot_width, y + snapshot_height)) + imgs.append(snapshot) + except: + pass + + return imgs + def getMoviesImage(self): @@ -7183,6 +7223,10 @@ class StockTicker(): elif msg == 'I': # image self.scrollFunctionsAnimated(['display_image', 'display_image'], animation = 'traditional') + + elif msg == 'RP': # image + + self.scrollFunctionsAnimated(['place', 'place'], animation = 'traditional') elif msg == 'G': # gif