ó
    ~ˆjß  ã                   óz   • S r SSKrSSKJrJr  SSKJr  SS0rS\S\S-  4S	 jr	SS
/r
SS jr\S:X  a  \" 5         gg)a+  
Dependency-free manga archiver. Download all chapters of a manga from a
supported source into <archive_dir>/chapter_XXX/page_001.ext, ...

Usage:
  python3 download.py drake [manga_url]
      Drake Scans (drakecomic.org). Defaults to the original target:
      https://drakecomic.org/manga/disastrous-necromancer/

  python3 download.py mangaread manga_url
      MangaRead (mangaread.org), e.g.:
      python3 download.py mangaread           https://www.mangaread.org/manga/return-of-the-runebound-professor/

Behaviour (all sources):
  - Polite: single sequential connection, fixed delays between requests,
    longer breather every 25 images, exponential backoff, and a full stop
    if 429s persist.
  - Resumable / self-healing: re-running reconciles every chapter
    directory with the site's canonical page list (renames existing files
    to page_NNN names, downloads missing pages, removes stray files).
    Details in <archive_dir>/download_state.json.

After a download completes, run generate_html.py on the archive dir to
build the static reader pages.
é    N)ÚDrakeScansSourceÚMangaReadSource)ÚrunÚdrakez4https://drakecomic.org/manga/disastrous-necromancer/ÚnameÚurlc                 óZ  • U S:X  aB  S nU(       a.  SS K nUR                  SU5      nU(       a  UR                  S5      n[        U5      $ U S:X  a.  U(       d  [        R
                  " S[        -   5        [        5       $ [        R
                  " SU  SS	R                  [        5       35        g )
Nr   r   z/manga/([^/]+)/?$é   Ú	mangareadz mangaread requires a manga URL.
zUnknown source 'z'. Supported: z, )
ÚreÚsearchÚgroupr   ÚsysÚexitÚ__doc__r   ÚjoinÚSOURCES)r   r   Úslugr   Úms        Ú9/home/nathan/projects/ai/drake_scans_download/download.pyÚmake_sourcer   '   sŠ   € ØˆwƒØˆÞÛØ—	‘	Ð.°Ó4ˆAÞØ—w‘w˜q“z�Ü Ó%Ð%Øˆ{ÓÞÜ�HŠHÐ8¼7ÑBÔCÜÓ Ð Ü‡H‚HÐ ˜v ^°D·I±I¼gÓ4FÐ3GÐHÕIó    r   c                  óD  • [         R                  SS  n U (       d  Su  pOEU S   n[        U 5      S:”  a  U S   OS nU(       d#  [        R	                  U5      (       a	  [        U   nU(       d   [         R
                  " U S3[        -   5        [        [        X5      U5        g )Nr
   )r   Nr   z requires a manga URL.
)	r   ÚargvÚlenÚDEFAULTSÚgetr   r   r   r   )Úargsr   r   s      r   Úmainr   :   s€   € Ü�8‰8�A�Bˆ<€DÞØ!‰	ˆˆcà�A‰wˆÜ˜T› Q›ˆd�1Šg¨DˆÞ”x—|‘| D×)Ñ)Ü˜4‘.ˆCÞÜ�Š�D�6Ð1Ð2´WÑ<Ô=ÜŒ�DÓ Õ$r   Ú__main__)ÚreturnN)r   r   Úmangar   r   Ú
manga.corer   r   Ústrr   r   r   Ú__name__© r   r   Ú<module>r'      sc   ðñó6 ç 3Ý ð ÐCð€ð
J�cð J  d¡
ô Jð  �KÐ
 €ô%ð ˆzÓÙ…Fð r   