private VideoFileInfoSample GetVideo(Episode.ScannedFile file)
        {
            FFMpegConverter ffmpeg = new FFMpegConverter();
            FFProbe         probe  = new FFProbe();

            ffmpeg.FFMpegToolPath = probe.ToolPath = Environment.GetFolderPath(SpecialFolder.ApplicationData);
            var    info     = probe.GetMediaInfo(file.NewName);
            var    videotag = info.Streams.Where(x => x.CodecType == "video").FirstOrDefault();
            var    audiotag = info.Streams.Where(x => x.CodecType == "audio").FirstOrDefault();
            Stream str      = new MemoryStream();

            ffmpeg.GetVideoThumbnail(file.NewName, str, 10);
            Bitmap bmp = new Bitmap(str);

            return(Dispatcher.Invoke(() => {
                VideoFileInfoSample sample = sample = new VideoFileInfoSample();
                sample.ScannedFile = file;
                sample.Preview.Source = bmp.ToBitmapImage();
                sample.TopText.Text = videotag.Width + "x" + videotag.Height;
                sample.Codec.Text = videotag.CodecName;
                var lang = videotag.Tags.Where(x => x.Key == "language" || x.Key == "Language" || x.Key == "lang" || x.Key == "Lang").FirstOrDefault();
                sample.Language.Text = !String.IsNullOrEmpty(lang.Value) ? lang.Value : "-";
                sample.Fps.Text = videotag.FrameRate.ToString("##.##") + "FPS";
                sample.Pixel.Text = videotag.PixelFormat;
                sample.Created.Text = File.GetCreationTime(file.NewName).ToString("HH:mm:ss, dd. MM. yyyy");
                sample.AudioCodec.Text = audiotag.CodecName;
                return sample;
            }));
        }
        public async Task <Episode.ScannedFile> Show()
        {
            MainWindow.AddPage(this);
            Episode.ScannedFile result = await Task.Run(async() => {
                while (this.result == null)
                {
                    await Task.Delay(100);
                }
                return(this.result);
            });

            MainWindow.RemovePage();
            if (!String.IsNullOrEmpty(result.NewName))
            {
                return(result);
            }
            else
            {
                return(null);
            }
        }
        private async void Grid_Loaded(object sender, RoutedEventArgs e)
        {
            Panel.Opacity = 0;
            await Task.Run(() => {
                foreach (var file in files)
                {
                    if (File.Exists(file.NewName))
                    {
                        var sample = GetVideo(file);
                        Dispatcher.Invoke(() => {
                            sample.Container.MouseEnter        += (s, ev) => { Mouse.OverrideCursor = Cursors.Hand; };
                            sample.Container.MouseLeave        += (s, ev) => { Mouse.OverrideCursor = null; };
                            sample.Container.MouseLeftButtonUp += (s, ev) => { result = sample.ScannedFile; };
                            Panel.Children.Add(sample);
                        });
                    }
                }
            });

            var sb = (Storyboard)FindResource("OpacityUp");

            sb.Begin(Panel);
        }
예제 #4
0
 public async static Task <List <Subtitles> > GetSubtitles(Episode.ScannedFile file)
 {
     return(await Task.Run(() => {
         List <Subtitles> subList = new List <Subtitles>();
         HtmlWeb htmlWeb = new HtmlWeb();
         string name = String.IsNullOrEmpty(file.OriginalName) ? Path.GetFileNameWithoutExtension(file.NewName) : Path.GetFileNameWithoutExtension(file.OriginalName);
         HtmlDocument htmlDocument = htmlWeb.Load("http://www.addic7ed.com/search.php?search=" + name + "&anti_cache=" + DateTime.Now.ToString());
         var items = htmlDocument.DocumentNode.SelectNodes("//div[@id='container95m']");
         if (items != null)
         {
             items.RemoveAt(items.Count - 1);
             foreach (var item in items)
             {
                 Subtitles subs = new Subtitles();
                 subs.OriginalFile = file;
                 var data = item.ChildNodes[1].ChildNodes[3].ChildNodes[3].ChildNodes[1];
                 subs.Version = data.ChildNodes[1].ChildNodes[1].InnerText.Remove(data.ChildNodes[1].ChildNodes[1].InnerText.IndexOf(',')).Remove(0, 8);
                 string url = "http://www.addic7ed.com";
                 if (data.ChildNodes[4].ChildNodes[8].ChildNodes[2].Name == "a")
                 {
                     url += data.ChildNodes[4].ChildNodes[8].ChildNodes[2].Attributes[1].Value;
                 }
                 else
                 {
                     url += data.ChildNodes[4].ChildNodes[8].ChildNodes[5].Attributes[1].Value;
                 }
                 var request = (HttpWebRequest)WebRequest.Create(url);
                 request.Referer = htmlWeb.ResponseUri.ToString();
                 subs.DownloadLink = request;
                 subs.Language = data.ChildNodes[4].ChildNodes[4].InnerText.Replace("    \n\t\t\t", "");
                 subList.Add(subs);
             }
         }
         return subList;
     }));
 }