diff --git a/stockTicker.py b/stockTicker.py index 4714eaf..0e05870 100755 --- a/stockTicker.py +++ b/stockTicker.py @@ -4111,7 +4111,7 @@ class StockTicker(): return GIFs - + def getMoviesImage(self): f = open('csv/movie_settings.json', 'r') @@ -4136,7 +4136,22 @@ class StockTicker(): 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: + if movie['media_type'] == 'Movie': + if movie['budget'] == '0': + budget_img = self.textImage('$N/A', small_font, r = 255, g = 0, b = 0) + else: + budget_img = self.textImage('$' + movie['budget'], small_font, r = 255, g = 0, b = 0) + except: + pass + try: + if movie['media_type'] == 'Movie': + if movie['revenue'] == '0': + rev_img = self.textImage('$N/A', small_font, r = 0, g = 255, b = 0) + else: + rev_img = self.textImage('$' + movie['revenue'], small_font, r = 0, g = 255, b = 0) + except: + pass try: logo = Image.open('logos/movies/' + movie['backdrop']) logo.thumbnail((9000,32)) @@ -4151,7 +4166,13 @@ class StockTicker(): 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)) + try: + if movie['media_type'] == 'Movie': + 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 + 5 + budget_img.size[0] + 5 + rev_img.size[0], x_offset + date_img.size[0] + 3 + genre_offset) + 15, 32)) + else: + 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)) + except: + 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)) @@ -4162,7 +4183,17 @@ class StockTicker(): x_offset2 = x_offset img.paste(star_img, (x_offset2 , 14)) img.paste(vote_img, (x_offset2 + star_img.size[0] + 3, 14)) - + + try: + if movie['media_type'] == 'Movie': + img.paste(budget_img, (x_offset2 + star_img.size[0] + 3 + vote_img.size[0] + 5, 14)) + except: + pass + try: + if movie['media_type'] == 'Movie': + img.paste(rev_img,(x_offset2 + star_img.size[0] + 3 + vote_img.size[0] + 5 + budget_img.size[0] + 5, 14)) + except: + pass 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)) @@ -4176,7 +4207,7 @@ class StockTicker(): return self.stitchImage(image_list) - + def getMoviesProfessional(self): f = open('csv/movie_settings.json', 'r') @@ -4201,7 +4232,22 @@ class StockTicker(): 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: + if movie['media_type'] == 'Movie': + if movie['budget'] == '0': + budget_img = self.textImage('$N/A', small_font, r = 255, g = 0, b = 0) + else: + budget_img = self.textImage('$' + movie['budget'], small_font, r = 255, g = 0, b = 0) + except: + pass + try: + if movie['media_type'] == 'Movie': + if movie['revenue'] == '0': + rev_img = self.textImage('$N/A', small_font, r = 0, g = 255, b = 0) + else: + rev_img = self.textImage('$' + movie['revenue'], small_font, r = 0, g = 255, b = 0) + except: + pass try: logo = Image.open('logos/movies/' + movie['backdrop']) logo.thumbnail((1000,16)) @@ -4217,7 +4263,13 @@ class StockTicker(): 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)) + try: + if movie['media_type'] == 'Movie': + img = Image.new('RGB', (max(x_offset + movie_title_img.size[0] + 3 + star_img.size[0] + 2 + vote_img.size[0] + 10 + 3 + budget_img.size[0] + 3 + rev_img.size[0], x_offset + date_img.size[0] + 7 + lang_img.size[0] + 7 + genre_offset + 10), 16)) + else: + 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)) + except: + 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)) @@ -4225,6 +4277,18 @@ class StockTicker(): img.paste(star_img, (x_offset2, 1)) x_offset2 += star_img.size[0] + 2 img.paste(vote_img, (x_offset2, 2)) + x_offset2 += vote_img.size[0] + try: + if movie['media_type'] == 'Movie': + img.paste(budget_img, (x_offset2 + 3, 2)) + except: + pass + try: + if movie['media_type'] == 'Movie': + img.paste(rev_img,(x_offset2 + 3 + budget_img.size[0] + 3, 2)) + except: + pass + img.paste(date_img, (x_offset, 10)) x_offset += date_img.size[0] + 7 img.paste(lang_img, (x_offset, 10)) @@ -4242,8 +4306,8 @@ class StockTicker(): image_list.append(img) return self.stitchImage(image_list) - - + + def displayStocks(self):