Skip to main content

Ao3 Mirror – Trusted

return jsonify(works) @app.route('/api/read/<work_id>', methods=['GET']) def read_work(work_id): work_path = mirror.work_dir / work_id

@app.route('/api/mirror', methods=['POST']) def mirror_endpoint(): data = request.json url = data.get('url') mirror_type = data.get('type', 'work') format = data.get('format', 'html') ao3 mirror

def _is_mirrored(self, work_id: str) -> bool: """Check if work is already mirrored""" return (self.work_dir / work_id / "metadata.json").exists() return jsonify(works) @app

if format == 'epub': file_path = work_path / 'work.epub' mime_type = 'application/epub+zip' elif format == 'txt': file_path = work_path / 'work.txt' mime_type = 'text/plain' else: file_path = work_path / 'work.html' mime_type = 'text/html' return jsonify(works) @app.route('/api/read/&lt

for work_path in work_dir.iterdir(): if work_path.is_dir(): metadata_file = work_path / 'metadata.json' if metadata_file.exists(): with open(metadata_file, 'r', encoding='utf-8') as f: metadata = json.load(f) works.append({ 'work_id': metadata['work_id'], 'title': metadata['title'], 'author': metadata['author'], 'word_count': metadata['word_count'], 'chapters': metadata['chapters'], 'kudos': metadata['kudos'] })