diff --git a/beetsplug/importfeeds.py b/beetsplug/importfeeds.py index 9785a4a25..294a03703 100644 --- a/beetsplug/importfeeds.py +++ b/beetsplug/importfeeds.py @@ -33,6 +33,7 @@ class ImportFeedsPlugin(BeetsPlugin): 'formats': [], 'm3u_name': u'imported.m3u', 'dir': None, + 'relative_to': None, }) feeds_dir = self.config['dir'].get() @@ -42,6 +43,12 @@ class ImportFeedsPlugin(BeetsPlugin): if not os.path.exists(syspath(feeds_dir)): os.makedirs(syspath(feeds_dir)) + relative_to = self.config['relative_to'].get() + if relative_to: + self.config['relative_to'] = os.path.expanduser(bytestring_path(relative_to)) + else: + self.config['relative_to'] = feeds_dir + def _get_feeds_dir(lib): """Given a Library object, return the path to the feeds directory to be used (either in the library directory or an explicitly configured @@ -78,12 +85,13 @@ def _record_items(lib, basename, items): """Records relative paths to the given items for each feed format """ feedsdir = config['importfeeds']['dir'].as_filename() + relative_to = config['importfeeds']['relative_to'].as_filename() formats = config['importfeeds']['formats'].as_str_seq() paths = [] for item in items: paths.append(os.path.relpath( - item.path, feedsdir + item.path, relative_to )) if 'm3u' in formats: diff --git a/docs/plugins/importfeeds.rst b/docs/plugins/importfeeds.rst index 745cb1702..bad3742c3 100644 --- a/docs/plugins/importfeeds.rst +++ b/docs/plugins/importfeeds.rst @@ -8,8 +8,15 @@ To use the plugin, just put ``importfeeds`` on the ``plugins`` line in your ``importfeeds:`` section in the config file. The ``dir`` configuration option can be set to specify another folder -than the default library directory. Three different types of outputs coexist, -specify the ones you want to use by setting the ``formats`` parameter: +than the default library directory. + +the ``relative_to`` configuration option can be set to write the m3u paths +relative to another folder than where the playlist is being written. If you are +using importfeeds to genereate a playlist for mpd, you should set this to the +root of your music library. + +Three different types of outputs coexist, specify the ones you want to use by +setting the ``formats`` parameter: - ``m3u``: catalog the imports in a centralized playlist. By default, the playlist is named ``imported.m3u``. To use a different file, just set the ``m3u_name`` parameter inside the ``importfeeds`` config section. - ``m3u_multi``: create a new playlist for each import (uniquely named by appending the date and track/album name). @@ -20,4 +27,5 @@ Here's an example configuration for this plugin:: importfeeds: formats: m3u link dir: ~/imports/ + relative_to: ~/Music/ m3u_name: newfiles.m3u