Beispiel #1
0
        private static void FindMissingEpisode([NotNull] MovieItemMissing action, ItemList toRemove, ItemList newItems)
        {
            string url = TVSettings.Instance.UseJackettTextSearch ? TextJackettUrl(action.MovieConfig) : NormalJackettUrl(action.MovieConfig);

            RssItemList rssList = new RssItemList();

            rssList.DownloadRSS(url, false, "Jackett");
            ItemList newItemsForThisMissingEpisode = new ItemList();

            foreach (RSSItem rss in rssList.Where(rss => RssMatch(rss, action.MovieConfig)))
            {
                if (TVSettings.Instance.DetailedRSSJSONLogging)
                {
                    LOGGER.Info(
                        $"Adding {rss.URL} from RSS feed as it appears to be match for {action.MovieConfig.ShowName}");
                }
                newItemsForThisMissingEpisode.Add(new ActionTDownload(rss, action.TheFileNoExt, action));
                toRemove.Add(action);
            }

            foreach (ActionTDownload x in FindDuplicates(newItemsForThisMissingEpisode))
            {
                newItemsForThisMissingEpisode.Remove(x);
            }

            newItems.AddNullableRange(newItemsForThisMissingEpisode);
        }
Beispiel #2
0
 private static int TypeNumber(Item a)
 {
     return(a switch
     {
         ShowItemMissing _ => 1,
         MovieItemMissing _ => 2,
         ActionCopyMoveRename _ => 3,
         ActionMoveRenameDirectory _ => 4,
         ActionTDownload _ => 5,
         ActionDownloadImage _ => 6,
         ActionMede8erViewXML _ => 7,
         ActionMede8erXML _ => 8,
         ActionNfo _ => 9,
         ActionPyTivoMeta _ => 10,
         ActionWdtvMeta _ => 11,
         ItemDownloading _ => 12,
         ActionDeleteFile _ => 13,
         ActionDeleteDirectory _ => 14,
         ActionDateTouchEpisode _ => 15,
         ActionDateTouchSeason _ => 16,
         ActionDateTouchMedia _ => 17,
         ActionDateTouchMovie _ => 18,
         ActionTRemove _ => 19,
         _ => throw new NotSupportedException()
     });
Beispiel #3
0
        private void FindMovie(TVDoc.ScanSettings settings, MovieItemMissing mim, DirFilesCache dfc, ItemList newList, ItemList toRemove)
        {
            if (!mim.MovieConfig.UseAutomaticFolders)
            {
                return;
            }
            (string targetFolder, string targetFolderEarlier, string targetFolderLater) = mim.MovieConfig.NeighbouringFolderNames();

            TestShouldMove(targetFolderEarlier, targetFolder, dfc, newList, toRemove, mim);
            TestShouldMove(targetFolderLater, targetFolder, dfc, newList, toRemove, mim);
        }
Beispiel #4
0
        private void WarnPathTooLong([NotNull] MovieItemMissing me, [NotNull] FileInfo dce, [NotNull] Exception e, bool matched)
        {
            string t = "Path too long. " + dce.FullName + ", " + e.Message;

            LOGGER.Error(e, "Path too long. " + dce.FullName);

            t += ".  More information is available in the log file";
            if (!MDoc.Args.Unattended && !MDoc.Args.Hide && Environment.UserInteractive)
            {
                MessageBox.Show(t, "Path too long", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            t  = "DirectoryName " + dce.DirectoryName + ", File name: " + dce.Name;
            t += matched ? ", matched.  " : ", no match.  ";
            if (matched)
            {
                t += "Show: " + me.MovieConfig.ShowName + ".  ";
                t += "To: " + me.TheFileNoExt;
            }

            LOGGER.Warn(t);
        }
Beispiel #5
0
        protected bool ReviewFile(MovieItemMissing me, ItemList addTo, FileInfo dce, TVDoc.ScanSettings settings, bool preventMove, bool doExtraFiles, bool useFullPath)
        {
            if (settings.Token.IsCancellationRequested)
            {
                return(false);
            }

            bool matched = false;

            try
            {
                if (dce.IgnoreFile() || me.Movie is null)
                {
                    return(false);
                }

                //do any of the possible names for the cachedSeries match the filename?
                matched = me.Show.NameMatch(dce, useFullPath);

                if (!matched)
                {
                    return(false);
                }

                if (me.Show.LengthNameMatch(dce, useFullPath) != MDoc.FilmLibrary.Movies.MaxOrDefault(m => m.LengthNameMatch(dce, useFullPath), 0))
                {
                    int c = 1;
                    return(false);
                }

                FileInfo fi = FinderHelper.GenerateTargetName(me, dce);

                if (preventMove)
                {
                    //We do not want to move the file, just rename it
                    fi = new FileInfo(dce.DirectoryName.EnsureEndsWithSeparator() + me.Filename + dce.Extension);
                }

                if (dce.FullName != fi.FullName && !FindExistingActionFor(addTo, dce))
                {
                    // don't remove the base search folders
                    bool doTidyup =
                        !TVSettings.Instance.DownloadFolders.Any(folder =>
                                                                 folder.SameDirectoryLocation(fi.Directory.FullName));

                    addTo.Add(new ActionCopyMoveRename(ActionCopyMoveRename.Op.copy, dce, fi, me.Movie, doTidyup, me, MDoc));
                }

                if (doExtraFiles)
                {
                    DownloadIdentifiersController di = new DownloadIdentifiersController();

                    // if we're copying/moving a file across, we might also want to make a thumbnail or NFO for it
                    addTo.Add(di.ProcessMovie(me.MovieConfig, fi));
                }

                return(true);
            }
            catch (PathTooLongException e)
            {
                WarnPathTooLong(me, dce, e, matched);
            }
            return(false);
        }
Beispiel #6
0
        private void TestShouldMove(string sourceFolder, string targetFolder, DirFilesCache dfc, ItemList newList, ItemList toRemove, MovieItemMissing mim)
        {
            if (sourceFolder == targetFolder)
            {
                return;
            }

            if (dfc.GetFiles(targetFolder).Length > 0)
            {
                //do not want to copy any files over new location
                return;
            }

            if (!Directory.Exists(sourceFolder) || dfc.GetFiles(sourceFolder).Length == 0)
            {
                return;
            }
            LOGGER.Info($"Have identified that {sourceFolder} can be copied to {targetFolder}");

            toRemove.Add(mim);
            newList.Add(new ActionMoveRenameDirectory(sourceFolder, targetFolder, mim.MovieConfig));
        }