Abhinav commited on
Commit
9cd8136
·
unverified ·
1 Parent(s): b704a9b

feat: Support backgrounds

Browse files
Files changed (3) hide show
  1. pages/Backgrounds.py +44 -0
  2. utils/models.py +25 -0
  3. utils/wolvesville.py +9 -0
pages/Backgrounds.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from utils.wolvesville import Wolvesville
3
+ from utils.models import Backgrounds
4
+ from utils.helper import getTitle
5
+ from typing import List
6
+
7
+ api = Wolvesville()
8
+
9
+ screens: List[Backgrounds] = api.getBackgrounds()
10
+
11
+ st.markdown(getTitle("Backgrounds"), unsafe_allow_html=True)
12
+
13
+
14
+ for screen in screens[:5]:
15
+ rarity = screen.rarity.title()
16
+ st.header(rarity)
17
+ dayCols = st.columns(3)
18
+ dayCols[0].markdown(
19
+ f'<img src="{screen.imageDay.url}" style="height:75%; width:75%;"/>',
20
+ unsafe_allow_html=True,
21
+ )
22
+ dayCols[1].markdown(
23
+ f'<img src="{screen.imageDaySmall.url}" style="height:75%; width:75%;"/>',
24
+ unsafe_allow_html=True,
25
+ )
26
+ dayCols[2].markdown(
27
+ f'<img src="{screen.imageDayWide.url}" style="height:75%; width:75%;"/>',
28
+ unsafe_allow_html=True,
29
+ )
30
+
31
+ nightCols = st.columns(3)
32
+ nightCols[0].markdown(
33
+ f'<img src="{screen.imageNight.url}" style="height:75%; width:75%;"/>',
34
+ unsafe_allow_html=True,
35
+ )
36
+ nightCols[1].markdown(
37
+ f'<img src="{screen.imageNightSmall.url}" style="height:75%; width:75%;"/>',
38
+ unsafe_allow_html=True,
39
+ )
40
+ nightCols[2].markdown(
41
+ f'<img src="{screen.imageNightWide.url}" style="height:75%; width:75%;"/>',
42
+ unsafe_allow_html=True,
43
+ )
44
+ st.divider()
utils/models.py CHANGED
@@ -201,3 +201,28 @@ def _getProfileIconObjects(profile_icons: List[Dict[str, Union[str, Dict]]]):
201
  print(e)
202
  print(icon)
203
  return profileIconList
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
201
  print(e)
202
  print(icon)
203
  return profileIconList
204
+
205
+ def getUrl(text: str):
206
+ return text.split("'")[1]
207
+
208
+ class Backgrounds(BaseModel):
209
+ id: str
210
+ rarity: str
211
+ imageNight: Image
212
+ imageNightWide: Image
213
+ imageNightSmall: Image
214
+ imageDay: Image
215
+ imageDayWide: Image
216
+ imageDaySmall: Image
217
+
218
+
219
+ def _getBackgroundObjects(backgrounds: List[Dict[str, Union[str, Dict]]]):
220
+ backgroundList = []
221
+ for icon in backgrounds:
222
+ try:
223
+ entry = Backgrounds(**icon)
224
+ backgroundList.append(entry)
225
+ except Exception as e:
226
+ print(e)
227
+ print(icon)
228
+ return backgroundList
utils/wolvesville.py CHANGED
@@ -10,6 +10,7 @@ from utils.models import (
10
  _mapEmojiCollections,
11
  _getAvatarItemSetObjects,
12
  _mapItemItemSets,
 
13
  )
14
  from dotenv import load_dotenv
15
  from os import getenv
@@ -80,6 +81,14 @@ class Wolvesville:
80
  ).json()
81
  resp = _getScreenObjects(screens=screens)
82
  return resp
 
 
 
 
 
 
 
 
83
 
84
  @lru_cache(maxsize=None)
85
  def getItems(self):
 
10
  _mapEmojiCollections,
11
  _getAvatarItemSetObjects,
12
  _mapItemItemSets,
13
+ _getBackgroundObjects
14
  )
15
  from dotenv import load_dotenv
16
  from os import getenv
 
81
  ).json()
82
  resp = _getScreenObjects(screens=screens)
83
  return resp
84
+
85
+ @lru_cache(maxsize=None)
86
+ def getBackgrounds(self):
87
+ backgrounds = requests.get(
88
+ f"{self.url}/items/backgrounds", headers=self.headers
89
+ ).json()
90
+ resp = _getBackgroundObjects(backgrounds=backgrounds)
91
+ return resp
92
 
93
  @lru_cache(maxsize=None)
94
  def getItems(self):