# Updated database.py import json import datetime class Database: def __init__(self, base_path): self.base_path = base_path self.file_path = f'{base_path}/index.json' try: with open(self.file_path, 'r') as file: self.data = json.load(file) except FileNotFoundError: self.data = [] def add_entry(self, entry): entry['timestamp'] = datetime.datetime.now().strftime('%d/%m/%Y') self.data.append(entry) with open(self.file_path, 'w') as file: json.dump(self.data, file, indent=4) def downloadable(self, url, title): idx = url.split('https://www.youtube.com/watch?v=')[-1] for entry in self.data: if entry['id'] == idx or entry['title'] == title: return False return True