Metadata-Version: 2.4
Name: jwlib
Version: 1.2.1
Summary: Wrapper for jw.org APIs
Author-email: allejok96 <allejok96@gmail.com>
Project-URL: Homepage, https://github.com/allejok96/jwlib
Project-URL: Documentation, https://jwlib.readthedocs.io/en/latest
Project-URL: Issues, https://github.com/allejok96/jwlib/issues
Project-URL: Changelog, https://github.com/allejok96/jwlib/blob/main/HISTORY.rst
Keywords: jw,jworg
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.8
Classifier: Topic :: Internet :: WWW/HTTP :: Indexing/Search
Classifier: Topic :: Religion
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.8
Description-Content-Type: text/x-rst
License-File: LICENSE
Provides-Extra: dev
Requires-Dist: coverage; extra == "dev"
Requires-Dist: mypy; extra == "dev"
Requires-Dist: Pillow; extra == "dev"
Requires-Dist: pytest-recording; extra == "dev"
Requires-Dist: tabulate; extra == "dev"
Provides-Extra: docs
Requires-Dist: Sphinx; extra == "docs"
Requires-Dist: sphinx_rtd_theme; extra == "docs"
Requires-Dist: watchdog; extra == "docs"
Dynamic: license-file

=====
jwlib
=====

|build| |version| |docs|

Python wrappers for a few jw.org_ APIs.

Installation
============

.. code-block:: bash

    pip install jwlib

Usage
=====

Browsing JW Broadcasting
------------------------

.. code-block:: python

    from jwlib.media import get_session

    # Print a list of language codes
    for lang in get_session().get_languages():
         print(lang.code, lang.name)

    # Select a language
    session = get_session(language='E')

    # Browse the category tree
    root = session.get_category()
    for subcategory in root.get_subcategories():
        print(subcategory.key)

    # Select a category
    category = session.get_category('LatestVideos')

    # List media items
    for media in category.get_media():
        print(media.title)
        print(media.get_file().url)

See the media_ documentation for more details.

Searching at jw.org
-------------------

.. code-block:: python

    from jwlib.search import search
    from jwlib.search.const import FILTER_VIDEO

    # Search for videos only
    page = search('Caleb', filter_type=FILTER_VIDEO, language='E')

    # Print result page info
    print(page.pagination_label)

    # Print results
    for result in page.results:
        print(result.title)
        print(result.url_jw)

    # Continue on next page
    if page.next:
        next_page = page.next.open()
        print(next_page.pagination_label)
        for result in next_page.results:
            print(result.title)
            print(result.url_jw)

See the search_ documentation for more details.

Downloading publications
------------------------

Alpha version, may be subject to change.

Listing languages
-----------------

Alpha version, may be subject to change.

Development
===========

An example on how to setup the dev environment:

.. code-block:: shell

    # Create a virtual Python environment
    python -m venv venv
    . venv/bin/activate

    # Install dependencies
    # -e keeps the installed jwlib in sync with your changes
    # [dev] installs the dependencies for testing
    # [dev,docs] if you also want to build documentation
    pip install -e '.[dev]'

    # Run the tests
    make test

    # Show more convenience functions
    make help


.. |build| image:: https://github.com/allejok96/jwlib/actions/workflows/build.yml/badge.svg
    :target: https://github.com/allejok96/jwlib/actions/workflows/build.yml
    :alt: Build Status
.. |version| image:: https://img.shields.io/pypi/v/jwlib.svg
    :target: https://pypi.python.org/pypi/jwlib
    :alt: Package Status
.. |docs| image:: https://readthedocs.org/projects/jwlib/badge/?version=latest
    :target: https://jwlib.readthedocs.io/en/latest/?version=latest
    :alt: Documentation Status

.. _jw.org: https://www.jw.org/
.. _media: https://jwlib.readthedocs.io/en/latest/jwlib.media.html
.. _search: https://jwlib.readthedocs.io/en/latest/jwlib.search.html
