Пример #1
0
        private void AddToLibrary(CachedMovieInfo si)
        {
            // need to add a new showitem
            MovieConfiguration found = new MovieConfiguration(si.TmdbCode, TVDoc.ProviderType.TMDB);
            QuickLocateForm    f     = new QuickLocateForm(si.Name, MediaConfiguration.MediaType.movie);

            if (f.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            if (found.ConfigurationProvider == TVSettings.Instance.DefaultMovieProvider)
            {
                found.ConfigurationProvider = TVDoc.ProviderType.libraryDefault;
            }

            if (f.FolderNameChanged)
            {
                found.UseAutomaticFolders = false;
                found.UseManualLocations  = true;
                found.ManualLocations.Add(f.DirectoryFullPath);
            }
            else if (f.RootDirectory.HasValue())
            {
                found.AutomaticFolderRoot = f.RootDirectory !;
                found.UseAutomaticFolders = true;
            }

            mDoc.Add(found);
            mDoc.SetDirty();
            mDoc.ExportMovieInfo();
        }
Пример #2
0
        private void AddToLibrary(int mlastSelectedKey, TVDoc tvDoc)
        {
            switch (media)
            {
            case MediaConfiguration.MediaType.tv:
                ShowConfiguration show = new ShowConfiguration(mlastSelectedKey, TVDoc.ProviderType.TMDB);
                tvDoc.Add(show);
                break;

            case MediaConfiguration.MediaType.movie:
                MovieConfiguration newMovie = new MovieConfiguration(mlastSelectedKey, TVDoc.ProviderType.TMDB);
                tvDoc.Add(newMovie);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Пример #3
0
        private void AddToLibrary(CachedMovieInfo si)
        {
            // need to add a new showitem
            MovieConfiguration found = new MovieConfiguration(si.TmdbCode, TVDoc.ProviderType.TMDB);
            QuickLocateForm    f     = new QuickLocateForm(si.Name, MediaConfiguration.MediaType.movie);

            if (f.ShowDialog(this) == DialogResult.OK)
            {
                if (f.RootDirectory.HasValue())
                {
                    found.AutomaticFolderRoot = f.RootDirectory !;
                    found.UseAutomaticFolders = true;
                }

                ///TODO put UI to get folder - check they have not adjusted path - if so add as manual folders
                mDoc.Add(found);
                mDoc.SetDirty();
                mDoc.ExportMovieInfo();
            }
        }
Пример #4
0
        private void ProcessFile([NotNull] FileInfo droppedFile, IDialogParent owner)
        {
            if ((droppedFile.Attributes & FileAttributes.Directory) == FileAttributes.Directory)
            {
                Logger.Error($"{droppedFile.FullName} is a directory, ignoring.");
                return;
            }

            if (!droppedFile.IsMovieFile())
            {
                Logger.Info($"{droppedFile.FullName} is not a movie file, ignoring.");
                return;
            }

            // Note that the extension of the file may not be fi.extension as users can put ".mkv.t" for example as an extension
            string otherExtension = TVSettings.Instance.FileHasUsefulExtensionDetails(droppedFile, true);

            ShowConfiguration?bestShow = (string)cbShowList.SelectedItem == "<Auto>"
                ? FinderHelper.FindBestMatchingShow(droppedFile.FullName, mDoc.TvLibrary.Shows)
                : mDoc.TvLibrary.Shows.FirstOrDefault(item => item.ShowName == (string)cbShowList.SelectedItem);

            if (bestShow is null)
            {
                if (TVSettings.Instance.AutoAddAsPartOfQuickRename)
                {
                    List <MediaConfiguration> addedShows = FinderHelper.FindMedia(new List <FileInfo> {
                        droppedFile
                    }, mDoc, owner);
                    bestShow = addedShows.OfType <ShowConfiguration>().FirstOrDefault();

                    if (bestShow != null)
                    {
                        mDoc.Add(bestShow);
                        mDoc.TvAddedOrEdited(true, false, false, parent, bestShow);

                        Logger.Info($"Added new show called: {bestShow.ShowName}");
                    }
                }

                if (bestShow is null)
                {
                    Logger.Info($"Cannot find show for {droppedFile.FullName}, ignoring this file.");
                    return;
                }
            }

            if (!FinderHelper.FindSeasEp(droppedFile, out int seasonNum, out int episodeNum, out int _, bestShow,
                                         out TVSettings.FilenameProcessorRE _))
            {
                Logger.Info($"Cannot find episode for {bestShow.ShowName} for {droppedFile.FullName}, ignoring this file.");
                return;
            }

            try
            {
                ProcessedEpisode episode = bestShow.GetEpisode(seasonNum, episodeNum);

                string filename = TVSettings.Instance.FilenameFriendly(
                    TVSettings.Instance.NamingStyle.NameFor(episode, otherExtension,
                                                            droppedFile.DirectoryName.Length));

                FileInfo targetFile =
                    new FileInfo(droppedFile.DirectoryName.EnsureEndsWithSeparator() + filename);

                if (droppedFile.FullName == targetFile.FullName)
                {
                    Logger.Info(
                        $"Can't rename file for {bestShow.ShowName} for {droppedFile.FullName}, as it already has the appropriate name.");

                    return;
                }

                mDoc.TheActionList.Add(new ActionCopyMoveRename(droppedFile, targetFile, episode, mDoc));

                // if we're copying/moving a file across, we might also want to make a thumbnail or NFO for it
                mDoc.TheActionList.AddNullableRange(new DownloadIdentifiersController().ProcessEpisode(episode, targetFile));

                //If keep together is active then we may want to copy over related files too
                if (TVSettings.Instance.KeepTogether)
                {
                    FileFinder.KeepTogether(mDoc.TheActionList, false, true, mDoc);
                }
            }
            catch (ShowConfiguration.EpisodeNotFoundException)
            {
                Logger.Info(
                    $"Can't rename file for {bestShow.ShowName} for {droppedFile.FullName}, as it does not have Episode {episodeNum} for Season {seasonNum}.");
            }
        }