Esempio n. 1
0
        public static (ImportFolder, string) GetDestination(SVR_VideoLocal_Place place)
        {
            foreach (var renamer in GetPluginRenamersSorted())
            {
                MoveEventArgs args = GetMoveEventArgs(place);
                renamer.GetDestination(args);
                if (args.Cancel)
                {
                    return(null, null);
                }
                if (string.IsNullOrEmpty(args.DestinationPath) || args.DestinationImportFolder == null)
                {
                    continue;
                }
                var importFolder = RepoFactory.ImportFolder.GetByImportLocation(args.DestinationImportFolder.Location);
                if (importFolder != null)
                {
                    return(importFolder, args.DestinationPath);
                }
                Logger.Error(
                    $"Renamer returned a Destination Import Folder, but it could not be found. The offending plugin was {renamer.GetType().GetAssemblyName()}");
            }

            (ImportFolder dest, string folder) = GetRenamerWithFallback().GetDestinationFolder(place);
            if (dest != null && !string.IsNullOrEmpty(folder))
            {
                return(dest, folder);
            }

            return(null, null);
        }
Esempio n. 2
0
        public void DeleteAllErroredFiles()
        {
            if (ActiveScan == null)
            {
                return;
            }
            var files = ActiveErrorFiles.ToList();

            ActiveErrorFiles.Clear();
            HashSet <SVR_AnimeEpisode> episodesToUpdate = new HashSet <SVR_AnimeEpisode>();
            HashSet <SVR_AnimeSeries>  seriesToUpdate   = new HashSet <SVR_AnimeSeries>();

            using (var session = DatabaseFactory.SessionFactory.OpenSession())
            {
                files.ForEach(file =>
                {
                    SVR_VideoLocal_Place place = RepoFactory.VideoLocalPlace.GetByID(file.VideoLocal_Place_ID);
                    place.RemoveAndDeleteFileWithOpenTransaction(session, seriesToUpdate);
                });
                // update everything we modified
                foreach (SVR_AnimeSeries ser in seriesToUpdate)
                {
                    ser?.QueueUpdateStats();
                }
            }
            RepoFactory.ScanFile.Delete(files);
        }
Esempio n. 3
0
        public static string GetFilename(SVR_VideoLocal_Place place, string fallbackScript = null)
        {
            string result = Path.GetFileName(place.FilePath);

            foreach (var renamer in GetPluginRenamersSorted())
            {
                RenameEventArgs args = GetRenameEventArgs(place);
                renamer.GetFilename(args);
                if (args.Cancel)
                {
                    return(null);
                }
                if (string.IsNullOrEmpty(args.Result))
                {
                    continue;
                }
                return(args.Result);
            }

            string attempt = fallbackScript == null
                ? GetEnabledLegacyRenamer()?.GetFileName(place)
                : GetRenamer(fallbackScript)?.GetFileName(place);

            if (attempt != null)
            {
                result = attempt;
            }

            return(result);
        }
Esempio n. 4
0
        public static List <Stream> GetSubtitleStreams(SVR_VideoLocal_Place vplace)
        {
            List <Stream> ls = new VobSubSubtitles().Process(vplace);

            ls.AddRange(new TextSubtitles().Process(vplace));
            return(ls);
        }
