diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..dd67d23 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +# MIT License + +Copyright (c) 2021-2024 Bendik R. Brenne + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 6e9bb5c..ac4c038 100644 --- a/README.md +++ b/README.md @@ -1,42 +1,94 @@ -# NrkPodcastAPI +# nrk-psapi -NrkPodcastAPI is a Python library for interacting with the NRK Podcast API. It provides a simple interface for retrieving podcast information and episode details. +[![GitHub Release][releases-shield]][releases] +[![Python Versions][py-versions-shield]][py-versions] +![Project Maintenance][maintenance-shield] +[![License][license-shield]](LICENSE.md) -## Installation +[![Build Status][build-shield]][build] +[![Code coverage][codecov-shield]][codecov] -To install the library, you can use pip: -``` +Asynchronous Python client for the NRK Podcast/Radio API + +## Installation + +```bash pip install nrk-psapi ``` ## Usage -Here's an example of how to use the library to retrieve information about a podcast: +The following are some basic examples of how to use the library. + +Get information about a specific podcast: ```python +import asyncio + from nrk_psapi import NrkPodcastAPI -api = NrkPodcastAPI() -podcast = api.get_podcast("podcast_id") -print(podcast.title) + +async def main(): + """Main function.""" + async with NrkPodcastAPI() as client: + podcast = await client.get_podcast(podcast_id="desken_brenner") + print(podcast) + + +if __name__ == "__main__": + asyncio.run(main()) ``` -You can also retrieve information about an episode: +Get all episodes for a specific podcast: ```python -episode = api.get_episode("podcast_id", "episode_id") -print(episode.title) +episodes = await client.get_podcast_episodes(podcast_id="desken_brenner") +for episode in episodes: + print(episode) ``` +Search for a specific podcast: + +```python +search_results = await client.search( + query="Norsk", search_type=SearchResultType.PODCAST +) +for result in search_results.hits: + print(result) +``` + +Get curated podcasts: + +```python +curated_podcasts = await client.curated_podcasts() +for section in curated_podcasts.sections: + print(section) + for podcast in section.podcasts: + print(podcast) +``` + + ## Contributing If you'd like to contribute to the project, please submit a pull request or open an issue on the GitHub repository. ## License -NrkPodcastAPI is licensed under the MIT license. See the LICENSE file for more details. +nrk-psapi is licensed under the MIT license. See the LICENSE file for more details. ## Contact If you have any questions or need assistance with the library, you can contact the project maintainer at @bendikrb. + +[license-shield]: https://img.shields.io/github/license/bendikrb/nrk-psapi.svg +[license]: https://github.com/bendikrb/nrk-psapi/blob/main/LICENSE +[releases-shield]: https://img.shields.io/pypi/v/nrk-psapi +[releases]: https://github.com/bendikrb/nrk-psapi/releases +[build-shield]: https://github.com/bendikrb/nrk-psapi/actions/workflows/test.yaml/badge.svg +[build]: https://github.com/bendikrb/nrk-psapi/actions/workflows/tests.yaml +[maintenance-shield]: https://img.shields.io/maintenance/yes/2024.svg +[py-versions-shield]: https://img.shields.io/pypi/pyversions/nrk-psapi +[py-versions]: https://pypi.org/project/nrk-psapi/ +[codecov-shield]: https://codecov.io/gh/bendikrb/nrk-psapi/graph/badge.svg?token=011O5N9MKL +[codecov]: https://codecov.io/gh/bendikrb/nrk-psapi diff --git a/poetry.lock b/poetry.lock index f7c343e..0a1b2e3 100644 --- a/poetry.lock +++ b/poetry.lock @@ -147,6 +147,21 @@ files = [ {file = "alabaster-1.0.0.tar.gz", hash = "sha256:c00dca57bca26fa62a6d7d0a9fcce65f3e026e9bfe33e9c538fd3fbb2144fd9e"}, ] +[[package]] +name = "aresponses" +version = "3.0.0" +description = "Asyncio response mocking. Similar to the responses library used for 'requests'" +optional = false +python-versions = ">=3.7" +files = [ + {file = "aresponses-3.0.0-py3-none-any.whl", hash = "sha256:8093ab4758eb4aba91c765a50295b269ecfc0a9e7c7158954760bc0c23503970"}, + {file = "aresponses-3.0.0.tar.gz", hash = "sha256:8731d0609fe4c954e21f17753dc868dca9e2e002b020a33dc9212004599b11e7"}, +] + +[package.dependencies] +aiohttp = {version = ">=3.7.0,<3.8.dev0 || >=3.9.dev0", markers = "python_version >= \"3.12\""} +pytest-asyncio = {version = ">=0.17.0", markers = "python_version >= \"3.7\""} + [[package]] name = "astroid" version = "3.2.4" @@ -345,6 +360,20 @@ files = [ {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, ] +[[package]] +name = "covdefaults" +version = "2.3.0" +description = "A coverage plugin to provide sensible default settings" +optional = false +python-versions = ">=3.7" +files = [ + {file = "covdefaults-2.3.0-py2.py3-none-any.whl", hash = "sha256:2832961f6ffcfe4b57c338bc3418a3526f495c26fb9c54565409c5532f7c41be"}, + {file = "covdefaults-2.3.0.tar.gz", hash = "sha256:4e99f679f12d792bc62e5510fa3eb59546ed47bd569e36e4fddc4081c9c3ebf7"}, +] + +[package.dependencies] +coverage = ">=6.0.2" + [[package]] name = "coverage" version = "7.6.1" @@ -1602,4 +1631,4 @@ multidict = ">=4.0" [metadata] lock-version = "2.0" python-versions = "^3.12" -content-hash = "e3943635815d0ac72cee71ab8f5447c93159a77cbf2c4e30004b7fa336d6f037" +content-hash = "8f88c06561f886940852ef42190cbc3a2d59248cce449ab060086da18262cd97"