Metadata-Version: 2.4
Name: mediawiki-to-pdf
Version: 1.0
Summary: TBD
Author: Gerard
Author-email: gweatherby@uchc.edu
License: MIT
Project-URL: Homepage, https://github.com/NMRhub/mediawiki_to_pdf
Project-URL: Repository, https://github.com/NMRhub/mediawiki_to_pdf
Project-URL: Issues, https://github.com/NMRhub/mediawiki_to_pdf/issues
Project-URL: Changelog, https://github.com/NMRhub/mediawiki_to_pdf/releases
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pdfkit
Requires-Dist: pyyaml
Dynamic: license-file

# mediawiki-to-pdf 

## session
**MediaWikiSession(access_token: str, apiurl: str)** returns a requests.Session subclass that adds Mediawik authorization headers.
apiurl is typically https://example.com/api.php
*MediaWikiSession.parse_yaml(file)* is convenience method that reads access token and url from YAML file:
```
mediawiki:
  url: https://wiki.example.com/api.php
  access token: /usr/local/x/wiki_token
```
where access token is a file name.

## PDF
**save_pdf_from_authenticated_session(session: MediaWikiSession, page_title: str, output_path: str)->Path:**
Fetchs a MediaWiki page via API and convert it to PDF using pdfkit. Returns output.
/usr/bin/wkhtmlpdf must be installed.

## Command line
Processes list of pages specified in YAML file.
```
usage: mediawiki_to_pdf [-h] [-l LOGLEVEL] yaml

positional arguments:
  yaml                  Configuration file

options:
  -h, --help            show this help message and exit
  -l LOGLEVEL, --loglevel LOGLEVEL
                        Python logging level (default: WARN)
```
Example:
```
---
mediawiki:
  url: https://wiki.example.com/api.php
  access token: /usr/local/x/wiki_token
pages:
  -  First_page 
  -  Second_page 
...
```