Esempio n. 5
0
        public override void ProcessCommand()
        {
            logger.Info("Reading Media Info for File: {0}", VideoLocalID);


            try
            {
                SVR_VideoLocal       vlocal = RepoFactory.VideoLocal.GetByID(VideoLocalID);
                SVR_VideoLocal_Place place  = vlocal?.GetBestVideoLocalPlace();
                if (place == null)
                {
                    logger.Error("Cound not find Video: {0}", VideoLocalID);
                    return;
                }
                if (place.RefreshMediaInfo())
                {
                    RepoFactory.VideoLocal.Save(place.VideoLocal, true);
                }
            }
            catch (Exception ex)
            {
                logger.Error("Error processing CommandRequest_ReadMediaInfo: {0} - {1}", VideoLocalID, ex.ToString());
                return;
            }
        }
        public override void ProcessCommand()
        {
            logger.Info("Reading Media Info for File: {0}", VideoLocalID);


            try
            {
                SVR_VideoLocal       vlocal = Repo.Instance.VideoLocal.GetByID(VideoLocalID);
                SVR_VideoLocal_Place place  = vlocal?.GetBestVideoLocalPlace(true);
                if (place == null)
                {
                    logger.Error("Cound not find Video: {0}", VideoLocalID);
                    return;
                }
                using (var txn = Repo.Instance.VideoLocal.BeginAddOrUpdate(() => place.VideoLocal))
                {
                    if (place.RefreshMediaInfo(txn.Entity))
                    {
                        txn.Commit();
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error("Error processing CommandRequest_ReadMediaInfo: {0} - {1}", VideoLocalID, ex);
            }
        }
Esempio n. 7
0
        public List <Stream> Process(SVR_VideoLocal_Place vplace)
        {
            string dirname = Path.GetDirectoryName(vplace.FullServerPath);
            string fname   = Path.GetFileNameWithoutExtension(vplace.FilePath);

            if (string.IsNullOrEmpty(dirname) || string.IsNullOrEmpty(fname))
            {
                return(null);
            }
            string           basename   = Path.Combine(dirname, fname);
            HashSet <string> extensions = new HashSet <string>(SubtitleHelper.Extensions.Keys);

            extensions.Remove("idx");
            List <Stream> streams = new List <Stream>();

            foreach (string n in extensions)
            {
                string  newname = basename + "." + n;
                IObject r       = vplace.ImportFolder.FileSystem.Resolve(newname);
                if (r.Status == Status.Ok && r is IFile)
                {
                    List <Stream> ss = GetStreams((IFile)r);
                    if ((ss != null) && (ss.Count > 0))
                    {
                        streams.AddRange(ss);
                    }
                }
            }
            return(streams);
        }
Esempio n. 8
0
        public override void Run(IProgress <ICommand> progress = null)
        {
            logger.Info("Reading Media Info for File: {0}", VideoLocalID);


            try
            {
                ReportInit(progress);
                SVR_VideoLocal       vlocal = Repo.Instance.VideoLocal.GetByID(VideoLocalID);
                SVR_VideoLocal_Place place  = vlocal?.GetBestVideoLocalPlace(true);
                ReportUpdate(progress, 50);
                if (place == null)
                {
                    ReportError(progress, $"Could not find VideoLocal: {VideoLocalID}");
                    return;
                }
                using (var txn = Repo.Instance.VideoLocal.BeginAddOrUpdate(place.VideoLocalID))
                {
                    if (place.RefreshMediaInfo(txn.Entity))
                    {
                        txn.Commit();
                    }
                }

                ReportFinish(progress);
            }
            catch (Exception ex)
            {
                ReportError(progress, $"Error processing ServerReadMediaInfo: {VideoLocalID} - {ex}", ex);
            }
        }
        public List <Stream> Process(SVR_VideoLocal_Place vplace)
        {
            string dirname = Path.GetDirectoryName(vplace.FullServerPath);
            string fname   = Path.GetFileNameWithoutExtension(vplace.FilePath);

            if (string.IsNullOrEmpty(dirname) || string.IsNullOrEmpty(fname))
            {
                return(new List <Stream>());
            }
            string        basename = Path.Combine(dirname, fname);
            List <Stream> streams  = new List <Stream>();

            if (File.Exists(basename + ".idx") && File.Exists(basename + ".sub"))
            {
                IObject r = vplace.ImportFolder.FileSystem.Resolve(basename + ".sub");
                if (r.Status == Status.Ok && r is IFile)
                {
                    List <Stream> ss = GetStreams((IFile)r);
                    if ((ss != null) && (ss.Count > 0))
                    {
                        streams.AddRange(ss);
                    }
                }
            }
            return(streams);
        }
Esempio n. 10
0
        public List <TextStream> GetStreams(SVR_VideoLocal_Place vplace)
        {
            // TODO Scan the folder for filename.lang.sub files
            string dirname = Path.GetDirectoryName(vplace.FullServerPath);
            string fname   = Path.GetFileNameWithoutExtension(vplace.FilePath);

            if (string.IsNullOrEmpty(dirname) || string.IsNullOrEmpty(fname))
            {
                return(new List <TextStream>());
            }
            string basename = Path.Combine(dirname, fname);
            var    path     = basename + ".sub";

            if (!File.Exists(basename + ".idx") || !File.Exists(path))
            {
                return(new List <TextStream>());
            }
            FileSystemResult <IObject> r = vplace.ImportFolder.FileSystem.Resolve(path);

            if (r == null || !r.IsOk || !(r.Result is IFile))
            {
                return(new List <TextStream>());
            }

            MediaContainer m = MediaInfo.GetMediaInfo(path);

            if (m == null)
            {
                return(new List <TextStream>());
            }
            m.TextStreams.ForEach(a => a.Filename = path);
            return(m.TextStreams);
        }
Esempio n. 11
0
        public void DeleteAllErroredFiles()
        {
            if (ActiveScan == null)
            {
                return;
            }
            var files = ActiveErrorFiles.ToList();

            ActiveErrorFiles.Clear();
            HashSet <SVR_AnimeEpisode> episodesToUpdate = new HashSet <SVR_AnimeEpisode>();
            HashSet <SVR_AnimeSeries>  seriesToUpdate   = new HashSet <SVR_AnimeSeries>();

            files.ForEach(file =>
            {
                SVR_VideoLocal_Place place = Repo.Instance.VideoLocal_Place.GetByID(file.VideoLocal_Place_ID);
                place.RemoveAndDeleteFileWithOpenTransaction(episodesToUpdate, seriesToUpdate);
            });
            // update everything we modified
            Repo.Instance.AnimeEpisode.BatchAction(episodesToUpdate, episodesToUpdate.Count, (ep, _) => {
                if (ep.AnimeEpisodeID == 0)
                {
                    ep.PlexContract = null;
                }
                try
                {
                    ep.PlexContract = Helper.GenerateVideoFromAnimeEpisode(ep);
                }
                catch (Exception ex)
                {
                    LogManager.GetCurrentClassLogger().Error(ex, ex.ToString());
                }
            });

            Repo.Instance.ScanFile.Delete(files);
        }
Esempio n. 12
0
        public List <TextStream> GetStreams(SVR_VideoLocal_Place vplace)
        {
            // TODO Scan the folder for filename.lang.sub files
            string dirname = Path.GetDirectoryName(vplace.FullServerPath);
            string fname   = Path.GetFileNameWithoutExtension(vplace.FilePath);

            if (string.IsNullOrEmpty(dirname) || string.IsNullOrEmpty(fname))
            {
                return(new List <TextStream>());
            }
            string           basename   = Path.Combine(dirname, fname);
            HashSet <string> extensions = new HashSet <string>(SubtitleHelper.Extensions.Keys);

            extensions.Remove("idx");
            List <TextStream> streams = new List <TextStream>();

            foreach (string n in extensions)
            {
                string newname = $"{basename}.{n}";
                FileSystemResult <IObject> r = vplace.ImportFolder.FileSystem.Resolve(newname);
                if (r == null || !r.IsOk || !(r.Result is IFile))
                {
                    continue;
                }
                MediaContainer    m        = MediaInfo.GetMediaInfo(newname);
                List <TextStream> tStreams = m?.TextStreams;
                if (tStreams != null && tStreams.Count > 0)
                {
                    tStreams.ForEach(a => a.Filename = newname);
                    streams.AddRange(tStreams);
                }
            }
            return(streams);
        }
Esempio n. 13
0
 private void UpdateMediaContracts(SVR_VideoLocal obj)
 {
     if (obj.Media == null || obj.MediaVersion < SVR_VideoLocal.MEDIA_VERSION || obj.Duration == 0)
     {
         SVR_VideoLocal_Place place = obj.GetBestVideoLocalPlace();
         place?.RefreshMediaInfo();
     }
 }
Esempio n. 14
0
        public (ImportFolder dest, string folder) GetDestinationFolder(SVR_VideoLocal_Place video)
        {
            try
            {
                SVR_AnimeSeries series = video.VideoLocal?.GetAnimeEpisodes().FirstOrDefault()?.GetAnimeSeries();

                if (series == null)
                {
                    return(null, "Series is null");
                }
                string name = Utils.ReplaceInvalidFolderNameCharacters(series.GetSeriesName());
                if (string.IsNullOrEmpty(name))
                {
                    return(null, "Unable to get series name");
                }

                var          anime      = series.GetAnime();
                ImportFolder destFolder = RepoFactory.ImportFolder.GetAll()
                                          .FirstOrDefault(a => a.ImportFolderLocation.Contains("Anime"));
                if (anime.Restricted == 1)
                {
                    destFolder = RepoFactory.ImportFolder.GetAll()
                                 .FirstOrDefault(a => a.ImportFolderLocation.Contains("Hentai"));
                }

                if (destFolder == null)
                {
                    destFolder = RepoFactory.ImportFolder.GetAll().FirstOrDefault(a => a.FolderIsDropDestination) ??
                                 RepoFactory.ImportFolder.GetAll().FirstOrDefault();
                }

                string path;
                var    group = series.AnimeGroup;
                if (group == null)
                {
                    return(null, "group is null");
                }
                if (group.GetAllSeries().Count == 1)
                {
                    path = name;
                }
                else
                {
                    var groupName = Utils.ReplaceInvalidFolderNameCharacters(group.GroupName);
                    path = Path.Combine(groupName, name);
                }

                return(destFolder, path);
            }
            catch
            {
                return(null, "ERROR");
            }
        }
Esempio n. 15
0
        public static List <Stream> GetSubtitleStreams(SVR_VideoLocal_Place vplace)
        {
            List <Stream> ls            = new VobSubSubtitles().Process(vplace);
            var           textSubtitles = new TextSubtitles().Process(vplace);

            if (textSubtitles != null)
            {
                ls.AddRange(textSubtitles);
            }
            return(ls);
        }
Esempio n. 16
0
 public static string GetNewFileName(SVR_VideoLocal_Place vid)
 {
     try
     {
         return(GetRenamer()?.GetFileName(vid));
     }
     catch (Exception ex)
     {
         logger.Error(ex, ex.ToString());
         return(string.Empty);
     }
 }
Esempio n. 17
0
        internal void OnFileHashed(SVR_ImportFolder folder, SVR_VideoLocal_Place vlp)
        {
            var path = vlp.FilePath;

            FileHashed?.Invoke(null, new FileHashedEventArgs
            {
                FileInfo     = vlp.GetFile(),
                ImportFolder = folder,
                RelativePath = path,
                Hashes       = vlp.Hashes,
                MediaInfo    = vlp.MediaInfo,
            });
        }
Esempio n. 18
0
        public static Video VideoFromVideoLocal(IProvider prov, SVR_VideoLocal v, int userid)
        {
            Video l = new Video
            {
                AnimeType             = AnimeTypes.AnimeFile.ToString(),
                Id                    = v.VideoLocalID,
                Type                  = "episode",
                Summary               = "Episode Overview Not Available", //TODO Intenationalization
                Title                 = Path.GetFileNameWithoutExtension(v.Info),
                AddedAt               = v.DateTimeCreated.ToUnixTime(),
                UpdatedAt             = v.DateTimeUpdated.ToUnixTime(),
                OriginallyAvailableAt = v.DateTimeCreated.ToPlexDate(),
                Year                  = v.DateTimeCreated.Year,
                Medias                = new List <Media>()
            };
            VideoLocal_User vlr = v.GetUserRecord(userid);

            if (vlr?.WatchedDate != null)
            {
                l.LastViewedAt = vlr.WatchedDate.Value.ToUnixTime();
            }
            if (vlr?.ResumePosition > 0)
            {
                l.ViewOffset = vlr.ResumePosition;
            }
            Media m = v.Media;

            if (m?.Duration != 0)
            {
                SVR_VideoLocal_Place pl = v.GetBestVideoLocalPlace();
                if (pl != null)
                {
                    using (var upd = Repo.Instance.VideoLocal.BeginAddOrUpdate(v))
                    {
                        if (pl.RefreshMediaInfo(upd.Entity))
                        {
                            upd.Commit(true);
                        }
                    }
                }
                m = v.Media;
            }
            if (m != null)
            {
                l.Medias.Add(m);
                l.Duration = m.Duration;
            }
            AddLinksToAnimeEpisodeVideo(prov, l, userid);
            return(l);
        }
Esempio n. 19
0
        public static CL_VideoLocal_Place ToClient(this SVR_VideoLocal_Place vlocalplace)
        {
            CL_VideoLocal_Place v = new CL_VideoLocal_Place
            {
                FilePath            = vlocalplace.FilePath,
                ImportFolderID      = vlocalplace.ImportFolderID,
                ImportFolderType    = vlocalplace.ImportFolderType,
                VideoLocalID        = vlocalplace.VideoLocalID,
                ImportFolder        = vlocalplace.ImportFolder,
                VideoLocal_Place_ID = vlocalplace.VideoLocal_Place_ID
            };

            return(v);
        }
Esempio n. 20
0
        private static RenameEventArgs GetRenameEventArgs(SVR_VideoLocal_Place place)
        {
            var args = new RenameEventArgs
            {
                AnimeInfo = place.VideoLocal?.GetAnimeEpisodes().Select(a => a?.GetAnimeSeries()?.GetAnime())
                            .Where(a => a != null).Cast <IAnime>().ToList(),
                GroupInfo = place.VideoLocal?.GetAnimeEpisodes().Select(a => a.GetAnimeSeries()?.AnimeGroup)
                            .Where(a => a != null).DistinctBy(a => a.AnimeGroupID).Cast <IGroup>().ToList(),
                EpisodeInfo = place.VideoLocal?.GetAnimeEpisodes().Where(a => a != null).Cast <IEpisode>().ToList(),
                FileInfo    = place
            };

            return(args);
        }
Esempio n. 21
0
        internal void OnFileMatched(SVR_VideoLocal_Place vlp)
        {
            var series = vlp.VideoLocal?.GetAnimeEpisodes().Select(a => a.GetAnimeSeries()).DistinctBy(a => a.AniDB_ID).ToList() ?? new List <SVR_AnimeSeries>();

            FileMatched?.Invoke(
                null, new FileMatchedEventArgs
            {
                FileInfo    = vlp,
                AnimeInfo   = series.Select(a => a.GetAnime()).Cast <IAnime>().ToList(),
                EpisodeInfo = vlp.VideoLocal?.GetAnimeEpisodes().Cast <IEpisode>().ToList(),
                GroupInfo   = series.Select(a => a.AnimeGroup).DistinctBy(a => a.AnimeGroupID).Cast <IGroup>().ToList(),
            }
                );
        }
Esempio n. 22
0
        public static Video VideoFromVideoLocal(IProvider prov, SVR_VideoLocal v, int userid)
        {
            Video l = new Video();

            l.AnimeType             = AnimeTypes.AnimeFile.ToString();
            l.Id                    = v.VideoLocalID.ToString();
            l.Type                  = "episode";
            l.Summary               = "Episode Overview Not Available"; //TODO Intenationalization
            l.Title                 = Path.GetFileNameWithoutExtension(v.FileName);
            l.AddedAt               = v.DateTimeCreated.ToUnixTime();
            l.UpdatedAt             = v.DateTimeUpdated.ToUnixTime();
            l.OriginallyAvailableAt = v.DateTimeCreated.ToPlexDate();
            l.Year                  = v.DateTimeCreated.Year.ToString();
            l.Medias                = new List <Media>();
            VideoLocal_User vlr = v.GetUserRecord(userid);

            if (vlr != null)
            {
                if (vlr.WatchedDate.HasValue)
                {
                    l.LastViewedAt = vlr.WatchedDate.Value.ToUnixTime();
                }
                if (vlr.ResumePosition > 0)
                {
                    l.ViewOffset = vlr.ResumePosition.ToString();
                }
            }
            Media m = v.Media;

            if (string.IsNullOrEmpty(m?.Duration))
            {
                SVR_VideoLocal_Place pl = v.GetBestVideoLocalPlace();
                if (pl != null)
                {
                    if (pl.RefreshMediaInfo())
                    {
                        RepoFactory.VideoLocal.Save(v, true);
                    }
                }
                m = v.Media;
            }
            if (m != null)
            {
                l.Medias.Add(m);
                l.Duration = m.Duration;
            }
            AddLinksToAnimeEpisodeVideo(prov, l, userid);
            return(l);
        }
Esempio n. 23
0
        public void ReAddErrorFile(ScanFile sf)
        {
            ScannerInfo info = Scans.FirstOrDefault(a => a.Scan.ScanID == sf.ScanID);

            if (info != null && info.ErrorFiles.Any(a => a.ScanFileID == sf.ScanFileID))
            {
                ScannerInfo          si = Scans.First(a => a.Scan.ScanID == sf.ScanID);
                SVR_VideoLocal_Place pl = Repo.Instance.VideoLocal_Place.GetByID(sf.VideoLocal_Place_ID);
                if (pl != null)
                {
                    info.ErrorFiles.Remove(sf);
                    Repo.Instance.ScanFile.Delete(sf);
                    Queue.Instance.Add(new CmdVerifyFile(pl), BatchName + si.Scan.ScanID);
                }
            }
        }
Esempio n. 24
0
        private static MoveEventArgs GetMoveEventArgs(SVR_VideoLocal_Place place)
        {
            var args = new MoveEventArgs
            {
                AnimeInfo = place.VideoLocal?.GetAnimeEpisodes().Select(a => a?.GetAnimeSeries()?.GetAnime())
                            .Where(a => a != null).Cast <IAnime>().ToList(),
                GroupInfo = place.VideoLocal?.GetAnimeEpisodes().Select(a => a.GetAnimeSeries()?.AnimeGroup)
                            .Where(a => a != null).DistinctBy(a => a.AnimeGroupID).Cast <IGroup>().ToList(),
                EpisodeInfo      = place.VideoLocal?.GetAnimeEpisodes().Where(a => a != null).Cast <IEpisode>().ToList(),
                FileInfo         = place,
                AvailableFolders = RepoFactory.ImportFolder.GetAll().Cast <IImportFolder>()
                                   .Where(a => a.DropFolderType != DropFolderType.Excluded).ToList()
            };

            return(args);
        }
Esempio n. 25
0
        public void DeleteAllErroredFiles()
        {
            if (ActiveScan == null)
            {
                return;
            }
            var files = ActiveErrorFiles.ToList();

            ActiveErrorFiles.Clear();
            HashSet <SVR_AnimeEpisode> episodesToUpdate = new HashSet <SVR_AnimeEpisode>();
            HashSet <SVR_AnimeSeries>  seriesToUpdate   = new HashSet <SVR_AnimeSeries>();

            using (var session = DatabaseFactory.SessionFactory.OpenSession())
            {
                files.ForEach(file =>
                {
                    SVR_VideoLocal_Place place = RepoFactory.VideoLocalPlace.GetByID(file.VideoLocal_Place_ID);
                    place.RemoveAndDeleteFileWithOpenTransaction(session, episodesToUpdate, seriesToUpdate);
                });
                // update everything we modified
                foreach (SVR_AnimeEpisode ep in episodesToUpdate)
                {
                    if (ep.AnimeEpisodeID == 0)
                    {
                        ep.PlexContract = null;
                        RepoFactory.AnimeEpisode.Save(ep);
                    }
                    try
                    {
                        ep.PlexContract = Helper.GenerateVideoFromAnimeEpisode(ep);
                        RepoFactory.AnimeEpisode.SaveWithOpenTransaction(session, ep);
                    }
                    catch (Exception ex)
                    {
                        LogManager.GetCurrentClassLogger().Error(ex, ex.ToString());
                    }
                }
                foreach (SVR_AnimeSeries ser in seriesToUpdate)
                {
                    ser.QueueUpdateStats();
                }
            }
            RepoFactory.ScanFile.Delete(files);
        }
Esempio n. 26
0
        public static List <TextStream> GetSubtitleStreams(SVR_VideoLocal_Place vplace)
        {
            if (SubtitleImplementations == null)
            {
                SubtitleImplementations = InitImplementations();
            }

            var path = vplace.FullServerPath;

            if (string.IsNullOrEmpty(path))
            {
                return(new List <TextStream>());
            }
            string directoryName = Path.GetDirectoryName(path);

            if (string.IsNullOrEmpty(directoryName))
            {
                return(new List <TextStream>());
            }
            if (!Directory.Exists(directoryName))
            {
                return(new List <TextStream>());
            }
            DirectoryInfo directory = new DirectoryInfo(directoryName);

            var basename = Path.GetFileNameWithoutExtension(path);

            var streams = new List <TextStream>();

            foreach (FileInfo file in directory.EnumerateFiles())
            {
                // Make sure it's actually the subtitle for this video file
                if (!file.Name.StartsWith(basename))
                {
                    continue;
                }
                // Get streams for each implementation
                SubtitleImplementations.Where(implementation => implementation.IsSubtitleFile(file.Extension))
                .SelectMany(implementation => implementation.GetStreams(file)).ForEach(streams.Add);
            }

            return(streams);
        }
Esempio n. 27
0
        public (ImportFolder dest, string folder) GetDestinationFolder(SVR_VideoLocal_Place video)
        {
            try
            {
                var  anime    = RepoFactory.AniDB_Anime.GetByAnimeID(video.VideoLocal.GetAnimeEpisodes()[0].AniDB_Episode.AnimeID);
                bool IsPorn   = anime.Restricted > 0;
                var  location = @"E:\Plex\Anime";
                if (IsPorn)
                {
                    location = @"E:\Plex\Hentai";
                }

                return(RepoFactory.ImportFolder.GetByImportLocation(location), Utils.RemoveInvalidFolderNameCharacters(anime.PreferredTitle));
            }
            catch
            {
                return(script.GetDestinationFolder(video));
            }
        }
Esempio n. 28
0
        public (ImportFolder dest, string folder) GetDestinationFolder(SVR_VideoLocal_Place video)
        {
            var  anime    = RepoFactory.AniDB_Anime.GetByAnimeID(video.VideoLocal.GetAnimeEpisodes()[0].AniDB_Episode.AnimeID);
            bool IsPorn   = anime.Restricted > 0;
            var  location = "/anime/";

            if (anime.GetAnimeTypeEnum() == AnimeType.Movie)
            {
                location = "/movies/";
            }
            if (IsPorn)
            {
                location = "/p**n/";
            }


            ImportFolder dest = RepoFactory.ImportFolder.GetByImportLocation(location);

            return(dest, Utils.ReplaceInvalidFolderNameCharacters(anime.PreferredTitle));
        }
Esempio n. 29
0
        public static void FixEmptyVideoInfos()
        {
            List <SVR_VideoLocal> locals = RepoFactory.VideoLocal.GetAll()
                                           .Where(a => string.IsNullOrEmpty(a.FileName))
                                           .ToList();

            foreach (SVR_VideoLocal v in locals)
            {
                SVR_VideoLocal_Place p = v.Places.OrderBy(a => a.ImportFolderType).FirstOrDefault();
                if (!string.IsNullOrEmpty(p?.FilePath) && v.Media != null)
                {
                    v.FileName = p.FilePath;
                    int a = p.FilePath.LastIndexOf($"{Path.DirectorySeparatorChar}", StringComparison.InvariantCulture);
                    if (a > 0)
                    {
                        v.FileName = p.FilePath.Substring(a + 1);
                    }
                    SVR_VideoLocal_Place.FillVideoInfoFromMedia(v, v.Media);
                    RepoFactory.VideoLocal.Save(v, false);
                }
            }
        }
Esempio n. 30
0
        public static List <TextStream> GetSubtitleStreams(SVR_VideoLocal_Place vplace)
        {
            List <TextStream> ls = new VobSubSubtitles().GetStreams(vplace);

            ls.AddRange(new TextSubtitles().GetStreams(vplace));
            ls.ForEach(a =>
            {
                a.External  = true;
                string lang = GetLanguageFromFilename(vplace.FilePath);
                if (lang == null)
                {
                    return;
                }
                a.Language = lang;
                Tuple <string, string> mapping = MediaInfoUtils.GetLanguageMapping(lang);
                if (mapping == null)
                {
                    return;
                }
                a.LanguageCode = mapping.Item1;
                a.LanguageName = mapping.Item2;
            });
            return(ls);
        }