Beispiel #1
0
        public List <ManualImportResource> GetMediaFiles(string folder, string downloadId, int?authorId, bool filterExistingFiles = true, bool replaceExistingFiles = true)
        {
            NzbDrone.Core.Books.Author author = null;

            if (authorId > 0)
            {
                author = _authorService.GetAuthor(authorId.Value);
            }

            var filter = filterExistingFiles ? FilterFilesType.Matched : FilterFilesType.None;

            return(_manualImportService.GetMediaFiles(folder, downloadId, author, filter, replaceExistingFiles).ToResource().Select(AddQualityWeight).ToList());
        }
Beispiel #2
0
        public static AuthorResource ToResource(this NzbDrone.Core.Books.Author model)
        {
            if (model == null)
            {
                return(null);
            }

            return(new AuthorResource
            {
                Id = model.Id,
                AuthorMetadataId = model.AuthorMetadataId,

                AuthorName = model.Name,
                AuthorNameLastFirst = model.Metadata.Value.NameLastFirst,

                //AlternateTitles
                SortName = model.Metadata.Value.SortName,
                SortNameLastFirst = model.Metadata.Value.SortNameLastFirst,

                Status = model.Metadata.Value.Status,
                Overview = model.Metadata.Value.Overview,
                Disambiguation = model.Metadata.Value.Disambiguation,

                Images = model.Metadata.Value.Images.JsonClone(),

                Path = model.Path,
                QualityProfileId = model.QualityProfileId,
                MetadataProfileId = model.MetadataProfileId,
                Links = model.Metadata.Value.Links,

                Monitored = model.Monitored,
                MonitorNewItems = model.MonitorNewItems,

                CleanName = model.CleanName,
                ForeignAuthorId = model.Metadata.Value.ForeignAuthorId,
                TitleSlug = model.Metadata.Value.TitleSlug,

                // Root folder path is now calculated from the author path
                // RootFolderPath = model.RootFolderPath,
                Genres = model.Metadata.Value.Genres,
                Tags = model.Tags,
                Added = model.Added,
                AddOptions = model.AddOptions,
                Ratings = model.Metadata.Value.Ratings,

                Statistics = new AuthorStatisticsResource()
            });
        }
Beispiel #3
0
        private List <ManualImportResource> GetMediaFiles()
        {
            var folder     = (string)Request.Query.folder;
            var downloadId = (string)Request.Query.downloadId;

            NzbDrone.Core.Books.Author author = null;

            var authorIdQuery = Request.GetNullableIntegerQueryParameter("authorId", null);

            if (authorIdQuery.HasValue && authorIdQuery.Value > 0)
            {
                author = _authorService.GetAuthor(Convert.ToInt32(authorIdQuery.Value));
            }

            var filter = Request.GetBooleanQueryParameter("filterExistingFiles", true) ? FilterFilesType.Matched : FilterFilesType.None;
            var replaceExistingFiles = Request.GetBooleanQueryParameter("replaceExistingFiles", true);

            return(_manualImportService.GetMediaFiles(folder, downloadId, author, filter, replaceExistingFiles).ToResource().Select(AddQualityWeight).ToList());
        }
Beispiel #4
0
        public static NzbDrone.Core.Books.Author ToModel(this AuthorResource resource, NzbDrone.Core.Books.Author author)
        {
            var updatedAuthor = resource.ToModel();

            author.ApplyChanges(updatedAuthor);

            return(author);
        }
Beispiel #5
0
 protected override RemoteData GetRemoteData(Series local, List <Series> remote, Author data)
 {
     return(new RemoteData
     {
         Entity = remote.SingleOrDefault(x => x.ForeignSeriesId == local.ForeignSeriesId)
     });
 }
Beispiel #6
0
        public bool RefreshSeriesInfo(int authorMetadataId, List <Series> remoteSeries, Author remoteData, bool forceBookRefresh, bool forceUpdateFileTags, DateTime?lastUpdate)
        {
            var updated = false;

            var existingByAuthor = _seriesService.GetByAuthorMetadataId(authorMetadataId);
            var existingBySeries = _seriesService.FindById(remoteSeries.Select(x => x.ForeignSeriesId));
            var existing         = existingByAuthor.Concat(existingBySeries).GroupBy(x => x.ForeignSeriesId).Select(x => x.First()).ToList();

            var books    = _bookService.GetBooksByAuthorMetadataId(authorMetadataId);
            var bookDict = books.ToDictionary(x => x.ForeignBookId);
            var links    = new List <SeriesBookLink>();

            foreach (var s in remoteData.Series.Value)
            {
                s.LinkItems.Value.ForEach(x => x.Series = s);
                links.AddRange(s.LinkItems.Value.Where(x => bookDict.ContainsKey(x.Book.Value.ForeignBookId)));
            }

            var grouped = links.GroupBy(x => x.Series.Value);

            // Put in the links that go with the books we actually have
            foreach (var group in grouped)
            {
                group.Key.LinkItems = group.ToList();
            }

            remoteSeries = grouped.Select(x => x.Key).ToList();

            var toAdd = remoteSeries.ExceptBy(x => x.ForeignSeriesId, existing, x => x.ForeignSeriesId, StringComparer.Ordinal).ToList();
            var all   = toAdd.Union(existing).ToList();

            _seriesService.InsertMany(toAdd);

            foreach (var item in all)
            {
                item.ForeignAuthorId = remoteData.ForeignAuthorId;
                updated |= RefreshEntityInfo(item, remoteSeries, remoteData, true, forceUpdateFileTags, null);
            }

            return(updated);
        }
Beispiel #7
0
 protected override bool RefreshChildren(SortedChildren localChildren, List <SeriesBookLink> remoteChildren, Author remoteData, bool forceChildRefresh, bool forceUpdateFileTags, DateTime?lastUpdate)
 {
     return(_refreshLinkService.RefreshSeriesBookLinkInfo(localChildren.Added, localChildren.Updated, localChildren.Merged, localChildren.Deleted, localChildren.UpToDate, remoteChildren, forceUpdateFileTags));
 }