diff --git a/beetsplug/importfeeds.py b/beetsplug/importfeeds.py index 8bf90aa23..e42a1b367 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() @@ -41,6 +42,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 @@ -77,12 +84,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: