You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This library allows you to interact with `.zim` files via Python.
12
12
13
-
It just provides a shallow Python interface on top of the `libzim` C++ library (maintained by [OpenZIM](https://github.com/openzim)). The versions are pinned between the two packages (`python-libzim==6.1.1 <=> libzim==6.1.1`).
13
+
It just provides a shallow Python interface on top of the `libzim` C++ library (maintained by [OpenZIM](https://github.com/openzim)).
14
14
15
15
It is primarily used by [`sotoki`](https://github.com/openzim/sotoki).
16
16
17
17
## Quickstart
18
18
19
+
### Reader API
20
+
19
21
```python3
20
-
# Writer API
21
-
from libzim import ZimCreator, ZimArticle, ZimBlob, ...
22
+
from libzim.reader import File
22
23
23
-
with zimcreator('test.zim') as zc:
24
-
zc.add_article(ZimArticle(...))
24
+
f = File("test.zim")
25
+
article = f.get_article("article/url.html")
26
+
print(article.url, article.title)
27
+
ifnot article.is_redirect():
28
+
print(article.content)
25
29
```
26
30
27
-
```python3
28
-
# Reader API (coming soon...)
29
-
from libzim import zimreader
31
+
### Write API
32
+
33
+
See [example](examples/basic_writer.py) for a basic usage of the writer API.
@@ -40,30 +40,29 @@ with zimreader('test.zim') as zr:
40
40
### Setup: Ubuntu/Debian `x86_64` (Recommended)
41
41
42
42
Install the python `libzim` package from PyPI.
43
+
43
44
```bash
44
45
pip3 install libzim
45
-
python -c "from libzim import ZimArticle"
46
46
```
47
47
48
48
The `x86_64` linux wheel automatically includes the `libzim.so` dylib and headers, but other platforms may need to install `libzim` and its headers manually.
49
49
50
-
#### Installing the `libzim` dylib and headers manually
50
+
51
+
### Installing the `libzim` dylib and headers manually
52
+
53
+
If you are not on a linux `x86_64` platform, you will have to install libzim manually.
54
+
55
+
Either by get a prebuilt binary at https://download.openzim.org/release/libzim
56
+
or [compile `libzim` from source](https://github.com/openzim/libzim).
57
+
58
+
If you have not installed libzim in standard directory, you will have to set `LD_LIBRARY_PATH` to allow python to find the library :
59
+
60
+
Assuming you have extracted (or installed) the library if LIBZIM_DIR:
61
+
51
62
52
63
```bash
53
-
# Install the `libzim` dylib and headers from a pre-built release
If a pre-built release is not available for your platform, you can also [install `libzim` from source](https://github.com/openzim/libzim#dependencies).
66
-
67
66
68
67
## Setup: Docker (Optional)
69
68
@@ -75,7 +74,7 @@ docker run -it openzim:python-libzim ./some_example_script.py
75
74
76
75
# Or use the python repl interactively
77
76
docker run -it openzim:python-libzim
78
-
>>> from libzim import ZimCreator, ZimArticle, ZimBlob
0 commit comments