diff --git a/server/components.py b/server/components.py
index a952d3b..2b4d976 100644
--- a/server/components.py
+++ b/server/components.py
@@ -326,7 +326,8 @@
"type" : "filter",
"description": "Remove any duplicate tracks in the stream",
"help" : """ This component will remove any duplicate tracks from
- the stream. If By Name is set, then tracks dedupped by
+ the stream.
+ If By Name is set, then tracks dedupped by
artist and title, otherwise, they are dedupped based upon their
track id""",
"params": {
@@ -430,6 +431,8 @@
produce a stream of tracks that consist of the tracks on the green
input stream with the tracks that are not on the red
stream.
+ If By Name is set, then tracks are matched by name in
+ addition to the regular ID match
""",
"params": {
"true_source": {
@@ -452,6 +455,13 @@
"optional" : True,
"description": "if set, only tracks on both input streams will be passed through"
},
+ "by_name": {
+ "display" : "By name",
+ "type" : "bool",
+ "optional" : True,
+ "default": False,
+ "description": " if True also match by name in addition to the regular ID match",
+ },
}
},
{
diff --git a/server/plugs.py b/server/plugs.py
index 1a7be31..8a7c836 100644
--- a/server/plugs.py
+++ b/server/plugs.py
@@ -103,7 +103,7 @@ class TrackFilter(object):
'''
produces tracks on the true source that are not on the false source
'''
- def __init__(self, true_source, false_source, invert=False):
+ def __init__(self, true_source, false_source, invert=False, by_name=False):
prep = ' that are also in ' if invert else ' that are not in '
self.name = 'tracks in ' + true_source.name + prep + \
false_source.name
@@ -112,25 +112,34 @@ def __init__(self, true_source, false_source, invert=False):
self.bad_tracks = set()
self.invert = invert
self.debug = False
+ self.by_name = by_name
def next_track(self):
while True:
bad_track = self.false_source.next_track()
+ self.bad_tracks.add(bad_track)
if bad_track:
- self.bad_tracks.add(bad_track)
+ if self.by_name:
+ bad_track_name = pbl.tlib.get_tn(bad_track).lower()
+ self.bad_tracks.add(bad_track_name)
else:
break
while True:
track = self.true_source.next_track()
if track:
- if self.invert and (track in self.bad_tracks):
+ if self.by_name:
+ track_name = pbl.tlib.get_tn(track).lower()
+ else:
+ track_name = track
+
+ if self.invert and ((track in self.bad_tracks) or (track_name in self.bad_tracks)):
return track
- elif (not self.invert) and (track not in self.bad_tracks):
+ elif (not self.invert) and ((track not in self.bad_tracks) and (track_name not in self.bad_tracks)):
return track
else:
if self.debug:
- print 'filtered out', tlib.get_tn(track)
+ print 'filtered out', pbl.tlib.get_tn(track)
else:
break
return None
@@ -168,7 +177,7 @@ def next_track(self):
return track
else:
if self.debug:
- print 'filtered out', tlib.get_tn(track)
+ print 'filtered out', pbl.tlib.get_tn(track)
else:
break
return None