store titleSlug in tags for exclusions and always use TMDBID

geogolem 8 years ago
parent a3c0f4cb3f
commit 3dd14c72c8

@ -25,13 +25,11 @@ namespace NzbDrone.Core.NetImport
private readonly ISearchForNewMovie _movieSearch;
private readonly IRootFolderService _rootFolder;
private readonly IConfigService _configService;
private readonly IProvideMovieInfo _movieInfo;
public NetImportSearchService(INetImportFactory netImportFactory, IMovieService movieService,
ISearchForNewMovie movieSearch, IRootFolderService rootFolder, IConfigService configService, IProvideMovieInfo movieInfo, Logger logger)
ISearchForNewMovie movieSearch, IRootFolderService rootFolder, IConfigService configService, Logger logger)
{
_movieInfo = movieInfo;
_netImportFactory = netImportFactory;
_movieService = movieService;
_movieSearch = movieSearch;
@ -144,24 +142,15 @@ namespace NzbDrone.Core.NetImport
foreach (var movie in movies)
{
bool shouldAdd = true;
var mapped = _movieSearch.MapMovieToTmdbMovie(movie);
if (mapped != null)
{
if (importExclusions != null)
{
foreach (var exclusion in importExclusions)
{
int tmdbId;
if (exclusion.StartsWith("tt"))
//var excludedTmdbId = exclusion.Substring(exclusion.LastIndexOf('-')+1);
int excludedTmdbId;
if (Int32.TryParse(exclusion.Substring(exclusion.LastIndexOf('-') + 1), out excludedTmdbId))
{
var result = _movieInfo.GetMovieInfo(exclusion);
tmdbId = result.TmdbId;
}
else
{
tmdbId = Int32.Parse(exclusion);
}
if (tmdbId == movie.TmdbId)
if (excludedTmdbId == movie.TmdbId)
{
_logger.Info("Movie: {0} was found but will not be added because {1} was found on your exclusion list", movie, exclusion);
shouldAdd = false;
@ -169,7 +158,10 @@ namespace NzbDrone.Core.NetImport
}
}
}
if (shouldAdd)
}
var mapped = _movieSearch.MapMovieToTmdbMovie(movie);
if ((mapped != null) && shouldAdd)
{
_movieService.AddMovie(mapped);
}
@ -177,4 +169,3 @@ namespace NzbDrone.Core.NetImport
}
}
}
}

@ -244,11 +244,11 @@ namespace NzbDrone.Core.Tv
{
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);

@ -95,6 +95,7 @@
}
}
/*
var itemValue = self.options.itemValue(item),
itemText = self.options.itemText(item),
tagClass = self.options.tagClass(item);
@ -113,16 +114,54 @@
// if length greater than limit
if (self.items().toString().length + item.length + 1 > self.options.maxInputLength)
return;
*/
// raise beforeItemAdd arg
var beforeItemAddEvent = $.Event('beforeItemAdd', { item: item, cancel: false });
self.$element.trigger(beforeItemAddEvent);
if (beforeItemAddEvent.cancel)
return;
// 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);
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
var $tag = $('<span class="tag ' + htmlEncode(tagClass) + '">' + htmlEncode(itemText) + '<span data-role="remove"></span></span>');
$tag.data('item', item);

@ -90,12 +90,19 @@ var view = Marionette.ItemView.extend({
});
promise.success(function(response) {
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) {
event.cancel = true;
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 class="form-group">
<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-info" title="Comma separated imdbid or tmdbid: tt0120915,216138,tt0121765"/>
</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"/>
</div>

Loading…
Cancel
Save