Ao3 Mirror Online
with open(work_path / 'metadata.json', 'r', encoding='utf-8') as f: metadata = json.load(f)
class AO3Mirror: def (self, cache_dir: str = "ao3_cache"): self.cache_dir = Path(cache_dir) self.cache_dir.mkdir(exist_ok=True) self.work_dir = self.cache_dir / "works" self.work_dir.mkdir(exist_ok=True) ao3 mirror
return jsonify(works) @app.route('/api/read/<work_id>', methods=['GET']) def read_work(work_id): work_path = mirror.work_dir / work_id with open(work_path / 'metadata
def _extract_work_id(self, url: str) -> str: """Extract work ID from AO3 URL""" import re match = re.search(r'/works/(\d+)', url) if match: return match.group(1) raise ValueError("Invalid AO3 work URL") with open(work_path / 'metadata.json'

