Mopidy-Podcast-3.0.0/0000755000175000017500000000000013600615324014270 5ustar tkemtkem00000000000000Mopidy-Podcast-3.0.0/.circleci/0000755000175000017500000000000013600615324016123 5ustar tkemtkem00000000000000Mopidy-Podcast-3.0.0/.circleci/config.yml0000644000175000017500000000213213572475337020131 0ustar tkemtkem00000000000000version: 2.1 orbs: codecov: codecov/codecov@1.0.5 workflows: version: 2 test: jobs: - py38 - py37 - black - check-manifest - docs - flake8 jobs: py38: &test-template docker: - image: mopidy/ci-python:3.8 steps: - checkout - restore_cache: name: Restoring tox cache key: tox-v1-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.cfg" }} - run: name: Run tests command: | tox -e $CIRCLE_JOB -- \ --junit-xml=test-results/pytest/results.xml \ --cov-report=xml - save_cache: name: Saving tox cache key: tox-v1-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.cfg" }} paths: - ./.tox - ~/.cache/pip - codecov/upload: file: coverage.xml - store_test_results: path: test-results py37: <<: *test-template docker: - image: mopidy/ci-python:3.7 black: *test-template check-manifest: *test-template docs: *test-template flake8: *test-template Mopidy-Podcast-3.0.0/CHANGELOG.rst0000644000175000017500000000430313600612306016306 0ustar tkemtkem00000000000000v3.0.0 (2019-12-25) =================== - Depend on final release of Mopidy 3.0.0. v3.0.0a1 (2019-12-06) ===================== - Require Python >= 3.7. - Require Mopidy >= 3.0.0a5. - Require Pykka >= 2.0.1. - Update project setup. v2.0.3 (2018-07-23) =================== - Skip empty ```` tags. v2.0.2 (2018-01-10) =================== - Skip cache for local feeds. - Accept uppercase ``URL`` attributes in OPML feeds. v2.0.1 (2016-08-10) =================== - Add OPML example to docs. - Remove PyPI downloads badge from README. - Correct tests under extreme timezones (thanks to Chris Lamb). v2.0.0 (2016-03-23) =================== - Add support for OPML subscription lists and directories. - Add configuration options for browse and lookup order. - Change URI scheme for podcast episodes to use GUID as fragment identifier. - Drop ``feeds`` directory. - Drop directory API. - Drop search support. - Upgrade dependencies to Mopidy v1.1.1. v1.1.2 (2015-08-27) =================== - Pass ``episodes`` as ``list`` to ``Podcast.copy()``. v1.1.1 (2015-03-25) =================== - Prepare for Mopidy v1.0 exact search API. v1.1.0 (2014-11-22) =================== - Improve ``podcast`` URI scheme. - Report podcasts as albums when browsing. - Update dependencies. - Update unit tests. v1.0.0 (2014-05-24) =================== - Move RSS parsing to ``FeedsDirectory``. - Support for additional podcast/episode properties. - Add ``search_results`` config value. - Add ``uri_schemes`` property to ``PodcastDirectory``. - Add ``uri`` property to ``Podcast`` and ``Episode``. - Support for ````. - Convert ``Podcast.Image`` and ``Episode.Enclosure`` to Mopidy model types. v0.4.0 (2014-04-11) =================== - ``PodcastDirectory`` and models API changes. - Performance and stability improvements. - Configuration cleanup. v0.3.0 (2014-03-14) =================== - Complete rewrite to integrate podcast directory extensions. v0.2.0 (2014-02-07) =================== - Improve handling of iTunes tags. - Improve performance by removing feedparser. - Support searching for podcasts and episodes. v0.1.0 (2014-02-01) =================== - Initial release. Mopidy-Podcast-3.0.0/LICENSE0000644000175000017500000002367613572474063015326 0ustar tkemtkem00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS Mopidy-Podcast-3.0.0/MANIFEST.in0000644000175000017500000000051613572475337016050 0ustar tkemtkem00000000000000include *.py include *.rst include .mailmap include .readthedocs.yml include LICENSE include MANIFEST.in include pyproject.toml include tox.ini recursive-include .circleci * recursive-include .github * include mopidy_*/ext.conf recursive-include tests *.py recursive-include tests *.xml recursive-include docs * prune docs/_build Mopidy-Podcast-3.0.0/Mopidy_Podcast.egg-info/0000755000175000017500000000000013600615324020700 5ustar tkemtkem00000000000000Mopidy-Podcast-3.0.0/Mopidy_Podcast.egg-info/PKG-INFO0000644000175000017500000000572513600615324022006 0ustar tkemtkem00000000000000Metadata-Version: 2.1 Name: Mopidy-Podcast Version: 3.0.0 Summary: Mopidy extension for browsing and playing podcasts Home-page: https://github.com/tkem/mopidy-podcast Author: Thomas Kemmer Author-email: tkemmer@computer.org License: Apache License, Version 2.0 Description: ************** Mopidy-Podcast ************** .. image:: https://img.shields.io/pypi/v/Mopidy-Podcast :target: https://pypi.org/project/Mopidy-Podcast/ :alt: Latest PyPI version .. image:: https://img.shields.io/circleci/build/gh/tkem/mopidy-podcast :target: https://circleci.com/gh/tkem/mopidy-podcast :alt: CircleCI build status .. image:: https://img.shields.io/codecov/c/gh/tkem/mopidy-podcast :target: https://codecov.io/gh/tkem/mopidy-podcast :alt: Test coverage .. image:: https://img.shields.io/readthedocs/mopidy-podcast :target: https://mopidy-podcast.readthedocs.io/ :alt: Read the Docs build status Mopidy-Podcast is a Mopidy_ extension for browsing and playing podcasts. This extension lets you browse podcasts distributed as RSS feeds and play individual episodes in a variety of audio formats. Podcasts are mapped to albums, while podcast episodes are shown as tracks in Mopidy, with metadata converted to Mopidy’s native data model where applicable. OPML 2.0 subscription lists and directories are also supported for multi-level browsing. For more information and installation instructions, please see Mopidy-Podcast's online documentation_. .. _Mopidy: http://www.mopidy.com/ .. _Documentation: http://mopidy-podcast.readthedocs.io/en/latest/ Project Resources ================= - `Source code `_ - `Issue tracker `_ - `Changelog `_ Credits ======= - Original author: `Thomas Kemmer `__ - Current maintainer: `Thomas Kemmer `__ - `Contributors `_ Platform: UNKNOWN Classifier: Environment :: No Input/Output (Daemon) Classifier: Intended Audience :: End Users/Desktop Classifier: License :: OSI Approved :: Apache Software License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 Classifier: Topic :: Multimedia :: Sound/Audio :: Players Requires-Python: >=3.7 Provides-Extra: docs Provides-Extra: lint Provides-Extra: release Provides-Extra: test Provides-Extra: dev Mopidy-Podcast-3.0.0/Mopidy_Podcast.egg-info/SOURCES.txt0000644000175000017500000000150713600615324022567 0ustar tkemtkem00000000000000CHANGELOG.rst LICENSE MANIFEST.in README.rst pyproject.toml setup.cfg setup.py tox.ini .circleci/config.yml Mopidy_Podcast.egg-info/PKG-INFO Mopidy_Podcast.egg-info/SOURCES.txt Mopidy_Podcast.egg-info/dependency_links.txt Mopidy_Podcast.egg-info/entry_points.txt Mopidy_Podcast.egg-info/not-zip-safe Mopidy_Podcast.egg-info/requires.txt Mopidy_Podcast.egg-info/top_level.txt docs/Makefile docs/changelog.rst docs/conf.py docs/config.rst docs/index.rst docs/install.rst docs/license.rst mopidy_podcast/__init__.py mopidy_podcast/backend.py mopidy_podcast/ext.conf mopidy_podcast/feeds.py mopidy_podcast/library.py mopidy_podcast/playback.py tests/__init__.py tests/conftest.py tests/directory.xml tests/rssfeed.xml tests/test_extension.py tests/test_feeds.py tests/test_library.py tests/test_opml.py tests/test_playback.py tests/test_rss.pyMopidy-Podcast-3.0.0/Mopidy_Podcast.egg-info/dependency_links.txt0000644000175000017500000000000113600615324024746 0ustar tkemtkem00000000000000 Mopidy-Podcast-3.0.0/Mopidy_Podcast.egg-info/entry_points.txt0000644000175000017500000000006113600615324024173 0ustar tkemtkem00000000000000[mopidy.ext] podcast = mopidy_podcast:Extension Mopidy-Podcast-3.0.0/Mopidy_Podcast.egg-info/not-zip-safe0000644000175000017500000000000113600614247023131 0ustar tkemtkem00000000000000 Mopidy-Podcast-3.0.0/Mopidy_Podcast.egg-info/requires.txt0000644000175000017500000000053013600615324023276 0ustar tkemtkem00000000000000Mopidy>=3.0.0 Pykka>=2.0.1 cachetools>=2.0 setuptools uritools>=1.0 [dev] sphinx black check-manifest flake8 flake8-bugbear flake8-import-order isort[pyproject] twine wheel pytest pytest-cov [docs] sphinx [lint] black check-manifest flake8 flake8-bugbear flake8-import-order isort[pyproject] [release] twine wheel [test] pytest pytest-cov Mopidy-Podcast-3.0.0/Mopidy_Podcast.egg-info/top_level.txt0000644000175000017500000000001713600615324023430 0ustar tkemtkem00000000000000mopidy_podcast Mopidy-Podcast-3.0.0/PKG-INFO0000644000175000017500000000572513600615324015376 0ustar tkemtkem00000000000000Metadata-Version: 2.1 Name: Mopidy-Podcast Version: 3.0.0 Summary: Mopidy extension for browsing and playing podcasts Home-page: https://github.com/tkem/mopidy-podcast Author: Thomas Kemmer Author-email: tkemmer@computer.org License: Apache License, Version 2.0 Description: ************** Mopidy-Podcast ************** .. image:: https://img.shields.io/pypi/v/Mopidy-Podcast :target: https://pypi.org/project/Mopidy-Podcast/ :alt: Latest PyPI version .. image:: https://img.shields.io/circleci/build/gh/tkem/mopidy-podcast :target: https://circleci.com/gh/tkem/mopidy-podcast :alt: CircleCI build status .. image:: https://img.shields.io/codecov/c/gh/tkem/mopidy-podcast :target: https://codecov.io/gh/tkem/mopidy-podcast :alt: Test coverage .. image:: https://img.shields.io/readthedocs/mopidy-podcast :target: https://mopidy-podcast.readthedocs.io/ :alt: Read the Docs build status Mopidy-Podcast is a Mopidy_ extension for browsing and playing podcasts. This extension lets you browse podcasts distributed as RSS feeds and play individual episodes in a variety of audio formats. Podcasts are mapped to albums, while podcast episodes are shown as tracks in Mopidy, with metadata converted to Mopidy’s native data model where applicable. OPML 2.0 subscription lists and directories are also supported for multi-level browsing. For more information and installation instructions, please see Mopidy-Podcast's online documentation_. .. _Mopidy: http://www.mopidy.com/ .. _Documentation: http://mopidy-podcast.readthedocs.io/en/latest/ Project Resources ================= - `Source code `_ - `Issue tracker `_ - `Changelog `_ Credits ======= - Original author: `Thomas Kemmer `__ - Current maintainer: `Thomas Kemmer `__ - `Contributors `_ Platform: UNKNOWN Classifier: Environment :: No Input/Output (Daemon) Classifier: Intended Audience :: End Users/Desktop Classifier: License :: OSI Approved :: Apache Software License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 Classifier: Topic :: Multimedia :: Sound/Audio :: Players Requires-Python: >=3.7 Provides-Extra: docs Provides-Extra: lint Provides-Extra: release Provides-Extra: test Provides-Extra: dev Mopidy-Podcast-3.0.0/README.rst0000644000175000017500000000336213572475337016003 0ustar tkemtkem00000000000000************** Mopidy-Podcast ************** .. image:: https://img.shields.io/pypi/v/Mopidy-Podcast :target: https://pypi.org/project/Mopidy-Podcast/ :alt: Latest PyPI version .. image:: https://img.shields.io/circleci/build/gh/tkem/mopidy-podcast :target: https://circleci.com/gh/tkem/mopidy-podcast :alt: CircleCI build status .. image:: https://img.shields.io/codecov/c/gh/tkem/mopidy-podcast :target: https://codecov.io/gh/tkem/mopidy-podcast :alt: Test coverage .. image:: https://img.shields.io/readthedocs/mopidy-podcast :target: https://mopidy-podcast.readthedocs.io/ :alt: Read the Docs build status Mopidy-Podcast is a Mopidy_ extension for browsing and playing podcasts. This extension lets you browse podcasts distributed as RSS feeds and play individual episodes in a variety of audio formats. Podcasts are mapped to albums, while podcast episodes are shown as tracks in Mopidy, with metadata converted to Mopidy’s native data model where applicable. OPML 2.0 subscription lists and directories are also supported for multi-level browsing. For more information and installation instructions, please see Mopidy-Podcast's online documentation_. .. _Mopidy: http://www.mopidy.com/ .. _Documentation: http://mopidy-podcast.readthedocs.io/en/latest/ Project Resources ================= - `Source code `_ - `Issue tracker `_ - `Changelog `_ Credits ======= - Original author: `Thomas Kemmer `__ - Current maintainer: `Thomas Kemmer `__ - `Contributors `_ Mopidy-Podcast-3.0.0/docs/0000755000175000017500000000000013600615324015220 5ustar tkemtkem00000000000000Mopidy-Podcast-3.0.0/docs/Makefile0000644000175000017500000001273413572474063016702 0ustar tkemtkem00000000000000# Makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = BUILDDIR = _build # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . # the i18n builder cannot share the environment and doctrees with the others I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext help: @echo "Please use \`make ' where is one of" @echo " html to make standalone HTML files" @echo " dirhtml to make HTML files named index.html in directories" @echo " singlehtml to make a single large HTML file" @echo " pickle to make pickle files" @echo " json to make JSON files" @echo " htmlhelp to make HTML files and a HTML help project" @echo " qthelp to make HTML files and a qthelp project" @echo " devhelp to make HTML files and a Devhelp project" @echo " epub to make an epub" @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" @echo " latexpdf to make LaTeX files and run them through pdflatex" @echo " text to make text files" @echo " man to make manual pages" @echo " texinfo to make Texinfo files" @echo " info to make Texinfo files and run them through makeinfo" @echo " gettext to make PO message catalogs" @echo " changes to make an overview of all changed/added/deprecated items" @echo " linkcheck to check all external links for integrity" @echo " doctest to run all doctests embedded in the documentation (if enabled)" clean: -rm -rf $(BUILDDIR)/* html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." dirhtml: $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." singlehtml: $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml @echo @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." pickle: $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle @echo @echo "Build finished; now you can process the pickle files." json: $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json @echo @echo "Build finished; now you can process the JSON files." htmlhelp: $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp @echo @echo "Build finished; now you can run HTML Help Workshop with the" \ ".hhp project file in $(BUILDDIR)/htmlhelp." qthelp: $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp @echo @echo "Build finished; now you can run "qcollectiongenerator" with the" \ ".qhcp project file in $(BUILDDIR)/qthelp, like this:" @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/Mopidy-Podcast.qhcp" @echo "To view the help file:" @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Mopidy-Podcast.qhc" devhelp: $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp @echo @echo "Build finished." @echo "To view the help file:" @echo "# mkdir -p $$HOME/.local/share/devhelp/Mopidy-Podcast" @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/Mopidy-Podcast" @echo "# devhelp" epub: $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub @echo @echo "Build finished. The epub file is in $(BUILDDIR)/epub." latex: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." @echo "Run \`make' in that directory to run these through (pdf)latex" \ "(use \`make latexpdf' here to do that automatically)." latexpdf: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo "Running LaTeX files through pdflatex..." $(MAKE) -C $(BUILDDIR)/latex all-pdf @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." text: $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text @echo @echo "Build finished. The text files are in $(BUILDDIR)/text." man: $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man @echo @echo "Build finished. The manual pages are in $(BUILDDIR)/man." texinfo: $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." @echo "Run \`make' in that directory to run these through makeinfo" \ "(use \`make info' here to do that automatically)." info: $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo "Running Texinfo files through makeinfo..." make -C $(BUILDDIR)/texinfo info @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." gettext: $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale @echo @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." changes: $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes @echo @echo "The overview file is in $(BUILDDIR)/changes." linkcheck: $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck @echo @echo "Link check complete; look for any errors in the above output " \ "or in $(BUILDDIR)/linkcheck/output.txt." doctest: $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest @echo "Testing of doctests in the sources finished, look at the " \ "results in $(BUILDDIR)/doctest/output.txt." Mopidy-Podcast-3.0.0/docs/changelog.rst0000644000175000017500000000010013572475337017710 0ustar tkemtkem00000000000000********** Change Log ********** .. include:: ../CHANGELOG.rst Mopidy-Podcast-3.0.0/docs/conf.py0000644000175000017500000000200013572475337016527 0ustar tkemtkem00000000000000import configparser import pathlib def setup(app): app.add_object_type( "confval", "confval", objname="configuration value", indextemplate="pair: %s; configuration value", ) def get_version(): # Get current library version without requiring the library to be # installed, like ``pkg_resources.get_distribution(...).version`` requires. cp = configparser.ConfigParser() cp.read(pathlib.Path(__file__).parent.parent / "setup.cfg") return cp["metadata"]["version"] project = "Mopidy-Podcast" copyright = "2014-2019 Thomas Kemmer" version = get_version() release = version exclude_patterns = ["_build"] master_doc = "index" html_theme = "default" latex_documents = [ ( "index", "Mopidy-Podcast.tex", "Mopidy-Podcast Documentation", "Thomas Kemmer", "manual", ) ] man_pages = [ ( "index", "mopidy-podcast", "Mopidy-Podcast Documentation", ["Thomas Kemmer"], 1, ) ] Mopidy-Podcast-3.0.0/docs/config.rst0000644000175000017500000000505613572475337017245 0ustar tkemtkem00000000000000************* Configuration ************* This extension provides a number of configuration values that can be tweaked. However, the :ref:`default configuration ` should contain everything to get you up and running, and will usually require only a few modifications, if any, to match personal preferences. .. _confvals: Configuration Values ==================== .. confval:: podcast/enabled Whether this extension should be enabled or not. .. confval:: podcast/browse_root A local path or URL pointing to an OPML syndication feed to use as the root for browsing the *Podcasts* directory in Mopidy. Relative paths refer to files in the extension's configuration directory [#footnote1]_. For example, this will point the *Podcasts* directory to a collection of all the BBC Radio and Music feeds:: browse_root = http://www.bbc.co.uk/podcasts.opml The default value is ``Podcasts.opml``, so simply exporting your subscribed feeds from your favorite podcast client under this name and dropping the file in Mopidy-Podcast's configuration directory is usually all you need to do. If set to an empty string, the *Podcasts* directory will be hidden when browsing Mopidy. .. confval:: podcast/browse_order Whether to sort podcast episodes by ascending (``asc``) or descending (``desc``) publication date for browsing. .. confval:: podcast/lookup_order Whether to sort podcast episodes by ascending (``asc``) or descending (``desc``) publication date for lookup, for example when adding a podcast to Mopidy's tracklist. .. confval:: podcast/cache_size The maximum number of podcast feeds that will be cached in memory. .. confval:: podcast/cache_ttl The cache's *time to live*, i.e. the number of seconds after which a cached feed expires and needs to be reloaded. .. confval:: podcast/timeout The HTTP request timeout when retrieving podcast feeds, in seconds. .. _defconf: Default Configuration ===================== For reference, this is the default configuration shipped with Mopidy-Podcast release |release|: .. literalinclude:: ../mopidy_podcast/ext.conf :language: ini .. rubric:: Footnotes .. [#footnote1] When running Mopidy as a regular user, this will usually be ``~/.config/mopidy/podcast``. When running as a system service, this should be ``/etc/mopidy/podcast``. Note that it may be necessary to create these directories manually when installing the Python package from PyPi_, depending on local file permissions. .. _PyPI: https://pypi.python.org/pypi/Mopidy-Podcast/ Mopidy-Podcast-3.0.0/docs/index.rst0000644000175000017500000000453113572475337017104 0ustar tkemtkem00000000000000************** Mopidy-Podcast ************** Mopidy-Podcast is a Mopidy_ extension for browsing and playing podcasts. This extension lets you browse podcasts distributed as RSS feeds and play individual episodes in a variety of audio formats. Podcasts are mapped to albums, while podcast episodes are shown as tracks in Mopidy, with metadata converted to Mopidy’s native data model where applicable. OPML 2.0 subscription lists and directories are also supported for multi-level browsing. To use this extension, you first need a way to access podcasts from Mopidy: - If you are already using a podcasting client, chances are that it supports exporting your subscribed feeds as an OPML file. Simply store this file in the location pointed to by :confval:`podcast/browse_root` to access your favorite podcasts from Mopidy. - Since OPML is a simple XML format, it is also feasible to create your own, using an XML or text editor of your choice. OPML also supports linking to other OPML files, both locally and on the Web, so this even allows creating your own *meta directory* pointing to podcast collections from the `BBC `_, `gpodder.net `_, and other sources:: - If your client supports entering Mopidy URIs for playback and browsing directly, just prefix the feed URL with ``podcast+`` to make sure it is not treated as an audio stream:: mpc add "podcast+http://www.npr.org/rss/podcast.php?id=510298" - Last but not least, you can install `Mopidy-Podcast-iTunes`_, a companion extension to Mopidy-Podcast, to browse and search podcasts on the `Apple iTunes Store `_. .. toctree:: :hidden: install config changelog license .. _Mopidy: http://www.mopidy.com/ .. _OPML 2.0 specification: http://dev.opml.org/spec2.html .. _Mopidy-Podcast-iTunes: https://github.com/tkem/mopidy-podcast-itunes/ Mopidy-Podcast-3.0.0/docs/install.rst0000644000175000017500000000060613572475337017442 0ustar tkemtkem00000000000000************ Installation ************ On Debian Linux and Debian-based distributions like Ubuntu or Raspbian, install the ``mopidy-podcast`` package from apt.mopidy.com_:: apt-get install mopidy-podcast Otherwise, install the Python package from PyPI_:: pip install Mopidy-Podcast .. _PyPI: https://pypi.python.org/pypi/Mopidy-Podcast/ .. _apt.mopidy.com: http://apt.mopidy.com/ Mopidy-Podcast-3.0.0/docs/license.rst0000644000175000017500000000117113572475337017414 0ustar tkemtkem00000000000000******* License ******* Mopidy-Podcast is Copyright (c) 2014-2019 Thomas Kemmer and contributors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this software except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Mopidy-Podcast-3.0.0/mopidy_podcast/0000755000175000017500000000000013600615324017306 5ustar tkemtkem00000000000000Mopidy-Podcast-3.0.0/mopidy_podcast/__init__.py0000644000175000017500000000376013572475337021445 0ustar tkemtkem00000000000000import pathlib import pkg_resources from mopidy import config, ext, httpclient __version__ = pkg_resources.get_distribution("Mopidy-Podcast").version class Extension(ext.Extension): dist_name = "Mopidy-Podcast" ext_name = "podcast" version = __version__ def get_default_config(self): return config.read(pathlib.Path(__file__).parent / "ext.conf") def get_config_schema(self): schema = super().get_config_schema() schema["browse_root"] = config.String(optional=True) schema["browse_order"] = config.String(choices=["asc", "desc"]) schema["lookup_order"] = config.String(choices=["asc", "desc"]) schema["cache_size"] = config.Integer(minimum=1) schema["cache_ttl"] = config.Integer(minimum=1) schema["timeout"] = config.Integer(optional=True, minimum=1) # no longer used schema["browse_limit"] = config.Deprecated() schema["search_limit"] = config.Deprecated() schema["search_details"] = config.Deprecated() schema["update_interval"] = config.Deprecated() schema["feeds"] = config.Deprecated() schema["feeds_root_name"] = config.Deprecated() schema["feeds_cache_size"] = config.Deprecated() schema["feeds_cache_ttl"] = config.Deprecated() schema["feeds_timeout"] = config.Deprecated() return schema def setup(self, registry): from .backend import PodcastBackend registry.add("backend", PodcastBackend) @classmethod def get_url_opener(cls, config): from urllib.request import ProxyHandler, build_opener proxy = httpclient.format_proxy(config["proxy"]) if proxy: handlers = [ProxyHandler({"http": proxy, "https": proxy})] else: handlers = [] opener = build_opener(*handlers) user_agent = f"{cls.dist_name}/{cls.version}" opener.addheaders = [ ("User-agent", httpclient.format_user_agent(user_agent)) ] return opener Mopidy-Podcast-3.0.0/mopidy_podcast/backend.py0000644000175000017500000000270013572475337021266 0ustar tkemtkem00000000000000import contextlib import logging import cachetools import pykka from mopidy import backend from . import Extension, feeds from .library import PodcastLibraryProvider from .playback import PodcastPlaybackProvider logger = logging.getLogger(__name__) class PodcastFeedCache(cachetools.TTLCache): pykka_traversable = True def __init__(self, config): super().__init__( maxsize=config[Extension.ext_name]["cache_size"], ttl=config[Extension.ext_name]["cache_ttl"], ) self.__opener = Extension.get_url_opener(config) self.__timeout = config[Extension.ext_name]["timeout"] def __missing__(self, uri): ext_name, _, feedurl = uri.partition("+") assert ext_name == Extension.ext_name f = self.__opener.open(feedurl, timeout=self.__timeout) with contextlib.closing(f) as source: feed = feeds.parse(source) # do not cache local URIs so updates are available immediately if not feedurl.startswith("file:"): self[uri] = feed return feed class PodcastBackend(pykka.ThreadingActor, backend.Backend): uri_schemes = ["podcast", "podcast+file", "podcast+http", "podcast+https"] def __init__(self, config, audio): super().__init__() self.feeds = PodcastFeedCache(config) self.library = PodcastLibraryProvider(config, backend=self) self.playback = PodcastPlaybackProvider(audio, backend=self) Mopidy-Podcast-3.0.0/mopidy_podcast/ext.conf0000644000175000017500000000123113572474063020765 0ustar tkemtkem00000000000000[podcast] enabled = true # optional path or URL to an OPML file used as the root for browsing; # relative paths will be resolved according to the extension's # configuration directory browse_root = Podcasts.opml # sort podcast episodes by ascending (asc) or descending (desc) # publication date for browsing browse_order = desc # sort podcast episodes by ascending (asc) or descending (desc) # publication date for lookup, e.g. when adding a podcast to Mopidy's # tracklist lookup_order = asc # maximum number of podcast feeds to cache in memory cache_size = 64 # cache time-to-live in seconds cache_ttl = 86400 # HTTP request timeout in seconds timeout = 10 Mopidy-Podcast-3.0.0/mopidy_podcast/feeds.py0000644000175000017500000001656713572475337021005 0ustar tkemtkem00000000000000import datetime import email.utils import re import uritools from mopidy import models from . import Extension try: import xml.etree.cElementTree as ElementTree except ImportError: import xml.etree.ElementTree as ElementTree def parse(source): if isinstance(source, str): url = uritools.uricompose("file", "", source) else: url = source.geturl() root = ElementTree.parse(source).getroot() if root.tag == "rss": return RssFeed(url, root) elif root.tag == "opml": return OpmlFeed(url, root) else: raise TypeError("Not a recognized podcast feed: %s", url) def get_url(source, default=None): """ Get URL from xml.etree.ElementTree.Element. URL is often capitalized in OPML feeds. """ return source.get("url", source.get("URL", default)) class PodcastFeed: def __init__(self, url): self.uri = self.getfeeduri(url) @classmethod def getfeeduri(cls, url): return uritools.uridefrag(Extension.ext_name + "+" + url).uri def getitemuri(self, guid, safe=uritools.SUB_DELIMS + ":@/?"): return self.uri + "#" + uritools.uriencode(guid, safe=safe).decode() def getstreamuri(self, guid): raise NotImplementedError def items(self, newest_first=None): raise NotImplementedError def tracks(self, newest_first=None): return [] def images(self): return [] class RssFeed(PodcastFeed): ITUNES_PREFIX = "{http://www.itunes.com/dtds/podcast-1.0.dtd}" DURATION_RE = re.compile( r""" (?: (?:(?P\d+):)? (?P\d+): )? (?P\d+) """, flags=re.VERBOSE, ) def __init__(self, url, root): super().__init__(url) self.__channel = channel = root.find("channel") items = channel.findall("./item/enclosure[@url]/..") self.__items = list(sorted(items, key=self.__order)) def getstreamuri(self, guid): for item in self.__items: if self.__guid(item) == guid: return get_url(item.find("enclosure")) return None def items(self, newest_first=False): for item in reversed(self.__items) if newest_first else self.__items: yield models.Ref.track( uri=self.getitemuri(self.__guid(item)), name=item.findtext("title"), ) def tracks(self, newest_first=False): album = models.Album( uri=self.uri, name=self.__channel.findtext("title"), artists=self.__artists(self.__channel), num_tracks=len(self.__items), ) genre = self.__genre(self.__channel) items = enumerate(self.__items, start=1) for index, item in reversed(list(items)) if newest_first else items: yield models.Track( uri=self.getitemuri(self.__guid(item)), name=item.findtext("title"), album=album, artists=(self.__artists(item) or album.artists), genre=genre, date=self.__date(item), length=self.__length(item), comment=item.findtext("description"), track_no=index, ) def images(self): image = self.__image(self.__channel) default = [image] if image else None if default: yield self.uri, default for item in self.__items: image = self.__image(item) if image: yield self.getitemuri(self.__guid(item)), [image] elif default: yield self.getitemuri(self.__guid(item)), default else: pass @classmethod def __artists(cls, etree): elem = etree.find(cls.ITUNES_PREFIX + "author") if elem is not None and elem.text: return [models.Artist(name=elem.text)] else: return None @classmethod def __date(cls, etree): text = etree.findtext("pubDate") try: timestamp = email.utils.mktime_tz(email.utils.parsedate_tz(text)) except AttributeError: return None except TypeError: return None else: return ( datetime.datetime.utcfromtimestamp(timestamp,) .date() .isoformat() ) @classmethod def __genre(cls, etree): elem = etree.find(cls.ITUNES_PREFIX + "category") if elem is not None: return elem.get("text") else: return None @classmethod def __guid(cls, etree): return etree.findtext("guid") or get_url(etree.find("enclosure")) @classmethod def __image(cls, etree): elem = etree.find(cls.ITUNES_PREFIX + "image") if elem is not None: return models.Image(uri=elem.get("href")) else: return None @classmethod def __length(cls, etree): text = etree.findtext(cls.ITUNES_PREFIX + "duration") try: groups = cls.DURATION_RE.match(text).groupdict("0") except AttributeError: return None except TypeError: return None else: d = datetime.timedelta(**{k: int(v) for k, v in groups.items()}) return int(d.total_seconds() * 1000) @staticmethod def __order(etree): text = etree.findtext("pubDate") try: timestamp = email.utils.mktime_tz(email.utils.parsedate_tz(text)) except AttributeError: return 0 except TypeError: return 0 else: return timestamp class OpmlFeed(PodcastFeed): # not really a "feed" TYPES = { "include": lambda e: models.Ref.directory( name=e.get("text"), uri=PodcastFeed.getfeeduri(get_url(e)) ), "link": lambda e: models.Ref( type=( models.Ref.DIRECTORY if get_url(e).endswith(".opml") else models.Ref.ALBUM ), name=e.get("text"), uri=PodcastFeed.getfeeduri(get_url(e)), ), "rss": lambda e: models.Ref.album( name=e.get("title", e.get("text")), uri=PodcastFeed.getfeeduri(e.get("xmlUrl")), ), } def __init__(self, url, root): super().__init__(url) self.__outlines = root.findall("./body//outline[@type]") def items(self, newest_first=None): for e in self.__outlines: try: ref = self.TYPES[e.get("type").lower()] except KeyError: pass else: yield ref(e) if __name__ == "__main__": # pragma: no cover import argparse import contextlib import json import urllib.request import sys from mopidy.models import ModelJSONEncoder parser = argparse.ArgumentParser() parser.add_argument("url", metavar="URL") parser.add_argument("-i", "--images", action="store_true") parser.add_argument("-t", "--tracks", action="store_true") args = parser.parse_args() with contextlib.closing(urllib.request.urlopen(args.url)) as source: feed = parse(source) if args.tracks: result = list(feed.tracks()) elif args.images: result = dict(feed.images()) else: result = list(feed.items()) json.dump(result, sys.stdout, cls=ModelJSONEncoder, indent=2) sys.stdout.write("\n") Mopidy-Podcast-3.0.0/mopidy_podcast/library.py0000644000175000017500000000773113572475337021354 0ustar tkemtkem00000000000000import itertools import locale import logging import os import uritools from mopidy import backend, models from . import Extension logger = logging.getLogger(__name__) def strerror(error): if isinstance(error.strerror, bytes): return error.strerror.decode(locale.getpreferredencoding()) else: return error.strerror def get_config_dir(config): try: return Extension.get_config_dir(config) except OSError as e: logger.warning( "Cannot access %s config directory: %s", Extension.dist_name, strerror(e), ) except Exception as e: logger.warning( "Cannot access %s config directory: %s", Extension.dist_name, e ) return None class PodcastLibraryProvider(backend.LibraryProvider): def __init__(self, config, backend): super().__init__(backend) self.__config_dir = get_config_dir(config) self.__browse_root = config[Extension.ext_name]["browse_root"] self.__browse_order = config[Extension.ext_name]["browse_order"] self.__lookup_order = config[Extension.ext_name]["lookup_order"] self.__tracks = {} # cache tracks for faster lookup @property def root_directory(self): root = self.__browse_root if not root: return None elif root.startswith(("file:", "http:", "https:")): uri = uritools.uridefrag("podcast+" + root).uri return models.Ref.directory(name="Podcasts", uri=uri) elif os.path.isabs(root): uri = uritools.uricompose("podcast+file", "", root) return models.Ref.directory(name="Podcasts", uri=uri) elif self.__config_dir: path = os.path.join(self.__config_dir, root) uri = uritools.uricompose("podcast+file", "", path) return models.Ref.directory(name="Podcasts", uri=uri) else: logger.error("Cannot retrieve Podcast root directory") return None def browse(self, uri): try: feed = self.backend.feeds[uri] except Exception as e: logger.error("Error retrieving %s: %s", uri, e) # TODO: raise? else: return list(feed.items(self.__browse_order == "desc")) return [] # FIXME: hide errors from clients def get_images(self, uris): def key(uri): return uritools.uridefrag(uri).uri result = {} for feeduri, uris in itertools.groupby(sorted(uris, key=key), key=key): try: images = dict(self.backend.feeds[feeduri].images()) except Exception as e: logger.error("Error retrieving images for %s: %s", feeduri, e) else: result.update((uri, images.get(uri, [])) for uri in uris) return result def lookup(self, uri): # pop from __tracks since cached tracks shouldn't live too long try: track = self.__tracks.pop(uri) except KeyError: logger.debug("Lookup cache miss: %s", uri) else: return [track] try: feed = self.backend.feeds[uritools.uridefrag(uri).uri] except Exception as e: logger.error("Error retrieving %s: %s", uri, e) # TODO: raise? else: return self.__lookup(feed, uri) return [] # FIXME: hide errors from clients def refresh(self, uri=None): if uri: self.backend.feeds.pop(uritools.uridefrag(uri).uri, None) else: self.backend.feeds.clear() self.__tracks.clear() def __lookup(self, feed, uri): if uri == feed.uri: return list(feed.tracks(self.__lookup_order == "desc")) else: self.__tracks = tracks = {t.uri: t for t in feed.tracks()} try: track = tracks.pop(uri) except KeyError: logger.warning("No such track: %s", uri) # TODO: raise? else: return [track] Mopidy-Podcast-3.0.0/mopidy_podcast/playback.py0000644000175000017500000000071513572475337021471 0ustar tkemtkem00000000000000import logging import uritools from mopidy import backend logger = logging.getLogger(__name__) class PodcastPlaybackProvider(backend.PlaybackProvider): def translate_uri(self, uri): parts = uritools.uridefrag(uri) try: feed = self.backend.feeds[parts.uri] except Exception as e: logger.error("Error retrieving %s: %s", parts.uri, e) else: return feed.getstreamuri(parts.getfragment()) Mopidy-Podcast-3.0.0/pyproject.toml0000644000175000017500000000052613572475337017227 0ustar tkemtkem00000000000000[build-system] requires = ["setuptools >= 30.3.0", "wheel"] [tool.black] target-version = ["py37", "py38"] line-length = 80 [tool.isort] multi_line_output = 3 include_trailing_comma = true force_grid_wrap = 0 use_parentheses = true line_length = 88 known_tests = "tests" sections = "FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,TESTS,LOCALFOLDER" Mopidy-Podcast-3.0.0/setup.cfg0000644000175000017500000000274313600615324016117 0ustar tkemtkem00000000000000[metadata] name = Mopidy-Podcast version = 3.0.0 url = https://github.com/tkem/mopidy-podcast author = Thomas Kemmer author_email = tkemmer@computer.org license = Apache License, Version 2.0 license_file = LICENSE description = Mopidy extension for browsing and playing podcasts long_description = file: README.rst classifiers = Environment :: No Input/Output (Daemon) Intended Audience :: End Users/Desktop License :: OSI Approved :: Apache Software License Operating System :: OS Independent Programming Language :: Python :: 3 Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Topic :: Multimedia :: Sound/Audio :: Players [options] zip_safe = False include_package_data = True packages = find: python_requires = >= 3.7 install_requires = Mopidy >= 3.0.0 Pykka >= 2.0.1 cachetools >= 2.0 setuptools uritools >= 1.0 [options.extras_require] docs = sphinx lint = black check-manifest flake8 flake8-bugbear flake8-import-order isort[pyproject] release = twine wheel test = pytest pytest-cov dev = %(docs)s %(lint)s %(release)s %(test)s [options.packages.find] exclude = tests tests.* [options.entry_points] mopidy.ext = podcast = mopidy_podcast:Extension [flake8] application-import-names = mopidy_podcast, tests max-line-length = 80 exclude = .git, .tox, build select = C, E, F, W B B950 N ignore = E203 E501 W503 [build_sphinx] source-dir = docs/ build-dir = docs/_build all_files = 1 [egg_info] tag_build = tag_date = 0 Mopidy-Podcast-3.0.0/setup.py0000644000175000017500000000004613572475337016022 0ustar tkemtkem00000000000000from setuptools import setup setup() Mopidy-Podcast-3.0.0/tests/0000755000175000017500000000000013600615324015432 5ustar tkemtkem00000000000000Mopidy-Podcast-3.0.0/tests/__init__.py0000644000175000017500000000000013572474063017544 0ustar tkemtkem00000000000000Mopidy-Podcast-3.0.0/tests/conftest.py0000644000175000017500000000153013572475337017650 0ustar tkemtkem00000000000000import functools import os from unittest import mock import mopidy_podcast as ext import pytest @pytest.fixture def abspath(): return functools.partial(os.path.join, os.path.dirname(__file__)) @pytest.fixture def audio(): return mock.Mock() @pytest.fixture def config(): return { "podcast": { "browse_root": "Podcasts.opml", "browse_order": "desc", "lookup_order": "asc", "cache_size": 64, "cache_ttl": 86400, "timeout": 10, }, "core": {"config_dir": os.path.dirname(__file__)}, "proxy": {}, } @pytest.fixture def backend(config, audio): return ext.backend.PodcastBackend(config, audio) @pytest.fixture def library(backend): return backend.library @pytest.fixture def playback(backend): return backend.playback Mopidy-Podcast-3.0.0/tests/directory.xml0000644000175000017500000001111713572474063020174 0ustar tkemtkem00000000000000 mySubscriptions.opml Sat, 18 Jun 2005 12:11:52 GMT Tue, 02 Aug 2005 21:42:48 GMT Dave Winer dave@scripting.com 1 61 304 562 842 Mopidy-Podcast-3.0.0/tests/rssfeed.xml0000644000175000017500000000662413572474063017632 0ustar tkemtkem00000000000000 All About Everything http://www.example.com/podcasts/everything/index.html en-us ℗ & © 2014 John Doe & Family A show about everything John Doe All About Everything is a show about everything. Each week we dive into any subject known to man and talk about it as much as we can. Look for our podcast in the Podcasts app or in the iTunes Store All About Everything is a show about everything. Each week we dive into any subject known to man and talk about it as much as we can. Look for our podcast in the Podcasts app or in the iTunes Store John Doe john.doe@example.com Shake Shake Shake Your Spices John Doe A short primer on table spices salt and pepper shakers, comparing and contrasting pour rates, construction materials, and overall aesthetics. Come and join the party!]]> http://example.com/podcasts/archive/aae20140615.m4a Wed, 15 Jun 2014 19:00:00 GMT 7:04 Socket Wrench Shootout Jane Doe Comparing socket wrenches is fun! This week we talk about metric vs. Old English socket wrenches. Which one is better? Do you really need both? Get all of your answers here. http://example.com/podcasts/archive/aae20140608.mp3 Wed, 8 Jun 2014 19:00:00 GMT 4:34 Red,Whine, & Blue Various Red + Blue != Purple This week we talk about surviving in a Red state if you are a Blue person. Or vice versa. http://example.com/podcasts/archive/aae20140601.mp3 Wed, 1 Jun 2014 19:00:00 GMT 3:59 Mopidy-Podcast-3.0.0/tests/test_extension.py0000644000175000017500000000412213572475337021076 0ustar tkemtkem00000000000000from unittest import mock from urllib.request import FileHandler, HTTPHandler, HTTPSHandler import pytest from mopidy_podcast import Extension, backend def test_get_default_config(): config = Extension().get_default_config() assert "[" + Extension.ext_name + "]" in config assert "enabled = true" in config def test_get_config_schema(): schema = Extension().get_config_schema() assert "browse_root" in schema assert "browse_order" in schema assert "lookup_order" in schema assert "cache_size" in schema assert "cache_ttl" in schema assert "timeout" in schema def test_setup(): registry = mock.Mock() Extension().setup(registry) registry.add.assert_called_once_with("backend", backend.PodcastBackend) @pytest.mark.parametrize( "url,handler,method,proxy_config", [ ("file://example.com/feed.xml", FileHandler, "file_open", {}), ("http://example.com/feed.xml", HTTPHandler, "http_open", {}), ("https://example.com/feed.xml", HTTPSHandler, "https_open", {},), ( "http://example.com/feed.xml", HTTPHandler, "http_open", {"scheme": "http", "hostname": "localhost", "port": 9999}, ), ( "http://example.com/feed.xml", HTTPSHandler, "https_open", {"scheme": "https", "hostname": "localhost", "port": 9999}, ), ], ) def test_get_url_opener(url, handler, method, proxy_config): opener = Extension.get_url_opener({"proxy": proxy_config}) with mock.patch.object(handler, method) as mock_open: try: opener.open(url) except Exception: pass assert mock_open.mock_calls (req,), _ = mock_open.call_args if req.header_items(): user_agent = f"{Extension.dist_name}/{Extension.version}" assert user_agent in req.get_header("User-agent") if proxy_config: assert req.type == proxy_config["scheme"] assert req.host == "{hostname}:{port}".format(**proxy_config) assert req.selector == url assert url == req.get_full_url() Mopidy-Podcast-3.0.0/tests/test_feeds.py0000644000175000017500000000062213572475337020151 0ustar tkemtkem00000000000000import uritools import pytest from mopidy_podcast import feeds @pytest.mark.parametrize( "filename,expected", [("directory.xml", feeds.OpmlFeed), ("rssfeed.xml", feeds.RssFeed)], ) def test_parse(abspath, filename, expected): path = abspath(filename) feed = feeds.parse(path) assert isinstance(feed, expected) assert feed.uri == uritools.uricompose("podcast+file", "", path) Mopidy-Podcast-3.0.0/tests/test_library.py0000644000175000017500000000526713572475337020541 0ustar tkemtkem00000000000000import pytest from mopidy_podcast import feeds def test_root_directory(library): assert library.root_directory is not None assert library.root_directory.name == "Podcasts" assert library.root_directory.uri.endswith("Podcasts.opml") @pytest.mark.parametrize("filename", ["directory.xml", "rssfeed.xml"]) def test_browse(config, library, filename, abspath): feed = feeds.parse(abspath(filename)) newest_first = config["podcast"]["browse_order"] == "desc" assert library.browse(feed.uri) == list(feed.items(newest_first)) @pytest.mark.parametrize("uri,expected", [(None, []), ("podcast+file:///", [])]) def test_browse_error(library, uri, expected): if isinstance(expected, type): with pytest.raises(expected): library.browse(uri) else: assert library.browse(uri) == expected @pytest.mark.parametrize("filename", ["rssfeed.xml"]) def test_get_images(library, filename, abspath): feed = feeds.parse(abspath(filename)) for uri, images in feed.images(): assert library.get_images([uri]) == {uri: images} images = {uri: images for uri, images in feed.images()} assert library.get_images(list(images)) == images @pytest.mark.parametrize( "uris,expected", [(None, TypeError), ("podcast+file:///", {})] ) def test_get_images_error(library, uris, expected): if isinstance(expected, type): with pytest.raises(expected): library.get_images(uris) else: assert library.get_images(uris) == expected @pytest.mark.parametrize("filename", ["rssfeed.xml"]) def test_lookup(config, library, filename, abspath): feed = feeds.parse(abspath(filename)) for track in feed.tracks(): assert library.lookup(track.uri) == [track] newest_first = config["podcast"]["lookup_order"] == "desc" assert library.lookup(feed.uri) == list(feed.tracks(newest_first)) @pytest.mark.parametrize("uri,expected", [(None, []), ("podcast+file:///", [])]) def test_lookup_error(library, uri, expected): if isinstance(expected, type): with pytest.raises(expected): library.lookup(uri) else: assert library.lookup(uri) == expected @pytest.mark.parametrize("filename", ["rssfeed.xml"]) def test_refresh(library, filename, abspath): feed = feeds.parse(abspath(filename)) tracks = library.lookup(feed.uri) assert feed.uri not in library.backend.feeds # local feeds not cached! library.backend.feeds[feed.uri] = feed assert feed.uri in library.backend.feeds library.refresh(tracks[0].uri) assert feed.uri not in library.backend.feeds library.backend.feeds[feed.uri] = feed assert library.backend.feeds library.refresh() assert not library.backend.feeds Mopidy-Podcast-3.0.0/tests/test_opml.py0000644000175000017500000000456613572475337020045 0ustar tkemtkem00000000000000from mopidy import models import pytest from mopidy_podcast import feeds XML = """ example.opml Tue, 02 Mar 2016 12:01:00 GMT Tue, 02 Mar 2016 12:01:00 GMT """ @pytest.fixture def opml(): from io import StringIO class StringSource(StringIO): def geturl(self): return "http://example.com/example.opml" return StringSource(XML) def test_items(opml): feed = feeds.parse(opml) assert list(feed.items()) == [ models.Ref.album( uri="podcast+http://example.com/podcast1.rss", name="Podcast" ), models.Ref.album( uri="podcast+http://example.com/podcast2.xml", name="Podcast" ), models.Ref.album( uri="podcast+http://example.com/podcast3", name="Podcast" ), models.Ref.directory( uri="podcast+http://example.com/directory1", name="Directory" ), models.Ref.directory( uri="podcast+http://example.com/directory2.opml", name="Directory" ), models.Ref.album( uri="podcast+http://example.com/podcast4.xml", name="Podcast" ), models.Ref.album( uri="podcast+http://example.com/podcast5.xml", name="PODCAST" ), ] def test_tracks(opml): feed = feeds.parse(opml) assert list(feed.tracks()) == [] def test_images(opml): feed = feeds.parse(opml) assert dict(feed.images()) == {} Mopidy-Podcast-3.0.0/tests/test_playback.py0000644000175000017500000000075413572475337020657 0ustar tkemtkem00000000000000import pytest from mopidy_podcast import feeds @pytest.mark.parametrize("filename", ["rssfeed.xml"]) def test_translate_uri(playback, filename, abspath): feed = feeds.parse(abspath(filename)) for track in feed.tracks(): assert playback.translate_uri(track.uri) is not None assert playback.translate_uri(feed.uri + "#n/a") is None assert playback.translate_uri(feed.uri) is None def test_translate_empty_uri(playback): assert playback.translate_uri("") is None Mopidy-Podcast-3.0.0/tests/test_rss.py0000644000175000017500000001052013572475337017670 0ustar tkemtkem00000000000000from mopidy import models import pytest from mopidy_podcast import feeds XML = """ All About Everything http://www.example.com/everything/index.html en-us ℗ & © 2014 John Doe & Family John Doe All About Everything is a show about everything. Shake Shake Shake Your Spices episode3 Wed, 15 Jun 2014 19:00:00 GMT 7:04 Socket Wrench Shootout Jane Doe episode2 Wed, 8 Jun 2014 19:00:00 GMT 4:34 Red, Whine, & Blue Various Wed, 1 Jun 2014 19:00:00 GMT 3:59 """ @pytest.fixture def rss(): from io import StringIO class StringSource(StringIO): def geturl(self): return "http://www.example.com/everything.xml" return feeds.parse(StringSource(XML)) @pytest.fixture def album(): return models.Album( uri="podcast+http://www.example.com/everything.xml", name="All About Everything", artists=[models.Artist(name="John Doe")], num_tracks=3, ) @pytest.fixture def tracks(album): return [ models.Track( uri="podcast+http://www.example.com/everything.xml#episode3", name="Shake Shake Shake Your Spices", artists=[models.Artist(name="John Doe")], album=album, genre="Technology", date="2014-06-15", length=424000, track_no=3, ), models.Track( uri="podcast+http://www.example.com/everything.xml#episode2", name="Socket Wrench Shootout", artists=[models.Artist(name="Jane Doe")], album=album, genre="Technology", date="2014-06-08", length=274000, track_no=2, ), models.Track( uri=( "podcast+http://www.example.com/everything.xml" "#http://example.com/everything/Episode1.mp3" ), name="Red, Whine, & Blue", artists=[models.Artist(name="Various")], album=album, genre="Technology", date="2014-06-01", length=239000, track_no=1, ), ] @pytest.fixture def items(tracks): return [models.Ref.track(uri=t.uri, name=t.name) for t in tracks] def test_items(rss, items): assert list(rss.items(newest_first=True)) == items assert list(rss.items(newest_first=False)) == list(reversed(items)) def test_tracks(rss, tracks): assert list(rss.tracks(newest_first=True)) == tracks assert list(rss.tracks(newest_first=False)) == list(reversed(tracks)) def test_images(rss): assert dict(rss.images()) == { "podcast+http://www.example.com/everything.xml": [ models.Image(uri="http://example.com/everything/Podcast.jpg") ], "podcast+http://www.example.com/everything.xml#episode3": [ models.Image(uri="http://example.com/everything/Episode3.jpg") ], "podcast+http://www.example.com/everything.xml#episode2": [ models.Image(uri="http://example.com/everything/Episode2.jpg") ], ( "podcast+http://www.example.com/everything.xml" "#http://example.com/everything/Episode1.mp3" ): [models.Image(uri="http://example.com/everything/Podcast.jpg")], } Mopidy-Podcast-3.0.0/tox.ini0000644000175000017500000000114513572475337015624 0ustar tkemtkem00000000000000[tox] envlist = py37, py38, black, check-manifest, docs, flake8 [testenv] sitepackages = true deps = .[test] commands = python -m pytest \ --basetemp={envtmpdir} \ --cov=mopidy_podcast --cov-report=term-missing \ {posargs} [testenv:black] deps = .[lint] commands = python -m black --check . [testenv:check-manifest] deps = .[lint] commands = python -m check_manifest [testenv:docs] deps = .[docs] changedir = docs commands = python -m sphinx -b html -d {envtmpdir}/doctrees . {envtmpdir}/html [testenv:flake8] deps = .[lint] commands = python -m flake8 --show-source --statistics