Skip to content

Commit

Permalink
config: add external file
Browse files Browse the repository at this point in the history
config: fix schema change
Bump version
  • Loading branch information
Janez Troha committed Apr 18, 2013
1 parent a37c55a commit b419c05
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 24 deletions.
34 changes: 10 additions & 24 deletions mopidy_soundcloud/__init__.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,10 @@
from __future__ import unicode_literals

from mopidy import ext
import os
from mopidy import ext, config
from mopidy.exceptions import ExtensionError
from mopidy.utils import config, formatting


default_config = """
[soundcloud]
enabled = True
# Your SoundCloud auth token, you can get yours at http://www.mopidy.com/authenticate
auth_token =
# Extra playlists from http://www.soundcloud.com/explore
explore = pop/Easy Listening, rock/Indie, electronic/Ambient
# Number of pages (which roughly translates to hours) to fetch
explore_pages = 1
"""

__doc__ = """A extension for playing music from SoundCloud.
This extension handles URIs starting with ``soundcloud:`` and enables you,
Expand All @@ -39,10 +25,9 @@
.. code-block:: ini
%(config)s
""" % {'config': formatting.indent(default_config)}
"""

__version__ = '1.0.10'
__version__ = '1.0.12'


class SoundCloudExtension(ext.Extension):
Expand All @@ -52,13 +37,14 @@ class SoundCloudExtension(ext.Extension):
version = __version__

def get_default_config(self):
return default_config
conf_file = os.path.join(os.path.dirname(__file__), 'ext.conf')
return config.read(conf_file)

def get_config_schema(self):
schema = config.ExtensionConfigSchema()
schema['explore'] = config.List(required=False)
schema['explore_pages'] = config.Integer(required=False)
schema['auth_token'] = config.String(secret=True)
schema = super(SoundCloudExtension, self).get_config_schema()
schema['explore'] = config.List()
schema['explore_pages'] = config.Integer()
schema['auth_token'] = config.Secret()
return schema

def validate_config(self, config):
Expand Down
11 changes: 11 additions & 0 deletions mopidy_soundcloud/ext.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[soundcloud]
enabled = True

# Your SoundCloud auth token, you can get yours at http://www.mopidy.com/authenticate
auth_token =

# Extra playlists from http://www.soundcloud.com/explore
explore = pop/Easy Listening, rock/Indie, electronic/Ambient

# Number of pages (which roughly translates to hours) to fetch
explore_pages = 1
1 change: 1 addition & 0 deletions mopidy_soundcloud/soundcloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ def parse_track(self, data, remote_url=False, is_search=False):
artist_kwargs[b'name'] = data.get('user').get('username')

album_kwargs[b'name'] = 'SoundCloud'
#album_kwargs[b'url'] = data.get('permalink_url')

if 'date' in data:
track_kwargs[b'date'] = data['date']
Expand Down

0 comments on commit b419c05

Please sign in to comment.