Mopidy-Dirble-1.3.0/ 0000775 0001750 0001750 00000000000 12651253104 015160 5 ustar adamcik adamcik 0000000 0000000 Mopidy-Dirble-1.3.0/PKG-INFO 0000664 0001750 0001750 00000012676 12651253104 016271 0 ustar adamcik adamcik 0000000 0000000 Metadata-Version: 1.1
Name: Mopidy-Dirble
Version: 1.3.0
Summary: Mopidy extension for Dirble open radio directory
Home-page: https://github.com/mopidy/mopidy-dirble
Author: Thomas Adamcik
Author-email: thomas@adamcik.no
License: Apache License, Version 2.0
Description: *************
Mopidy-Dirble
*************
.. image:: https://img.shields.io/pypi/v/Mopidy-Dirble.svg?style=flat
:target: https://pypi.python.org/pypi/Mopidy-Dirble/
:alt: Latest PyPI version
.. image:: https://img.shields.io/pypi/dm/Mopidy-Dirble.svg?style=flat
:target: https://pypi.python.org/pypi/Mopidy-Dirble/
:alt: Number of PyPI downloads
.. image:: https://img.shields.io/travis/mopidy/mopidy-dirble/develop.svg?style=flat
:target: https://travis-ci.org/mopidy/mopidy-dirble
:alt: Travis CI build status
.. image:: https://img.shields.io/coveralls/mopidy/mopidy-dirble/develop.svg?style=flat
:target: https://coveralls.io/r/mopidy/mopidy-dirble?branch=develop
:alt: Test coverage
`Mopidy `_ extension for Dirble open radio directory.
Installation
============
Debian/Ubuntu/Raspbian: Install the ``mopidy-dirble`` package from
`apt.mopidy.com `_::
sudo apt-get install mopidy-dirble
Arch Linux: Install the ``mopidy-dirble`` package from
`AUR `_::
sudo yaourt -S mopidy-dirble
OS X: Install the ``mopidy-dirble`` package from the
`mopidy/mopidy `_ Homebrew tap::
brew install mopidy-dirble
Else: Install the the package from PyPI::
pip install Mopidy-Dirble
Configuration
=============
Before starting Mopidy, you must add configuration for
Mopidy-Dirble to your Mopidy configuration file::
[dirble]
api_key = INSERT-YOUR-API-KEY-FROM-DIRBLE-HERE
countries = US,GB,NO
timeout = 5000
To get this working you must first go to `Dirble `_ and
sign up for an account or just login with Facebook or Twitter. Then go to the
`API keys page `_ and get your API key.
The free plan should be more than enough for a typical Mopidy install.
Project resources
=================
- `Source code `_
- `Issue tracker `_
Credits
=======
- Original author: `Thomas Adamcik `__
- Current maintainer: `Thomas Adamcik `__
- `Contributors `_
Changelog
=========
v1.3.0 (2016-01-25)
-------------------
- Fix user country handling. Fixes #12
- Log an error for bad API tokens.
- Various internal cleanups
- Removed bad sample API key and added instructions to get your own. Fixes #13
v1.2.0 (2015-12-05)
-------------------
- Update to account for changes in data from Dirble API. Fixes #11
- pycountry is no longer used as Dirble provides names now.
v1.1.2 (2015-06-25)
-------------------
- Fix image handling bugs in 1.1.1.
v1.1.1 (2015-06-24)
-------------------
- Updates to match Dirble v2 API changes.
- Prefer streams that Dirble says are up. Thanks to Alexander Hartl
(@alexhartl) for suggesting the status check in PR#8.
v1.1.0 (2015-04-26)
-------------------
- Use Requests for accessing the API.
- Update to use new Dirble v2 APIs.
- Add support for station images.
- Add continent/country browsing.
- Add search support.
- Stop showing country codes in country folders.
v1.0.0 (2015-03-25)
-------------------
- Require Mopidy >= 1.0.
- Update to work with new playback API in Mopidy 1.0.
- Update to work with new backend search API in Mopidy 1.0.
v0.1.1 (2014-03-20)
-------------------
- Change to new API endpoint URL. The old API endpoint will be discontinued
2014-05-03.
v0.1.0 (2014-01-20)
-------------------
- Initial release.
- Provides basic hierarchy based browsing of Dirble categories and
sub-categories.
- Lists user defined countries.
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 :: 2
Classifier: Topic :: Multimedia :: Sound/Audio :: Players
Mopidy-Dirble-1.3.0/README.rst 0000664 0001750 0001750 00000007275 12651253034 016664 0 ustar adamcik adamcik 0000000 0000000 *************
Mopidy-Dirble
*************
.. image:: https://img.shields.io/pypi/v/Mopidy-Dirble.svg?style=flat
:target: https://pypi.python.org/pypi/Mopidy-Dirble/
:alt: Latest PyPI version
.. image:: https://img.shields.io/pypi/dm/Mopidy-Dirble.svg?style=flat
:target: https://pypi.python.org/pypi/Mopidy-Dirble/
:alt: Number of PyPI downloads
.. image:: https://img.shields.io/travis/mopidy/mopidy-dirble/develop.svg?style=flat
:target: https://travis-ci.org/mopidy/mopidy-dirble
:alt: Travis CI build status
.. image:: https://img.shields.io/coveralls/mopidy/mopidy-dirble/develop.svg?style=flat
:target: https://coveralls.io/r/mopidy/mopidy-dirble?branch=develop
:alt: Test coverage
`Mopidy `_ extension for Dirble open radio directory.
Installation
============
Debian/Ubuntu/Raspbian: Install the ``mopidy-dirble`` package from
`apt.mopidy.com `_::
sudo apt-get install mopidy-dirble
Arch Linux: Install the ``mopidy-dirble`` package from
`AUR `_::
sudo yaourt -S mopidy-dirble
OS X: Install the ``mopidy-dirble`` package from the
`mopidy/mopidy `_ Homebrew tap::
brew install mopidy-dirble
Else: Install the the package from PyPI::
pip install Mopidy-Dirble
Configuration
=============
Before starting Mopidy, you must add configuration for
Mopidy-Dirble to your Mopidy configuration file::
[dirble]
api_key = INSERT-YOUR-API-KEY-FROM-DIRBLE-HERE
countries = US,GB,NO
timeout = 5000
To get this working you must first go to `Dirble `_ and
sign up for an account or just login with Facebook or Twitter. Then go to the
`API keys page `_ and get your API key.
The free plan should be more than enough for a typical Mopidy install.
Project resources
=================
- `Source code `_
- `Issue tracker `_
Credits
=======
- Original author: `Thomas Adamcik `__
- Current maintainer: `Thomas Adamcik `__
- `Contributors `_
Changelog
=========
v1.3.0 (2016-01-25)
-------------------
- Fix user country handling. Fixes #12
- Log an error for bad API tokens.
- Various internal cleanups
- Removed bad sample API key and added instructions to get your own. Fixes #13
v1.2.0 (2015-12-05)
-------------------
- Update to account for changes in data from Dirble API. Fixes #11
- pycountry is no longer used as Dirble provides names now.
v1.1.2 (2015-06-25)
-------------------
- Fix image handling bugs in 1.1.1.
v1.1.1 (2015-06-24)
-------------------
- Updates to match Dirble v2 API changes.
- Prefer streams that Dirble says are up. Thanks to Alexander Hartl
(@alexhartl) for suggesting the status check in PR#8.
v1.1.0 (2015-04-26)
-------------------
- Use Requests for accessing the API.
- Update to use new Dirble v2 APIs.
- Add support for station images.
- Add continent/country browsing.
- Add search support.
- Stop showing country codes in country folders.
v1.0.0 (2015-03-25)
-------------------
- Require Mopidy >= 1.0.
- Update to work with new playback API in Mopidy 1.0.
- Update to work with new backend search API in Mopidy 1.0.
v0.1.1 (2014-03-20)
-------------------
- Change to new API endpoint URL. The old API endpoint will be discontinued
2014-05-03.
v0.1.0 (2014-01-20)
-------------------
- Initial release.
- Provides basic hierarchy based browsing of Dirble categories and
sub-categories.
- Lists user defined countries.
Mopidy-Dirble-1.3.0/LICENSE 0000664 0001750 0001750 00000026135 12265576367 016220 0 ustar adamcik adamcik 0000000 0000000
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
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file 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-Dirble-1.3.0/tox.ini 0000664 0001750 0001750 00000000535 12651253034 016500 0 ustar adamcik adamcik 0000000 0000000 [tox]
envlist = py27, flake8
[testenv]
sitepackages = true
deps =
mock
pytest
pytest-cov
pytest-xdist
commands =
py.test \
--basetemp={envtmpdir} \
--cov=mopidy_dirble --cov-report=term-missing \
{posargs}
[testenv:flake8]
deps =
flake8
flake8-import-order
skip_install = true
commands = flake8
Mopidy-Dirble-1.3.0/setup.cfg 0000664 0001750 0001750 00000000237 12651253104 017003 0 ustar adamcik adamcik 0000000 0000000 [flake8]
application-import-names = mopidy_dirble,tests
exclude = .git,.tox
[wheel]
universal = 1
[egg_info]
tag_build =
tag_date = 0
tag_svn_revision = 0
Mopidy-Dirble-1.3.0/setup.py 0000664 0001750 0001750 00000002437 12651253034 016702 0 ustar adamcik adamcik 0000000 0000000 from __future__ import unicode_literals
import re
from setuptools import find_packages, setup
def get_version(filename):
with open(filename) as fh:
metadata = dict(re.findall("__([a-z]+)__ = '([^']+)'", fh.read()))
return metadata['version']
setup(
name='Mopidy-Dirble',
version=get_version('mopidy_dirble/__init__.py'),
url='https://github.com/mopidy/mopidy-dirble',
license='Apache License, Version 2.0',
author='Thomas Adamcik',
author_email='thomas@adamcik.no',
description='Mopidy extension for Dirble open radio directory',
long_description=open('README.rst').read(),
packages=find_packages(exclude=['tests', 'tests.*']),
zip_safe=False,
include_package_data=True,
install_requires=[
'setuptools',
'Mopidy >= 1.0',
'Pykka >= 1.1',
'requests',
],
entry_points={
'mopidy.ext': [
'dirble = mopidy_dirble:Extension',
],
},
classifiers=[
'Environment :: No Input/Output (Daemon)',
'Intended Audience :: End Users/Desktop',
'License :: OSI Approved :: Apache Software License',
'Operating System :: OS Independent',
'Programming Language :: Python :: 2',
'Topic :: Multimedia :: Sound/Audio :: Players',
],
)
Mopidy-Dirble-1.3.0/.travis.yml 0000664 0001750 0001750 00000001045 12651253034 017273 0 ustar adamcik adamcik 0000000 0000000 sudo: false
language: python
python:
- "2.7_with_system_site_packages"
addons:
apt:
sources:
- mopidy-stable
packages:
- mopidy
env:
- TOX_ENV=py27
- TOX_ENV=flake8
install:
- "pip install tox"
script:
- "tox -e $TOX_ENV"
after_success:
- "if [ $TOX_ENV == 'py27' ]; then pip install --pre coveralls; coveralls; fi"
branches:
except:
- debian
notifications:
irc:
channels:
- "irc.freenode.org#mopidy"
on_success: change
on_failure: change
use_notice: true
skip_join: true
Mopidy-Dirble-1.3.0/tests/ 0000775 0001750 0001750 00000000000 12651253104 016322 5 ustar adamcik adamcik 0000000 0000000 Mopidy-Dirble-1.3.0/tests/test_extension.py 0000664 0001750 0001750 00000001001 12266627022 021745 0 ustar adamcik adamcik 0000000 0000000 from __future__ import unicode_literals
import unittest
from mopidy_dirble import Extension
class ExtensionTest(unittest.TestCase):
def test_get_default_config(self):
ext = Extension()
config = ext.get_default_config()
self.assertIn('[dirble]', config)
self.assertIn('enabled = true', config)
def test_get_config_schema(self):
ext = Extension()
schema = ext.get_config_schema()
self.assertIn('api_key', schema)
# TODO Write more tests
Mopidy-Dirble-1.3.0/tests/__init__.py 0000664 0001750 0001750 00000000000 12265576367 020445 0 ustar adamcik adamcik 0000000 0000000 Mopidy-Dirble-1.3.0/Mopidy_Dirble.egg-info/ 0000775 0001750 0001750 00000000000 12651253104 021374 5 ustar adamcik adamcik 0000000 0000000 Mopidy-Dirble-1.3.0/Mopidy_Dirble.egg-info/requires.txt 0000664 0001750 0001750 00000000057 12651253104 023776 0 ustar adamcik adamcik 0000000 0000000 setuptools
Mopidy >= 1.0
Pykka >= 1.1
requests
Mopidy-Dirble-1.3.0/Mopidy_Dirble.egg-info/PKG-INFO 0000664 0001750 0001750 00000012676 12651253104 022505 0 ustar adamcik adamcik 0000000 0000000 Metadata-Version: 1.1
Name: Mopidy-Dirble
Version: 1.3.0
Summary: Mopidy extension for Dirble open radio directory
Home-page: https://github.com/mopidy/mopidy-dirble
Author: Thomas Adamcik
Author-email: thomas@adamcik.no
License: Apache License, Version 2.0
Description: *************
Mopidy-Dirble
*************
.. image:: https://img.shields.io/pypi/v/Mopidy-Dirble.svg?style=flat
:target: https://pypi.python.org/pypi/Mopidy-Dirble/
:alt: Latest PyPI version
.. image:: https://img.shields.io/pypi/dm/Mopidy-Dirble.svg?style=flat
:target: https://pypi.python.org/pypi/Mopidy-Dirble/
:alt: Number of PyPI downloads
.. image:: https://img.shields.io/travis/mopidy/mopidy-dirble/develop.svg?style=flat
:target: https://travis-ci.org/mopidy/mopidy-dirble
:alt: Travis CI build status
.. image:: https://img.shields.io/coveralls/mopidy/mopidy-dirble/develop.svg?style=flat
:target: https://coveralls.io/r/mopidy/mopidy-dirble?branch=develop
:alt: Test coverage
`Mopidy `_ extension for Dirble open radio directory.
Installation
============
Debian/Ubuntu/Raspbian: Install the ``mopidy-dirble`` package from
`apt.mopidy.com `_::
sudo apt-get install mopidy-dirble
Arch Linux: Install the ``mopidy-dirble`` package from
`AUR `_::
sudo yaourt -S mopidy-dirble
OS X: Install the ``mopidy-dirble`` package from the
`mopidy/mopidy `_ Homebrew tap::
brew install mopidy-dirble
Else: Install the the package from PyPI::
pip install Mopidy-Dirble
Configuration
=============
Before starting Mopidy, you must add configuration for
Mopidy-Dirble to your Mopidy configuration file::
[dirble]
api_key = INSERT-YOUR-API-KEY-FROM-DIRBLE-HERE
countries = US,GB,NO
timeout = 5000
To get this working you must first go to `Dirble `_ and
sign up for an account or just login with Facebook or Twitter. Then go to the
`API keys page `_ and get your API key.
The free plan should be more than enough for a typical Mopidy install.
Project resources
=================
- `Source code `_
- `Issue tracker `_
Credits
=======
- Original author: `Thomas Adamcik `__
- Current maintainer: `Thomas Adamcik `__
- `Contributors `_
Changelog
=========
v1.3.0 (2016-01-25)
-------------------
- Fix user country handling. Fixes #12
- Log an error for bad API tokens.
- Various internal cleanups
- Removed bad sample API key and added instructions to get your own. Fixes #13
v1.2.0 (2015-12-05)
-------------------
- Update to account for changes in data from Dirble API. Fixes #11
- pycountry is no longer used as Dirble provides names now.
v1.1.2 (2015-06-25)
-------------------
- Fix image handling bugs in 1.1.1.
v1.1.1 (2015-06-24)
-------------------
- Updates to match Dirble v2 API changes.
- Prefer streams that Dirble says are up. Thanks to Alexander Hartl
(@alexhartl) for suggesting the status check in PR#8.
v1.1.0 (2015-04-26)
-------------------
- Use Requests for accessing the API.
- Update to use new Dirble v2 APIs.
- Add support for station images.
- Add continent/country browsing.
- Add search support.
- Stop showing country codes in country folders.
v1.0.0 (2015-03-25)
-------------------
- Require Mopidy >= 1.0.
- Update to work with new playback API in Mopidy 1.0.
- Update to work with new backend search API in Mopidy 1.0.
v0.1.1 (2014-03-20)
-------------------
- Change to new API endpoint URL. The old API endpoint will be discontinued
2014-05-03.
v0.1.0 (2014-01-20)
-------------------
- Initial release.
- Provides basic hierarchy based browsing of Dirble categories and
sub-categories.
- Lists user defined countries.
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 :: 2
Classifier: Topic :: Multimedia :: Sound/Audio :: Players
Mopidy-Dirble-1.3.0/Mopidy_Dirble.egg-info/entry_points.txt 0000664 0001750 0001750 00000000057 12651253104 024674 0 ustar adamcik adamcik 0000000 0000000 [mopidy.ext]
dirble = mopidy_dirble:Extension
Mopidy-Dirble-1.3.0/Mopidy_Dirble.egg-info/not-zip-safe 0000664 0001750 0001750 00000000001 12265600037 023624 0 ustar adamcik adamcik 0000000 0000000
Mopidy-Dirble-1.3.0/Mopidy_Dirble.egg-info/SOURCES.txt 0000664 0001750 0001750 00000000757 12651253104 023271 0 ustar adamcik adamcik 0000000 0000000 .travis.yml
LICENSE
MANIFEST.in
README.rst
setup.cfg
setup.py
tox.ini
Mopidy_Dirble.egg-info/PKG-INFO
Mopidy_Dirble.egg-info/SOURCES.txt
Mopidy_Dirble.egg-info/dependency_links.txt
Mopidy_Dirble.egg-info/entry_points.txt
Mopidy_Dirble.egg-info/not-zip-safe
Mopidy_Dirble.egg-info/requires.txt
Mopidy_Dirble.egg-info/top_level.txt
mopidy_dirble/__init__.py
mopidy_dirble/actor.py
mopidy_dirble/client.py
mopidy_dirble/ext.conf
mopidy_dirble/translator.py
tests/__init__.py
tests/test_extension.py Mopidy-Dirble-1.3.0/Mopidy_Dirble.egg-info/top_level.txt 0000664 0001750 0001750 00000000016 12651253104 024123 0 ustar adamcik adamcik 0000000 0000000 mopidy_dirble
Mopidy-Dirble-1.3.0/Mopidy_Dirble.egg-info/dependency_links.txt 0000664 0001750 0001750 00000000001 12651253104 025442 0 ustar adamcik adamcik 0000000 0000000
Mopidy-Dirble-1.3.0/mopidy_dirble/ 0000775 0001750 0001750 00000000000 12651253104 020002 5 ustar adamcik adamcik 0000000 0000000 Mopidy-Dirble-1.3.0/mopidy_dirble/translator.py 0000664 0001750 0001750 00000002365 12630635057 022563 0 ustar adamcik adamcik 0000000 0000000 from __future__ import unicode_literals
import re
from mopidy.models import Ref, Track
def unparse_uri(variant, identifier):
return b'dirble:%s:%s' % (variant, identifier)
def parse_uri(uri):
result = re.findall(r'^dirble:([a-z]+)(?::(\d+|[a-z]{2}))?$', uri)
if result:
return result[0]
return None, None
def station_to_ref(station, show_country=True):
name = station.get('name').strip() # TODO: fallback to streams URI?
if show_country:
# TODO: make this a setting so users can set '$name [$country]' etc?
name = '%s [%s]' % (name, station.get('country', '??'))
uri = unparse_uri('station', station['id'])
return Ref.track(uri=uri, name=name)
def station_to_track(station):
ref = station_to_ref(station)
return Track(uri=ref.uri, name=ref.name)
def category_to_ref(category):
uri = unparse_uri('category', category['id'])
return Ref.directory(uri=uri, name=category.get('title', uri))
def continent_to_ref(continent):
uri = unparse_uri('continent', continent['id'])
return Ref.directory(uri=uri, name=continent['name'])
def country_to_ref(country):
uri = unparse_uri('country', country['country_code'].lower())
return Ref.directory(uri=uri, name=country['name'])
Mopidy-Dirble-1.3.0/mopidy_dirble/actor.py 0000664 0001750 0001750 00000013102 12651253034 021463 0 ustar adamcik adamcik 0000000 0000000 from __future__ import unicode_literals
import logging
from mopidy import backend
from mopidy.models import Image, Ref, SearchResult
import pykka
from . import client, translator
logger = logging.getLogger(__name__)
class DirbleBackend(pykka.ThreadingActor, backend.Backend):
uri_schemes = ['dirble']
def __init__(self, config, audio):
super(DirbleBackend, self).__init__()
self.dirble = client.Dirble(config['dirble']['api_key'],
config['dirble']['timeout'])
self.countries = config['dirble']['countries']
self.library = DirbleLibrary(backend=self)
self.playback = DirblePlayback(audio=audio, backend=self)
class DirbleLibrary(backend.LibraryProvider):
root_directory = Ref.directory(uri='dirble:root', name='Dirble')
# TODO: add countries when there is a lookup for countries with stations
def browse(self, uri):
result = []
variant, identifier = translator.parse_uri(uri)
if variant == 'root':
for category in self.backend.dirble.categories():
result.append(translator.category_to_ref(category))
for continent in self.backend.dirble.continents():
result.append(translator.continent_to_ref(continent))
elif variant == 'category' and identifier:
for category in self.backend.dirble.subcategories(identifier):
result.append(translator.category_to_ref(category))
for station in self.backend.dirble.stations(category=identifier):
result.append(translator.station_to_ref(station))
elif variant == 'continent' and identifier:
for country in self.backend.dirble.countries(continent=identifier):
result.append(translator.country_to_ref(country))
elif variant == 'country' and identifier:
for station in self.backend.dirble.stations(country=identifier):
result.append(
translator.station_to_ref(station, show_country=False))
else:
logger.debug('Unknown URI: %s', uri)
return []
result.sort(key=lambda ref: ref.name)
# Handle this case after the general ones as we want the user defined
# countries be the first entries, and retain their config sort order.
if variant == 'root':
user_countries = []
for country_code in self.backend.countries:
country = self.backend.dirble.country(country_code)
if country:
user_countries.append(translator.country_to_ref(country))
else:
logger.debug('Unknown country: %s', country_code)
result = user_countries + result
if not result:
logger.debug('Did not find any browse results for: %s', uri)
return result
def refresh(self, uri=None):
self.backend.dirble.flush()
def lookup(self, uri):
variant, identifier = translator.parse_uri(uri)
if variant != 'station':
return []
station = self.backend.dirble.station(identifier)
if not station:
return []
return [translator.station_to_track(station)]
def search(self, query=None, uris=None, exact=False):
if not query.get('any'):
return None
categories = set()
countries = []
for uri in uris or []:
variant, identifier = translator.parse_uri(uri)
if variant == 'country':
countries.append(identifier.lower())
elif variant == 'continent':
countries.extend(self.backend.dirble.countries(identifier))
elif variant == 'category':
pending = [self.backend.dirble.category(identifier)]
while pending:
c = pending.pop(0)
categories.add(c['id'])
pending.extend(c['children'])
tracks = []
for station in self.backend.dirble.search(' '.join(query['any'])):
if countries and station['country'].lower() not in countries:
continue
station_categories = {c['id'] for c in station['categories']}
if categories and not station_categories.intersection(categories):
continue
tracks.append(translator.station_to_track(station))
return SearchResult(tracks=tracks)
def get_images(self, uris):
result = {}
for uri in uris:
result[uri] = []
variant, identifier = translator.parse_uri(uri)
if variant != 'station' or not identifier:
continue
station = self.backend.dirble.station(identifier)
if not station or 'image' not in station:
continue
elif station['image'].get('url'):
result[uri].append(Image(uri=station['image']['url']))
elif station['image'].get('thumb', {}).get('url'):
result[uri].append(Image(uri=station['image']['thumb']['url']))
return result
class DirblePlayback(backend.PlaybackProvider):
def translate_uri(self, uri):
variant, identifier = translator.parse_uri(uri)
if variant != 'station':
return None
station = self.backend.dirble.station(identifier)
if not station['streams']:
return None
# TODO: order by bitrate and preferred mime types?
for stream in station['streams']:
if stream['status']:
return stream['stream']
return station['streams'][0]['stream']
Mopidy-Dirble-1.3.0/mopidy_dirble/__init__.py 0000664 0001750 0001750 00000001367 12651253034 022124 0 ustar adamcik adamcik 0000000 0000000 from __future__ import unicode_literals
import os
from mopidy import config, ext
__version__ = '1.3.0'
class Extension(ext.Extension):
dist_name = 'Mopidy-Dirble'
ext_name = 'dirble'
version = __version__
def get_default_config(self):
conf_file = os.path.join(os.path.dirname(__file__), 'ext.conf')
return config.read(conf_file)
def get_config_schema(self):
schema = super(Extension, self).get_config_schema()
schema['api_key'] = config.String()
schema['countries'] = config.List(optional=True)
schema['timeout'] = config.Integer(minimum=0)
return schema
def setup(self, registry):
from .actor import DirbleBackend
registry.add('backend', DirbleBackend)
Mopidy-Dirble-1.3.0/mopidy_dirble/client.py 0000664 0001750 0001750 00000013763 12651253034 021646 0 ustar adamcik adamcik 0000000 0000000 from __future__ import unicode_literals
import logging
import time
import urllib
from mopidy import __version__ as mopidy_version
from requests import Session, exceptions
from requests.adapters import HTTPAdapter
from mopidy_dirble import __version__ as dirble_version
logger = logging.getLogger(__name__)
class Dirble(object):
"""Light wrapper for Dirble API lookup.
Important things to note:
- The client will retry up to three times before giving up for network
errors etc.
- The client will do exponential back off when requests fail or timeout.
- The client will cache results aggressively.
- Failed requests will return an empty default type appropriate for the
lookup in question, normally a empty dict or list.
- The data returned comes direct from the API's JSON.
- The data is not copied, so beware of modifying what you get back.
"""
def __init__(self, api_key, timeout):
self._cache = {}
self._stations = {}
self._countries = {}
self._invalid_token = False
self._timeout = timeout / 1000.0
self._backoff_until = time.time()
self._backoff_max = 60
self._backoff = 1
self._base_uri = 'http://api.dirble.com/v2/'
self._session = Session()
self._session.params = {'token': api_key}
self._session.headers['User-Agent'] = ' '.join([
'Mopidy-Dirble/%s' % dirble_version,
'Mopidy/%s' % mopidy_version,
self._session.headers['User-Agent']])
self._session.mount(self._base_uri, HTTPAdapter(max_retries=3))
def flush(self):
self._cache = {}
self._stations = {}
self._countries = {}
self._invalid_token = False
def categories(self):
return self._fetch('categories/tree', [])
def category(self, identifier):
identifier = int(identifier)
categories = self.categories()[:]
while categories:
c = categories.pop(0)
if c['id'] == identifier:
return c
categories.extend(c['children'])
return None
def subcategories(self, identifier):
category = self.category(identifier)
return (category or {}).get('children', [])
def stations(self, category=None, country=None):
if category and not country:
path = 'category/%s/stations' % category
elif country and not category:
path = 'countries/%s/stations?all=1' % country.lower()
else:
return []
stations = self._fetch(path, [])
for station in stations:
self._stations.setdefault(station['id'], station)
return stations
def station(self, identifier):
identifier = int(identifier) # Ensure we are consistent for cache key.
if identifier in self._stations:
return self._stations[identifier]
station = self._fetch('station/%s' % identifier, {})
if station:
if 'id' not in station:
station['id'] = identifier
self._stations.setdefault(station['id'], station)
return station
def continents(self):
return self._fetch('continents', [])
def countries(self, continent=None):
if continent:
return self._fetch('continents/%s/countries' % continent, [])
else:
return self._fetch('countries', [])
def country(self, country_code):
if not self._countries:
for c in self.countries():
self._countries[c['country_code'].lower()] = c
return self._countries.get(country_code.lower())
def search(self, query):
quoted_query = urllib.quote(query.encode('utf-8'))
stations = self._fetch('search/%s' % quoted_query, [])
for station in stations:
self._stations.setdefault(station['id'], station)
return stations
def _fetch(self, path, default):
# Give up right away if we know the token is bad.
if self._invalid_token:
return default
uri = self._base_uri + path
# Try and serve request from our cache.
if uri in self._cache:
logger.debug('Cache hit: %s', uri)
return self._cache[uri]
# Check if we should back of sending queries.
if time.time() < self._backoff_until:
logger.debug('Back off fallback used: %s', uri)
return default
try:
logger.debug('Fetching: %s', uri)
resp = self._session.get(uri, timeout=self._timeout)
# Get succeeded, convert JSON, normalize and return.
if resp.status_code == 200:
normalize_keys = lambda d: {k.lower(): v for k, v in d.items()}
data = resp.json(object_hook=normalize_keys)
self._cache[uri] = data
self._backoff = 1
return data
# Special case invalid tokens as there is no point in doing any
# further requests.
if resp.status_code == 401:
logger.error('Dirble API token is not valid, please double '
'check your key or get a new one at dirble.com')
self._invalid_token = True
return default
# Don't treat a 404 as an error, just fallback to default value.
if resp.status_code == 404:
return default
# Anything else is an error.
resp.raise_for_status()
except exceptions.RequestException as e:
logger.warning('Fetching Dirble data failed: %s', e)
except ValueError as e:
logger.warning('Decoding Dirble data failed: %s', e)
# If we made it this far something is broken on our side or with the
# service, so start backing off sending requests.
self._backoff = min(self._backoff_max, self._backoff*2)
self._backoff_until = time.time() + self._backoff
logger.debug('Entering back off mode for %d seconds.', self._backoff)
return default
Mopidy-Dirble-1.3.0/mopidy_dirble/ext.conf 0000664 0001750 0001750 00000000075 12266606312 021460 0 ustar adamcik adamcik 0000000 0000000 [dirble]
enabled = true
api_key =
countries =
timeout = 5000
Mopidy-Dirble-1.3.0/MANIFEST.in 0000664 0001750 0001750 00000000254 12516773211 016725 0 ustar adamcik adamcik 0000000 0000000 include .coveragerc
include .travis.yml
include LICENSE
include MANIFEST.in
include README.rst
include mopidy_dirble/ext.conf
include tox.ini
recursive-include tests *.py