Example #1
0
        private async Task checkSubtitlesAsync()
        {
            var groomer = new Groomer(Config.LastDirectory);

            lblStatus.Content           = "Working...";
            lblTotal.Content            = 0;
            lblNeedMoving.Content       = 0;
            lblWithoutVideo.Content     = 0;
            lblWithoutSubtitles.Content = 0;
            lblRenamed.Content          = 0;

            await groomer.CheckSubtitlesAsync();

            lblStatus.Content = "Ready";

            VideosWithoutSubtitles.Clear();
            foreach (var video in groomer.VideosWithoutSubtitle
                     .Where(video => !Config.IgnoredVideos.Any(ignored => video.FullName.EndsWith(ignored, StringComparison.OrdinalIgnoreCase))))
            {
                VideosWithoutSubtitles.Add(video.FullName);
            }

            lblTotal.Content        = groomer.SubtitlesTotal;
            lblNeedMoving.Content   = groomer.SubtitlesNeedMoving.Count;
            lblWithoutVideo.Content = groomer.SubtitlesWithoutVideo.Count;
            lblWithoutLang.Content  = groomer.SubtitlesWithoutLang;
            updateVideosWithoutSubtitleCount();

            lbNeedMoving.ItemsSource = groomer.SubtitlesNeedMoving;
            SubtitlesWithoutVideo.Clear();
            groomer.SubtitlesWithoutVideo.ForEach(fi => SubtitlesWithoutVideo.Add(new SubtitleData {
                Subtitle = fi
            }));
        }
Example #2
0
        private void subtitleItem_OnMouseUp(object sender, MouseButtonEventArgs e)
        {
            if (e.ChangedButton != MouseButton.Left)
            {
                return;
            }

            var subtitleData = lvSubtitlesWithoutVideo.SelectedItem as SubtitleData;

            if (subtitleData == null)
            {
                return;
            }

            subtitleData.IsActive = !subtitleData.IsActive;

            if (!subtitleData.IsActive)
            {
                return;
            }

            subtitleData.AvailableVideos.Clear();
            foreach (var video in Groomer.GetAvailableVideosInDirectory(subtitleData.Subtitle.Directory).Where(video => !Groomer.HasVideoSubtitle(video)))
            {
                subtitleData.AvailableVideos.Add(Path.GetFileName(video));
            }
        }
Example #3
0
        private void subtitleItemVideo_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            lblRenamed.Content = 0;

            if (e.AddedItems.Count == 0)
            {
                return;
            }

            var video = e.AddedItems[0] as string;

            if (video == null)
            {
                return;
            }

            var subtitleData = lvSubtitlesWithoutVideo.SelectedItem as SubtitleData;

            if (subtitleData == null)
            {
                return;
            }

            try
            {
                var hasLangCode = Groomer.HasSubtitleLangCode(subtitleData.Subtitle.Name);

                Groomer.RenameSubtitleToMatchVideo(subtitleData.Subtitle, video);

                SubtitlesWithoutVideo.Remove(subtitleData);
                lblWithoutVideo.Content = SubtitlesWithoutVideo.Count;
                if (!hasLangCode)
                {
                    lblWithoutLang.Content = (int)lblWithoutLang.Content - 1;
                }

                var videoItem = VideosWithoutSubtitles.FirstOrDefault(v => v.Contains(video));
                if (videoItem != null)
                {
                    VideosWithoutSubtitles.Remove(videoItem);
                    lblWithoutSubtitles.Content = VideosWithoutSubtitles.Count;
                }

                lblRenamed.Content = 1;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Example #4
0
        private async void btnFixLocations_Click(object sender, RoutedEventArgs e)
        {
            if (Config.LastDirectory == null)
            {
                return;
            }

            var groomer = new Groomer(Config.LastDirectory);

            await groomer.MoveSubtitlesNextToVideoAsync();

            await Task.Delay(100);

            await checkSubtitlesAsync();
        }
Example #5
0
        private async void btnFixNaming_Click(object sender, RoutedEventArgs e)
        {
            if (Config.LastDirectory == null)
            {
                return;
            }

            var groomer = new Groomer(Config.LastDirectory);

            await groomer.RenameSubtitlesWithLangCodeAsync();

            await Task.Delay(100);

            await checkSubtitlesAsync();

            lblRenamed.Content = groomer.SubtitlesRenamed;
        }