#!/usr/bin/env python3 from __future__ import annotations import hashlib,json,subprocess,tarfile from pathlib import Path R=Path(__file__).resolve().parent;S=R/'source';E=R/'source_extract';V='2606.02073v1' def sha(p):return hashlib.sha256(p.read_bytes()).hexdigest() def main(): S.mkdir(parents=True,exist_ok=True);E.mkdir(parents=True,exist_ok=True);pdf=S/f'{V}.pdf';arc=S/f'{V}.tar' subprocess.run(['curl','-fsSL','--retry','3',f'https://arxiv.org/pdf/{V}','-o',str(pdf)],check=True);subprocess.run(['curl','-fsSL','--retry','3',f'https://arxiv.org/e-print/{V}','-o',str(arc)],check=True) with tarfile.open(arc,'r:*') as h: for m in h.getmembers(): d=(E/m.name).resolve() if E.resolve() not in d.parents and d!=E.resolve():raise ValueError(m.name) h.extractall(E,filter='data') print(json.dumps({'paper_id':'nbU2LNYdZN','arxiv_id':V,'pdf_sha256':sha(pdf),'source_sha256':sha(arc)},indent=2)) if __name__=='__main__':main()