Files
parentzone_downloader/__pycache__/config_snapshot_downloader.cpython-313.pyc

101 lines
12 KiB
Plaintext
Raw Normal View History

2025-10-07 14:52:04 +01:00
<EFBFBD>
nN<6E>h<EFBFBD>$<00><00><><00>SrSSKrSSKrSSKrSSKrSSKrSSKJrJr SSKJ r SSK
J r "SS 5rS
rS r\S :Xa\"\"55 gg!\ a \ "S5 \"S5 N=f=f) z<>
Configuration-based Snapshot Downloader for ParentZone
This script reads configuration from a JSON file and downloads snapshots (daily events)
from the ParentZone API with pagination support, generating a comprehensive HTML report.
<EFBFBD>N)<02>datetime<6D> timedelta)<01>Path)<01>SnapshotDownloaderzRError: snapshot_downloader.py not found. Please ensure it's in the same directory.<2E>c<00>N<00>\rSrSrS\4SjrS\S\4SjrSrS\ 4Sjr
Sr S r g
) <0B>ConfigSnapshotDownloader<65><00> config_filec <00>r<00>URU5UlUR5 [URR SS5URR SS5URR S5URR S5URR S5S9Ulg )
z|
Initialize the downloader with configuration from a JSON file.
Args:
config_file: Path to the JSON configuration file
<EFBFBD>api_url<72>https://api.parentzone.me<6D>
output_dir<EFBFBD> snapshots<74>api_key<65>email<69>password)r rrrrN)<06> load_config<69>config<69> setup_loggingr<00>get<65>
downloader)<02>selfr s <20>O/Users/tudorsitaru/projects/parentzone_downloader/config_snapshot_downloader.py<70>__init__<5F>!ConfigSnapshotDownloader.__init__s<><00><00><1B>&<26>&<26>{<7B>3<><04> <0B> <0C><1A><1A><1C>-<2D><18>K<EFBFBD>K<EFBFBD>O<EFBFBD>O<EFBFBD>I<EFBFBD>/J<>K<><1B>{<7B>{<7B><EFBFBD><EFBFBD>|<7C>[<5B>A<><18>K<EFBFBD>K<EFBFBD>O<EFBFBD>O<EFBFBD>I<EFBFBD>.<2E><16>+<2B>+<2B>/<2F>/<2F>'<27>*<2A><19>[<5B>[<5B>_<EFBFBD>_<EFBFBD>Z<EFBFBD>0<> 
<EFBFBD><04><0F><00>returnc<00>,<00>[US5n[R"U5nSSS5 SW;=(a USnSU;=(a SU;=(a US=(a USnU(dU(d [S5eUR SS5 UR S S
5 UR S S /5 UR S S5 SU;d
US(d1[
R "5[SS9-
RS5US'SU;d
US(d'[
R "5RS5US'U$!,(df  GN%=f![a [SU35e[Ran[SU35eSnAff=f)z"Load configuration from JSON file.<2E>rNrrrzJEither 'api_key' or both 'email' and 'password' must be provided in configr rrr<00>type_ids<64><00> max_pages<65> date_fromim)<01>daysz%Y-%m-%d<>date_tozConfiguration file not found: z$Invalid JSON in configuration file: ) <0B>open<65>json<6F>load<61>
ValueError<EFBFBD>
setdefaultr<00>nowr<00>strftime<6D>FileNotFoundError<6F>JSONDecodeError)rr <00>fr<00> has_api_key<65>has_credentials<6C>es rr<00>$ConfigSnapshotDownloader.load_config-ss<00><00> I<01><15>k<EFBFBD>3<EFBFBD>'<27>1<EFBFBD><1D><19><19>1<EFBFBD><1C><06>(<28>$<24>v<EFBFBD>-<2D>C<>&<26><19>2C<32>K<EFBFBD>%<25><16>/<2F>s<>J<EFBFBD>&<26>4H<34>s<>V<EFBFBD>T[<5B>_<EFBFBD>s<>ag<61>hr<68>as<61>O<EFBFBD><1E><EFBFBD> <20>!m<>n<>n<> <13> <1D> <1D>i<EFBFBD>)D<> E<> <12> <1D> <1D>l<EFBFBD>K<EFBFBD> 8<> <12> <1D> <1D>j<EFBFBD>2<EFBFBD>$<24> /<2F> <12> <1D> <1D>k<EFBFBD>4<EFBFBD> 0<><1B>&<26>(<28><06>{<7B>0C<30>'/<2F>|<7C>|<7C>~<7E> <09>s<EFBFBD>8K<38>'K<>&U<>&U<>V`<60>&a<><06>{<7B>#<23><18><06>&<26>f<EFBFBD>Y<EFBFBD>.?<3F>$,<2C>L<EFBFBD>L<EFBFBD>N<EFBFBD>$;<3B>$;<3B>J<EFBFBD>$G<><06>y<EFBFBD>!<21><19>M<EFBFBD>/(<28>'<27><>2!<21> T<01>#<23>&D<>[<5B>M<EFBFBD>$R<>S<> S<><13>#<23>#<23> I<01><1C>C<>A<EFBFBD>3<EFBFBD>G<>H<> H<><48> I<01>s.<00> E<00>E<03>DE<00>
E<07> E<00>+F<03>F<03>Fc<00>4<00>[URS5nURSS9 US- n[R"[R
S[R "U5[R"5/S9 [R"[5Ul
g)zSetup logging configuration.rT)<01>exist_okz snapshots.logz)%(asctime)s - %(levelname)s - %(message)s)<03>level<65>format<61>handlersN) rr<00>mkdir<69>logging<6E> basicConfig<69>INFO<46> FileHandler<65> StreamHandler<65> getLogger<65>__name__<5F>logger)rr<00>log_files rr<00>&ConfigSnapshotDownloader.setup_loggingNs{<00><00><19>$<24>+<2B>+<2B>l<EFBFBD>3<>4<>
<EFBFBD><12><18><18>$<24><18>'<27><1D><0F>/<2F><08><0F><1B><1B><19>,<2C>,<2C>><3E><17>#<23>#<23>H<EFBFBD>-<2D><17>%<25>%<25>'<27><0E>
<EFBFBD><1E>'<27>'<27><08>1<><04> rc<00><00>,# <00>URRS5 URRSURSSURS35 URRSURS35 URRSURS 35 URRS
5(a+URRS URS
35 URR URSURSURSURRS
5S 9IS hv<01>N nU$N![ a$nURRSU35 eS nAff=f7f)zd
Download snapshots using the configuration settings.
Returns:
Path to the generated HTML file
z-Starting snapshot download with configurationz Date range: r$z to r&<00>
Type IDs: r!zOutput directory: rr#zMax pages limit: )r!r$r&r#Nz Error during snapshot download: )rB<00>inforrr<00>download_snapshots<74> Exception<6F>error)r<00> html_filer3s rrH<00>+ConfigSnapshotDownloader.download_snapshots^s_<00><00><00> <0A> <0B> <0B><18><18>H<>I<> <0C> <0B> <0B><18><18><<3C><04> <0B> <0B>K<EFBFBD>(@<40>'A<><14>d<EFBFBD>k<EFBFBD>k<EFBFBD>R[<5B>F\<5C>E]<5D>^<5E>_<> <0C> <0B> <0B><18><18>:<3A>d<EFBFBD>k<EFBFBD>k<EFBFBD>*<2A>&=<3D>%><3E>?<3F>@<40> <0C> <0B> <0B><18><18>-<2D>d<EFBFBD>k<EFBFBD>k<EFBFBD>,<2C>.G<>-H<>I<>J<> <0F>;<3B>;<3B>?<3F>?<3F>;<3B> '<27> '<27> <10>K<EFBFBD>K<EFBFBD> <1C> <1C>0<><14><1B><1B>[<5B>1I<31>0J<30>K<> L<> <12>"<22>o<EFBFBD>o<EFBFBD>@<40>@<40><1D><1B><1B>Z<EFBFBD>0<><1E>+<2B>+<2B>k<EFBFBD>2<><1C> <0B> <0B>I<EFBFBD>.<2E><1E>+<2B>+<2B>/<2F>/<2F>+<2B>6<> A<01><0E><0E>I<EFBFBD><1D> <1C><0E><><19> <12> <10>K<EFBFBD>K<EFBFBD> <1D> <1D> @<40><11><03>D<> E<> <11><> <12>s=<00>C8F<01>;AE#<00>E!<04>E#<00> F<01>!E#<00>#
F<03>-F <03> F<03>Fc<00>D<00>[S5 [S5 [S5 [SURS35 [SURS35 [SURS35 [S URS
35 [S URS 35 URRS 5(aSOSn[SU35 URRS5(a[SURS35 [S5 g)z-Print a summary of the current configuration.<2E><============================================================z!SNAPSHOT DOWNLOADER CONFIGURATIONz API URL: r zOutput Directory: rz Date From: r$z Date To: r&rFr!rzAPI KeyzEmail/PasswordzAuthentication: r#z Max Pages: N)<03>printrr)r<00> auth_methods r<00>print_config_summary<72>-ConfigSnapshotDownloader.print_config_summary{s<><00><00> <0A>h<EFBFBD><0F> <0A>1<>2<> <0A>h<EFBFBD><0F> <0A> <09>$<24>+<2B>+<2B>i<EFBFBD>0<>1<>2<>3<> <0A>"<22>4<EFBFBD>;<3B>;<3B>|<7C>#<<3C>"=<3D>><3E>?<3F> <0A> <0B>D<EFBFBD>K<EFBFBD>K<EFBFBD> <0B>4<>5<>6<>7<> <0A> <09>$<24>+<2B>+<2B>i<EFBFBD>0<>1<>2<>3<> <0A>
<EFBFBD>4<EFBFBD>;<3B>;<3B>z<EFBFBD>2<>3<>4<>5<>#'<27>;<3B>;<3B>?<3F>?<3F>9<EFBFBD>#=<3D>#=<3D>i<EFBFBD>CS<43> <0B> <0A> <20><1B> <0A>.<2E>/<2F> <0F>;<3B>;<3B>?<3F>?<3F>;<3B> '<27> '<27> <11>K<EFBFBD><04> <0B> <0B>K<EFBFBD> 8<>9<>:<3A> ;<3B> <0A>h<EFBFBD>r)rrrBN) rA<00>
__module__<EFBFBD> __qualname__<5F>__firstlineno__<5F>strr<00>dictrrrrHrQ<00>__static_attributes__<5F>rrr r s;<00><00>
<EFBFBD>C<EFBFBD>
<EFBFBD>&I<01>s<EFBFBD>I<01>t<EFBFBD>I<01>B2<> <12>$<24><12>:rr c
<00><><00>SSS/SS[SSSS . n[S
5n[US 5n[R"XS S 9 SSS5 [ SU35 [ S5 U$!,(df  N)=f)z%Create an example configuration file.rz ./snapshotsr"z
2024-01-01z
2024-12-31zyour-api-key-herezyour-email@example.comzyour-password-here) r rr!r$r&r#rrrzsnapshot_config_example.json<6F>w<>)<01>indentNu#✅ Example configuration created: u5📝 Edit the file with your credentials and settings)<06>nullrr'r(<00>dumprO)<03>example_configr r0s r<00>create_example_configra<00>s~<00><00>/<2F>#<23><17>D<EFBFBD>!<21><1F><19>&<26>)<29>(<28>
<06>N<EFBFBD><17>5<>6<>K<EFBFBD> <0A>k<EFBFBD>3<EFBFBD> <1F>1<EFBFBD> <0C> <09> <09>.<2E>A<EFBFBD>.<2E>
<20>
<EFBFBD> /<2F> <0B>}<7D>
=<3D>><3E> <09>
A<EFBFBD>B<> <16><16>
<20> <1F>s <00>A"<03>"
A0c<00>d<00>[R"S[RSS9nURSSS9 URSSS S
9 URS SS S
9 UR 5nUR
(a [ 5 g UR(d[S5 [S5 g[UR5nUR(aUR5 [5 [R"UR55nU(a}[S5 [S5 [S5 [SU35 [S5 [S5 [S5 [S5 [S5 [S5 [S5 g [S5 [S5 g ![a [S5 g[ a#n[SU35 [S5 SnAgSnAf["an[S U35 SnAgSnAf[$an[S!U35 SnAgSnAff=f)"Nz6Download ParentZone snapshots using configuration filear
Examples:
# Use existing config file
python3 config_snapshot_downloader.py --config snapshot_config.json
# Create example config file
python3 config_snapshot_downloader.py --create-example
# Show config summary before downloading
python3 config_snapshot_downloader.py --config snapshot_config.json --show-config
Configuration file format:
{
"api_url": "https://api.parentzone.me",
"output_dir": "./snapshots",
"type_ids": [15],
"date_from": "2024-01-01",
"date_to": "2024-12-31",
"max_pages": null,
"api_key": "your-api-key-here",
"email": "your-email@example.com",
"password": "your-password-here"
}
Notes:
- Either 'api_key' OR both 'email' and 'password' are required
- 'date_from' and 'date_to' default to last year if not specified
- 'type_ids' defaults to [15] (snapshot type)
- 'max_pages' limits pages fetched (useful for testing)
)<03> description<6F>formatter_class<73>epilogz--configz#Path to the JSON configuration file)<01>helpz--create-example<6C>
store_truez-Create an example configuration file and exit)<02>actionrfz --show-configz-Show configuration summary before downloadingrz>Error: --config argument is required (or use --create-example)z$Run with --help for more informationrz=
============================================================u ✅ SUCCESS!rNu📄 HTML Report: u8📁 Open the file in your browser to view the snapshotsu🎯 The report includes:u3 • All snapshots with descriptions and metadatau& • Images and attachments (if any)u( • Search and filtering capabilitiesu' • Interactive collapsible sectionsu7⚠️ No snapshots were found for the specified periodu7💡 Try adjusting the date range in your configurationu$
⚠️ Download interrupted by useru❌ Configuration file error: u0💡 Use --create-example to generate a templateu❌ Configuration error: u❌ Download failed: )<13>argparse<73>ArgumentParser<65>RawDescriptionHelpFormatter<65> add_argument<6E>
parse_args<EFBFBD>create_examplerarrOr <00> show_configrQ<00>asyncio<69>runrH<00>KeyboardInterruptr.r*rI)<05>parser<65>argsrrKr3s r<00>mainru<00>s<00><00> <15> $<24> $<24>L<> <20><<3C><<3C> <0C>!<06>F<EFBFBD>F <0B><17><17><12> 2<><18><06>
 <0B><17><17><1A><1B> <<3C><18><06>  <0B><17><17><17><1B> <<3C><18><06> <12> <1C> <1C> <1E>D<EFBFBD> <0C><1A><1A><1D><1F><10> <10>;<3B>;<3B> <0A>N<>O<> <0A>4<>5<><10>(<11>-<2D>d<EFBFBD>k<EFBFBD>k<EFBFBD>:<3A>
<EFBFBD> <10> <1B> <1B> <16> +<2B> +<2B> -<2D> <11>G<EFBFBD><1C>K<EFBFBD>K<EFBFBD>
<EFBFBD> =<3D> =<3D> ?<3F>@<40> <09> <14> <11>/<2F> "<22> <11>.<2E> !<21> <11>(<28>O<EFBFBD> <11>&<26>y<EFBFBD>k<EFBFBD>2<> 3<> <11>L<> N<> <11>-<2D> .<2E> <11>G<> H<> <11>:<3A> ;<3B> <11><<3C> =<3D> <11>;<3B> <<3C> <11>(<28>O<EFBFBD>& <0A># <12>K<> L<> <11>K<> L<> <0A><> <1D><11> <0A>5<>6<><10> <1C><11> <0A>.<2E>q<EFBFBD>c<EFBFBD>2<>3<> <0A>@<40>A<><10><> <15><11> <0A>)<29>!<21><13>-<2D>.<2E><10><> <14><11> <0A>%<25>a<EFBFBD>S<EFBFBD>)<29>*<2A><10><><11>s=<00>,C'F,<00>F,<00>,H/<03> H/<03> G*<03>* H/<03>7H
<03>
H/<03>H*<03>*H/<03>__main__)<13>__doc__rirpr(r;<00>osrr<00>pathlibr<00>snapshot_downloaderr<00> ImportErrorrO<00>exitr rarurArYrr<00><module>r}s|<00><01><04><10><0E> <0B><0E> <09>(<28><18> <0C>6<> s<18>s<18>l<17>.l <0A>^ <0C>z<EFBFBD><19><08><14><16>L<EFBFBD><1A><>C<13> <0C> <09>
^<5E>_<><08><11>G<EFBFBD> <0C>s<00>A<00>A*<03>)A*