added shit

This commit is contained in:
2022-04-16 02:40:01 +03:00
parent cb43e8f2c0
commit c5c978ed52
+16 -3
View File
@@ -34,8 +34,23 @@ class Meme:
if not attachments or attachments.get('video') is None: if not attachments or attachments.get('video') is None:
return None return None
return random.choice(attachments.get('video')) return random.choice(attachments.get('video'))
def dump_meta(self, path: str = None):
if not path:
path = "current_meta.json"
with open(path, 'w', encoding='utf8') as f:
f.write(json.dumps(self.meta))
@staticmethod
def info_from_json(path: str) -> str:
with open(path, 'w', encoding='utf8') as f:
data = json.loads(f.read())
return f"{'Fandom: ' if data.get('fandom') else 'Project: '} {data.get('fandom', data.get('Project'))}\n"\
f"Character(s):\n{', '.join(c for c in data.get('characters'))}\n"
@staticmethod @staticmethod
def flatten_meta(meta: dict[str, any]) -> list[str]: def flatten_meta(meta: dict[str, any]) -> list[str]:
return [a for k in [i for i in meta.values()] for a in k] return [a for k in [i for i in meta.values()] for a in k]
@@ -64,8 +79,6 @@ class DayOfTheWeek:
return self.days[DAYS.index(day)] return self.days[DAYS.index(day)]
else: else:
return self.days[day] return self.days[day]
@staticmethod @staticmethod
def get_data() -> list[Day]: def get_data() -> list[Day]: