GithubHelp home page GithubHelp logo

mopidy / mopidy-dirble Goto Github PK

View Code? Open in Web Editor NEW
11.0 13.0 4.0 91 KB

DEPRECATED (Mopidy extension for Dirble open radio directory)

Home Page: https://mopidy.com

License: Apache License 2.0

Python 100.00%
python mopidy mopidy-backend

mopidy-dirble's Introduction

WARNING

As of November 2019, the dirble.com service is no longer operational. Thus, the maintenance of this extension has been stopped. The mopidy-dirble package has been removed from Homebrew and Debian/Ubuntu, and the Git repo is put into archive mode.


Mopidy-Dirble

Latest PyPI version Travis CI build status 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:

yay -S mopidy-dirble

OS X: Install the mopidy-dirble package from the mopidy/mopidy Homebrew tap:

brew install mopidy-dirble

Else: Install 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

Credits

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's People

Contributors

adamcik avatar jodal avatar kingosticks avatar lpmi-13 avatar trygveaa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mopidy-dirble's Issues

Use pagination

When browsing the the stations for a specific country we request all the stations rather than use the API's pagination support. There are (as of today) 9025 US stations returned by Dirble and this data takes ~25 seconds to fetch for me. The default timeout of 5 seconds means this fetch fails. And we then also retry 3 times which is probably why my usage quota has been exceeded.

However, for categories, we don't use all=1 in our request and so we only get the first 20 results. It's not clear how the results are ordered but the Rock category has over 2000 more stations.

Use streams instead of stream url

{"urlid":"nrk-p3-pyro","id":"3464","name":"NRK P3 Pyro","description":"","website":"http:\/\/www.p3.no\/","added":"2013-10-19 17:24:31","country":"NO","bitrate":"0","streamurl":"http:\/\/lyd.nrk.no:80\/nrk_radio_p3_pyro_aac_l","status":"1","songhistory":[],"streams":[{"id":"1002","stream":"http:\/\/lyd.nrk.no:80\/nrk_radio_p3_pyro_aac_l","bitrate":"0","type":"?","status":"1","station":"3464"}],"directory":[{"id":"8","name":"Hard Rock","urlid":"hard-rock"}]}

Mopidy hangs randomly when accessing radio playlist

Randomly, during the day, mopidy hangs when I try to access Radio Playlists from IRIS webclient.

These messages (a lot) are in the log:

2019-03-22 09:50:48,037 WARNING [466:MainThread] mopidy.internal.network: Rejected connection from [::ffff:127.0.0.1]:6600
2019-03-22 09:50:48,040 WARNING [466:MainThread] mopidy.internal.network: Rejected connection from [::ffff:127.0.0.1]:6600
2019-03-22 09:50:49,072 WARNING [466:MainThread] mopidy.internal.network: Rejected connection from [::ffff:127.0.0.1]:6600
2019-03-22 09:50:50,112 WARNING [466:MainThread] mopidy.internal.network: Rejected connection from [::ffff:127.0.0.1]:6600
2019-03-22 09:50:51,152 WARNING [466:MainThread] mopidy.internal.network: Rejected connection from [::ffff:127.0.0.1]:6600
2019-03-22 09:50:52,192 WARNING [466:MainThread] mopidy.internal.network: Rejected connection from [::ffff:127.0.0.1]:6600

..and Raspberry is not responding either to sudo service mopidy restart. All that I can do is to reboot Raspberry-

After hundreds of those messages, I have found this in the log:

2019-03-22 09:53:55,155 INFO [830:MainThread] mopidy.commands: GLib mainloop got SIGTERM. Exiting...
2019-03-22 09:53:55,157 INFO [830:MainThread] mopidy.commands: Stopping Mopidy frontends
2019-03-22 09:54:12,947 WARNING [830:DirbleBackend-13] urllib3.connectionpool: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPConnectionPool(host='api.dirble.com', port=80): Read timed out. (read timeout=30.0)",)': /v2/station/55363?token=4fd2a3d9e68118a39ed868c3ea
2019-03-22 09:54:43,009 WARNING [830:DirbleBackend-13] urllib3.connectionpool: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPConnectionPool(host='api.dirble.com', port=80): Read timed out. (read timeout=30.0)",)': /v2/station/55363?token=4fd2a3d9e68118a39ed868c3ea

maybe Dirble has some random network issues (in this moment I can't even log in in DIrble - Error 504), but this should not stop the system. I have only 1 dirble station in my Playlist...
I can access Dirble in Browsing and play the station. The problem is related to the dirble API call.

Start using urlid values in custom urls

{"urlid":"nrk-p3-pyro","id":"3464","name":"NRK P3 Pyro","description":"","website":"http:\/\/www.p3.no\/","added":"2013-10-19 17:24:31","country":"NO","bitrate":"0","streamurl":"http:\/\/lyd.nrk.no:80\/nrk_radio_p3_pyro_aac_l","status":"1","songhistory":[],"streams":[{"id":"1002","stream":"http:\/\/lyd.nrk.no:80\/nrk_radio_p3_pyro_aac_l","bitrate":"0","type":"?","status":"1","station":"3464"}],"directory":[{"id":"8","name":"Hard Rock","urlid":"hard-rock"}]}

API connection error while running as service

I'm running mopidy behind a company proxy and looking forward to run mopidy as a service.
So I've added a /etc/default/mopidy file with the following input:

http_proxy=http://Username:Password@ProxyServer:80
https_proxy=http://Username:Password@ProxyServer:80

Added the following lines to the /etc/init.d/mopidy:
[ -f /etc/default/mopidy ] && . /etc/default/mopidy

Here is my mopidy config file. (~/.config/mopidy/mopidy.conf is the same like /etc/mopidy/mopidy.conf)
# For further information about options in this file see:
#   http://docs.mopidy.com/
#
# The initial commented out values reflect the defaults as of:
#   Mopidy 2.1.0
#   Mopidy-File 2.1.0
#   Mopidy-HTTP 2.1.0
#   Mopidy-Local 2.1.0
#   Mopidy-M3U 2.1.0
#   Mopidy-MPD 2.1.0
#   Mopidy-SoftwareMixer 2.1.0
#   Mopidy-Stream 2.1.0
#
# Available options and defaults might have changed since then,
# run `mopidy config` to see the current effective config and
# `mopidy --version` to check the current version.

[core]
cache_dir = /var/cache/mopidy
config_dir = /etc/mopidy
data_dir = /var/lib/mopidy
#max_tracklist_length = 10000
#restore_state = false

[logging]
color = true
console_format = %(levelname)-8s %(message)s
debug_format = %(levelname)-8s %(asctime)s [%(process)d:%(threadName)s] %(name)s\n  %(message)s
debug_file = mopidy.log
config_file = /etc/mopidy/logging.conf

[audio]
mixer = software
mixer_volume = 30
#output = autoaudiosink
#buffer_time =

[proxy]
scheme = http
hostname = proxyserverhostname
port = 80
username = User
password = Password

[mpd]
#enabled = true
#hostname = 127.0.0.1
#port = 6600
#password =
#max_connections = 20
#connection_timeout = 60
#zeroconf = Mopidy MPD server on $hostname
#command_blacklist =
#  listall
#  listallinfo
#default_playlist_scheme = m3u

[http]
enabled = true
hostname = 10.138.175.132
port = 6680
#static_dir =
#zeroconf = Mopidy HTTP server on $hostname

[stream]
enabled = true
protocols =
  http
  https
  mms
  rtmp
  rtmps
  rtsp
#metadata_blacklist =
#timeout = 5000

[m3u]
#enabled = true
#base_dir =
#default_encoding = latin-1
#default_extension = .m3u8
#playlists_dir =

[softwaremixer]
#enabled = true

[file]
#enabled = true
#media_dirs =
#  $XDG_MUSIC_DIR|Music
#  ~/|Home
#excluded_file_extensions =
#  .jpg
#  .jpeg
#show_dotfiles = false
#follow_symlinks = false
#metadata_timeout = 1000

[local]
#enabled = true
#library = json
media_dir = /tmp
#scan_timeout = 1000
#scan_flush_threshold = 100
#scan_follow_symlinks = false
#excluded_file_extensions =
#  .directory
#  .html
#  .jpeg
#  .jpg
#  .log
#  .nfo
#  .png
#  .txt

[musicbox_webclient]
enabled = true
musicbox = true
websocket_host =
websocket_port =
on_track_click = PLAY_NOW

[dirble]
api_key = 64somerandom738387cf9fwc
countries = US,GB,NO
timeout = 5000

[websettings]
enabled = true
musicbox = true
config_file = /etc/mopidy/mopidy.conf

Like this I'm able to listen to SomaFM for example. But if I browse for dirble stations the log is showing the following Error:
WARNING [1832:DirbleBackend-8] mopidy_dirble.client: Fetching Dirble data failed: HTTPConnectionPool(host='api.dirble.com', port=80): Max retries exceeded with url: /v2/categories/tree?token=642c6a258dbe4eea1f39ce4c8b (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0xaf599950>: Failed to establish a new connection: [Errno 101] Network is unreachable',))

If I'm starting mopidy from the shell like (root@mopidybox:/# mopidy) I can browse dirble and listen to the radio.
Is this a permission thing with the mopidy user which is used while running it as a service?

Invalid or expired token

The authorisation token that is provided in the sample configuration does not work on my setup.

api_key = a4c8107f8fe57c235ce48df846720b9c816e8584

...produces 401 responses from the Dirble server with error message: Unauthorized. Invalid or expired token.

The one that is supplied with the Pi MusicBox does work however (473279e3fa0e7010cbbbb40ecc31890d46e57a2e).

I'm just looking at Dirble now so have no idea what I am doing, so my apologies in advance if I am being dense.

Error trying to browse Dirble

I get an empty list when I try to browse the Dirble 1.2.0 directory in Mopidy.

Log contains:

ERROR    DirbleBackend backend caused an exception.
Traceback (most recent call last):
  File "/Users/jcass/PycharmProjects/Mopidy/mopidy/mopidy/core/library.py", line 19, in _backend_error_handling
    yield
  File "/Users/jcass/PycharmProjects/Mopidy/mopidy/mopidy/core/library.py", line 112, in _browse
    result = backend.library.browse(uri).get()
  File "/usr/local/lib/python2.7/site-packages/pykka/threading.py", line 52, in get
    compat.reraise(*self._data['exc_info'])
  File "/usr/local/lib/python2.7/site-packages/pykka/compat.py", line 12, in reraise
    exec('raise tp, value, tb')
  File "/usr/local/lib/python2.7/site-packages/pykka/actor.py", line 201, in _actor_loop
    response = self._handle_receive(message)
  File "/usr/local/lib/python2.7/site-packages/pykka/actor.py", line 295, in _handle_receive
    return callee(*message['args'], **message['kwargs'])
  File "/usr/local/lib/python2.7/site-packages/mopidy_dirble/actor.py", line 39, in browse
    result.append(translator.country_to_ref(country))
  File "/usr/local/lib/python2.7/site-packages/mopidy_dirble/translator.py", line 44, in country_to_ref
    uri = unparse_uri('country', country['country_code'].lower())
TypeError: string indices must be integers

Tacking a quick look at the code, I can't see how

uri = unparse_uri('country', country['country_code'].lower())
could work since country only refers to the two-letter country code that is read from the config file.

Perhaps something went wrong when this was merged?

Use images from API

The available metadata seems to have been increasing, we should check what else we should add.

KeyError when browsing continents

Running Mopidy develop and Mopidy-Dirble develop (equivalent with 1.1.2).

  1. ncmpcpp
  2. Browse
  3. Dirble
  4. Select any continent: Europe, North America, etc
ERROR    2015-12-04 11:00:36,136 [9506:Core-25] mopidy.core.library
  DirbleBackend backend caused an exception.
Traceback (most recent call last):
  File "/home/jodal/mopidy-dev/mopidy/mopidy/core/library.py", line 19, in _backend_error_handling
    yield
  File "/home/jodal/mopidy-dev/mopidy/mopidy/core/library.py", line 112, in _browse
    result = backend.library.browse(uri).get()
  File "/home/jodal/dev/virtualenvs/mopidy2/local/lib/python2.7/site-packages/pykka/threading.py", line 52, in get
    compat.reraise(*self._data['exc_info'])
  File "/home/jodal/dev/virtualenvs/mopidy2/local/lib/python2.7/site-packages/pykka/compat.py", line 12, in reraise
    exec('raise tp, value, tb')
  File "/home/jodal/dev/virtualenvs/mopidy2/local/lib/python2.7/site-packages/pykka/actor.py", line 201, in _actor_loop
    response = self._handle_receive(message)
  File "/home/jodal/dev/virtualenvs/mopidy2/local/lib/python2.7/site-packages/pykka/actor.py", line 295, in _handle_receive
    return callee(*message['args'], **message['kwargs'])
  File "/home/jodal/mopidy-dev/mopidy-dirble/mopidy_dirble/actor.py", line 48, in browse
    for country in self.backend.dirble.countries(identifier):
  File "/home/jodal/mopidy-dev/mopidy-dirble/mopidy_dirble/client.py", line 102, in countries
    if continent is None or c['continent_id'] == continent:
KeyError: u'continent_id'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.