Merge pull request #1016 from geogolem/exclusionsFix

Exclusions fix
geogolem 8 years ago committed by GitHub
commit 0aa6066a6f

@ -92,7 +92,7 @@ namespace NzbDrone.Core.NetImport
bool foundMatch = false; bool foundMatch = false;
foreach (var listedMovie in listedMovies) foreach (var listedMovie in listedMovies)
{ {
if (movie.ImdbId == listedMovie.ImdbId) if (movie.TmdbId == listedMovie.TmdbId)
{ {
foundMatch = true; foundMatch = true;
break; break;
@ -146,11 +146,16 @@ namespace NzbDrone.Core.NetImport
{ {
foreach (var exclusion in importExclusions) foreach (var exclusion in importExclusions)
{ {
if (exclusion == movie.ImdbId || exclusion == movie.TmdbId.ToString()) //var excludedTmdbId = exclusion.Substring(exclusion.LastIndexOf('-')+1);
int excludedTmdbId;
if (Int32.TryParse(exclusion.Substring(exclusion.LastIndexOf('-') + 1), out excludedTmdbId))
{ {
_logger.Info("Movie: {0} was found but will not be added because {1} was found on your exclusion list",movie, exclusion); if (excludedTmdbId == movie.TmdbId)
shouldAdd = false; {
break; _logger.Info("Movie: {0} was found but will not be added because {1} was found on your exclusion list", movie, exclusion);
shouldAdd = false;
break;
}
} }
} }
} }

@ -250,11 +250,11 @@ namespace NzbDrone.Core.Tv
{ {
if (_configService.ImportExclusions.Empty()) if (_configService.ImportExclusions.Empty())
{ {
_configService.ImportExclusions = movie.ImdbId; _configService.ImportExclusions = movie.TitleSlug;
} }
else if (!_configService.ImportExclusions.Contains(movie.ImdbId) && !_configService.ImportExclusions.Contains(movie.TmdbId.ToString())) else if (!_configService.ImportExclusions.Contains(movie.TitleSlug))
{ {
_configService.ImportExclusions += ',' + movie.ImdbId; _configService.ImportExclusions += ',' + movie.TitleSlug;
} }
} }
_movieRepository.Delete(movieId); _movieRepository.Delete(movieId);

@ -95,6 +95,7 @@
} }
} }
/*
var itemValue = self.options.itemValue(item), var itemValue = self.options.itemValue(item),
itemText = self.options.itemText(item), itemText = self.options.itemText(item),
tagClass = self.options.tagClass(item); tagClass = self.options.tagClass(item);
@ -113,7 +114,7 @@
// if length greater than limit // if length greater than limit
if (self.items().toString().length + item.length + 1 > self.options.maxInputLength) if (self.items().toString().length + item.length + 1 > self.options.maxInputLength)
return; return;
*/
// raise beforeItemAdd arg // raise beforeItemAdd arg
var beforeItemAddEvent = $.Event('beforeItemAdd', { item: item, cancel: false }); var beforeItemAddEvent = $.Event('beforeItemAdd', { item: item, cancel: false });
self.$element.trigger(beforeItemAddEvent); self.$element.trigger(beforeItemAddEvent);
@ -121,8 +122,46 @@
return; return;
// register item in internal array and map // register item in internal array and map
//self.itemsArray.push(item);
// read var beforeItemAddEvent with new value
var item = beforeItemAddEvent.item; // Get text from event (BeforeItemAddEvent)
var itemValue = self.options.itemValue(item),
itemText = self.options.itemText(item),
tagClass = self.options.tagClass(item);
// Ignore items allready added
var existing = $.grep(self.itemsArray, function(item) { return self.options.itemValue(item) === itemValue; } )[0];
if (existing && !self.options.allowDuplicates) {
// Invoke onTagExists
if (self.options.onTagExists) {
var $existingTag = $(".tag", self.$container).filter(function() { return $(this).data("item") === existing; });
self.options.onTagExists(item, $existingTag);
}
return;
}
// if length greater than limit
if (self.items().toString().length + item.length + 1 > self.options.maxInputLength)
return;
// register item in internal array and map
self.itemsArray.push(item); self.itemsArray.push(item);
if (beforeItemAddEvent.tagClass !== undefined){ var tagClass = beforeItemAddEvent.tagClass; }
if (item != undefined){
var items = item.toString().split(',');
if (items.length > 1) {
for (var i = 0; i < items.length; i++) {
this.add(items[i], true);
}
if (!dontPushVal)
self.pushVal(self.options.triggerChange);
return;
}
}
// add a tag element // add a tag element
var $tag = $('<span class="tag ' + htmlEncode(tagClass) + '">' + htmlEncode(itemText) + '<span data-role="remove"></span></span>'); var $tag = $('<span class="tag ' + htmlEncode(tagClass) + '">' + htmlEncode(itemText) + '<span data-role="remove"></span></span>');
$tag.data('item', item); $tag.data('item', item);

@ -90,12 +90,19 @@ var view = Marionette.ItemView.extend({
}); });
promise.success(function(response) { promise.success(function(response) {
event.cancel=false; event.cancel=false;
//var newText = response['tmdbId']+'-';
//if (event.item.startsWith('tt')) {
// newText = newText+'['+event.item+']';
//}
event.item = response['titleSlug'];//+' ('+response['year']+')-'+response['tmdbId'];
}); });
promise.error(function(request, status, error) { promise.error(function(request, status, error) {
event.cancel = true; event.cancel = true;
window.alert(event.item+' is not a valid! Must be valid tt#### IMDB ID or #### TMDB ID'); window.alert(event.item+' is not a valid! Must be valid tt#### IMDB ID or #### TMDB ID');
}); });
return event;
}); });
}, },

@ -32,11 +32,11 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">Import Exclusions</label> <label class="col-sm-3 control-label">Import Exclusions</label>
<div class="col-sm-1 col-sm-push-2 help-inline"> <div class="col-sm-1 col-sm-push-4 help-inline">
<i class="icon-sonarr-form-warning" title="Movies in this field will not be imported even if they exist on your lists."/> <i class="icon-sonarr-form-warning" title="Movies in this field will not be imported even if they exist on your lists."/>
<i class="icon-sonarr-form-info" title="Comma separated imdbid or tmdbid: tt0120915,216138,tt0121765"/> <i class="icon-sonarr-form-info" title="Comma separated imdbid or tmdbid: tt0120915,216138,tt0121765"/>
</div> </div>
<div class="col-sm-2 col-sm-pull-1"> <div class="col-sm-4 col-sm-pull-1">
<input type="text" name="importExclusions" class="form-control x-import-exclusions"/> <input type="text" name="importExclusions" class="form-control x-import-exclusions"/>
</div> </div>

Loading…
Cancel
Save