Beispiel #1
0
 public static VideoInfo ToVideoInfo(this VM_VideoLocal vid, bool forcebegining)
 {
     if (string.IsNullOrEmpty(vid.GetLocalFileSystemFullPath()))
     {
         if (vid.Media?.Parts == null || vid.Media.Parts.Count == 0)
         {
             throw new Exception("There is no media information loaded in the video selected, we're unable to stream the media");
         }
         Tuple <string, List <string> > t = GetInfoFromMedia(vid.Media);
         return(new VideoInfo
         {
             Uri = t.Item1,
             SubtitlePaths = t.Item2,
             IsUrl = true,
             Duration = vid.Duration,
             ResumePosition = forcebegining ? 0 : vid.ResumePosition,
             VideoLocalId = vid.VideoLocalID,
             VideoLocal = vid,
             WasWatched = vid.WatchedDate.HasValue
         });
     }
     return(new VideoInfo
     {
         Uri = vid.GetLocalFileSystemFullPath(),
         IsUrl = false,
         Duration = vid.Duration,
         ResumePosition = forcebegining ? 0 : vid.ResumePosition,
         VideoLocalId = vid.VideoLocalID,
         VideoLocal = vid,
         WasWatched = vid.WatchedDate.HasValue
     });
 }
Beispiel #2
0
 public static VideoInfo ToVideoInfo(this VM_VideoLocal vid, bool forcebegining)
 {
     if (string.IsNullOrEmpty(vid.GetLocalFileSystemFullPath()))
     {
         Tuple <string, List <string> > t = GetInfo(vid.VideoLocalID, vid.FullPath, vid.Media);
         return(new VideoInfo
         {
             Uri = t.Item1,
             SubtitlePaths = t.Item2,
             IsUrl = true,
             Duration = vid.Duration,
             ResumePosition = forcebegining ? 0 : vid.ResumePosition,
             VideoLocalId = vid.VideoLocalID,
             VideoLocal = vid,
             WasWatched = vid.WatchedDate.HasValue
         });
     }
     return(new VideoInfo
     {
         Uri = vid.GetLocalFileSystemFullPath(),
         IsUrl = false,
         Duration = vid.Duration,
         ResumePosition = forcebegining ? 0 : vid.ResumePosition,
         VideoLocalId = vid.VideoLocalID,
         VideoLocal = vid,
         WasWatched = vid.WatchedDate.HasValue
     });
 }
        void workerAvdump_DoWork(object sender, DoWorkEventArgs e)
        {
            VM_VideoLocal vid = e.Argument as VM_VideoLocal;

            //Create process
            Process pProcess = new Process();

            //strCommand is path and file name of command to run
            string appPath  = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
            string filePath = Path.Combine(appPath, "AVDump2CL.exe");

            if (!File.Exists(filePath))
            {
                e.Result = "Could not find AvDump2 CLI: " + filePath;
                return;
            }
            if (string.IsNullOrEmpty(vid.GetLocalFileSystemFullPath()))
            {
                e.Result = "Unable to map video file : " + vid.FileName;
                return;
            }
            if (!File.Exists(vid.GetLocalFileSystemFullPath()))
            {
                e.Result = "Could not find Video File: " + vid.GetLocalFileSystemFullPath();
                return;
            }

            pProcess.StartInfo.FileName = filePath;

            //strCommandParameters are parameters to pass to program
            string fileName = (char)34 + vid.GetLocalFileSystemFullPath() + (char)34;

            pProcess.StartInfo.Arguments =
                $@" --Auth={VM_ShokoServer.Instance.AniDB_Username}:{VM_ShokoServer.Instance.AniDB_AVDumpKey} --LPort={VM_ShokoServer.Instance.AniDB_AVDumpClientPort} --PrintEd2kLink -t {fileName}";

            pProcess.StartInfo.UseShellExecute        = false;
            pProcess.StartInfo.WindowStyle            = ProcessWindowStyle.Hidden;
            pProcess.StartInfo.RedirectStandardOutput = true;
            pProcess.StartInfo.CreateNoWindow         = true;
            pProcess.Start();
            string strOutput = pProcess.StandardOutput.ReadToEnd();

            //Wait for process to finish
            pProcess.WaitForExit();

            e.Result = strOutput;
        }
Beispiel #4
0
        /*public AVDumpVM(VideoDetailedVM vid)
         *      {
         *              this.FullPath = vid.FullPath;
         *              this.FileSize = vid.VideoLocal_FileSize;
         *              this.ED2KDump = "";
         *              this.AVDumpFullResult = "";
         *              this.HasBeenDumped = false;
         *              this.IsBeingDumped = false;
         *              this.DumpStatus = "To be processed";
         *      }*/

        public VM_AVDump(VM_VideoLocal vid)
        {
            FullPath         = vid.GetLocalFileSystemFullPath();
            FileSize         = vid.FileSize;
            ED2KDump         = "";
            AVDumpFullResult = ""; HasBeenDumped = false;
            IsBeingDumped    = false;
            DumpStatus       = "To be processed";
            VideoLocal       = vid;
        }
Beispiel #5
0
        private void CommandBinding_OpenFolder(object sender, ExecutedRoutedEventArgs e)
        {
            object obj = e.Parameter;

            if (obj == null)
            {
                return;
            }

            if (obj.GetType() == typeof(VM_VideoLocal))
            {
                VM_VideoLocal vid = obj as VM_VideoLocal;

                if (vid.IsLocalFile() && File.Exists(vid.GetLocalFileSystemFullPath()))
                {
                    Utils.OpenFolderAndSelectFile(vid.GetLocalFileSystemFullPath());
                }
                else
                {
                    MessageBox.Show(Shoko.Commons.Properties.Resources.MSG_ERR_FileNotFound, Shoko.Commons.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }