Exemplo n.º 1
0
        private void tmdb_OnClick(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(txtFilename.Text))
            {
                return;
            }
            if (!File.Exists(txtFilename.Text))
            {
                return;
            }

            // Use original tags as base with latest changes from GUI
            MatroskaTags tag = MatroskaLoader.Clone(originalTag);

            tag.Movie = UpdateTagFromGUI(tag.Movie);

            // Update from TVSeries
            try
            {
                TheMovieDbImporter importer = new TheMovieDbImporter();
                tag.Movie = importer.UpdateTags(tag.Movie);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            UpdateGUI(tag.Movie);
        }
Exemplo n.º 2
0
        public void SetFile(string filepath)
        {
            originalTag = MatroskaLoader.ReadTag(filepath);
            if (ReferenceEquals(originalTag, null))
            {
                //clear textboxes
                txtXmlFilename.Text = string.Empty;
                dockXml.Visibility  = Visibility.Collapsed;
                txtFilename.Text    = filepath;

                textEditorOriginal.Text = string.Empty;
                ClearGUI();
            }
            else
            {
                txtXmlFilename.Text = string.Empty;
                dockXml.Visibility  = Visibility.Collapsed;
                txtFilename.Text    = filepath;

                textEditorOriginal.Text = MatroskaLoader.GetXML(originalTag);
                ClearGUI();
                UpdateGUI(originalTag);
            }
            saveButton.IsEnabled = false;
            UpdatePreview(null, null);
        }
Exemplo n.º 3
0
        private void SaveButton_OnClick(object sender, RoutedEventArgs e)
        {
            MatroskaTags tags;

            try
            {
                tags = MatroskaLoader.ReadTagFromXML(textEditorNew.Text);
                if (tags == null)
                {
                    MessageBox.Show("invalid tag file.");
                    return;
                }
            }
            catch (Exception)
            {
                MessageBox.Show("invalid tag file.");
                return;
            }

            MessageBoxResult result = MessageBox.Show("Do you really want to overwrite the old tags with the new ones?",
                                                      "Overwrite tags",
                                                      MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No);

            if (result == MessageBoxResult.Yes)
            {
                MatroskaLoader.WriteTags(tags, txtFilename.Text);
                SetFile(txtFilename.Text);
            }
        }
Exemplo n.º 4
0
        private void UpdatePreview(object sender, TextChangedEventArgs e)
        {
            MatroskaTags tag = MatroskaLoader.Clone(originalTag);

            tag.Movie = UpdateTagFromGUI(tag.Movie);
            tag.Cleanup();

            textEditorNew.Text   = MatroskaLoader.GetXML(tag);
            saveButton.IsEnabled = true;
        }
Exemplo n.º 5
0
        private void WriteXmlTags(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;
            WorkerArgs       args   = e.Argument as WorkerArgs;

            var filteredfileNames       = Directory.GetFiles(args.Directory, "*.*", SearchOption.AllDirectories);
            MPTVSeriesImporter importer = new MPTVSeriesImporter();

            importer.OpenConnection();

            int current = 0;
            int total   = filteredfileNames.Count();

            foreach (var file in filteredfileNames)
            {
                if (worker.CancellationPending)
                {
                    e.Cancel = true;
                    break;
                }

                current++;
                worker.ReportProgress(100 * current / total);

                // Check only video files
                if (!SupportedFiles.IsFileSupportedVideo(file))
                {
                    continue;
                }

                // build xml file name
                string xmlFile = GetXmlFilename(file);

                // init document
                MatroskaTags tag = new MatroskaTags();

                // Read MKV tags, if existing should be reused
                if (App.Config.BasedOnExistingTags)
                {
                    tag = MatroskaLoader.ReadTag(file);
                }

                // update tags from MP-TVSeries
                tag.Series = importer.UpdateTags(tag.Series, file);

                string logText = File.Exists(xmlFile) ? "XML updated: " : "XML created: ";
                MatroskaLoader.WriteTagToXML(tag, xmlFile);
                worker.ReportProgress(100 * current / total, new FileBasedLogEntry(xmlFile, logText));
            }

            importer.CloseConnection();
        }
Exemplo n.º 6
0
        private void listBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ListBox lb = sender as ListBox;

            if (ReferenceEquals(lb, null))
            {
                return;
            }

            if (lb.SelectedItems.Count != 1)
            {
                return;
            }

            FileBasedLogEntry item = lb.SelectedItems[0] as FileBasedLogEntry;

            if (ReferenceEquals(item, null))
            {
                return;
            }

            string extension = Path.GetExtension(item.Filepath);

            if (extension == null)
            {
                return;
            }

            switch (extension.ToLower())
            {
            case ".xml":
            case ".mkv":
                //todo: make it async
                MatroskaTags tags = MatroskaLoader.ReadTag(item.Filepath);
                textEditor.Text = MatroskaLoader.GetXML(tags);
                break;
            }
        }
Exemplo n.º 7
0
        private void UpdatePreview(object sender, TextChangedEventArgs e)
        {
            textEditorNew.Text = string.Empty;

            MatroskaTags tag;

            if (!ReferenceEquals(originalTag, null))
            {
                string xmlString = MatroskaLoader.GetXML(originalTag);
                tag = MatroskaLoader.ReadTagFromXML(xmlString);
            }
            else
            {
                tag = new MatroskaTags();
            }

            #region Album

            if (!string.IsNullOrEmpty(albumArtist.Value))
            {
                tag.MusicVideo.AlbumArtist = albumArtist.Value;
            }

            if (!string.IsNullOrEmpty(albumTitle.Value))
            {
                tag.MusicVideo.AlbumTitle = albumTitle.Value;
            }

            if (!string.IsNullOrEmpty(albumReleaseDate.Value))
            {
                tag.MusicVideo.AlbumReleaseDate = albumReleaseDate.Value;
            }

            //if (albumReleaseDate.Value.HasValue)
            //{
            //  tag.MusicVideo.AlbumReleaseDate = albumReleaseDate.Value.Value;
            //}

            #endregion Album

            #region Track

            if (!string.IsNullOrEmpty(trackArtist.Value))
            {
                tag.MusicVideo.TrackArtist = trackArtist.Value;
            }

            if (!string.IsNullOrEmpty(trackTitle.Value))
            {
                tag.MusicVideo.TrackTitle = trackTitle.Value;
            }

            if (!string.IsNullOrEmpty(trackNumber.Value))
            {
                int index;
                if (int.TryParse(trackNumber.Value, out index))
                {
                    tag.MusicVideo.TrackNumber = index;
                }
            }

            if (!string.IsNullOrEmpty(trackReleaseDate.Value))
            {
                tag.MusicVideo.TrackReleaseDate = trackReleaseDate.Value;
            }

            if (trackGenre.Value.Count > 0)
            {
                tag.MusicVideo.GenreList = trackGenre.Value;
            }

            #endregion Track

            textEditorNew.Text   = MatroskaLoader.GetXML(tag);
            saveButton.IsEnabled = true;
        }
Exemplo n.º 8
0
        private void WriteMkvTags(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker   = sender as BackgroundWorker;
            WorkerArgs       args     = e.Argument as WorkerArgs;
            DirectoryInfo    di       = new DirectoryInfo(args.Directory);
            List <FileInfo>  mkvFiles = new List <FileInfo>();

            mkvFiles.AddRange(di.GetFiles("*.mkv", SearchOption.AllDirectories));
            mkvFiles.AddRange(di.GetFiles("*.mk3d", SearchOption.AllDirectories));

            MPTVSeriesImporter importer = new MPTVSeriesImporter();

            importer.OpenConnection();

            int current = 0;
            int total   = mkvFiles.Count;

            foreach (FileInfo mkvFile in mkvFiles)
            {
                string file = mkvFile.FullName;
                if (worker.CancellationPending)
                {
                    e.Cancel = true;
                    break;
                }

                current++;
                worker.ReportProgress(100 * current / total);

                // init document
                MatroskaTags tag = new MatroskaTags();

                // Read MKV tags, if existing should be reused
                if (App.Config.BasedOnExistingTags)
                {
                    tag = MatroskaLoader.ReadTag(file);
                }

                // update tags from MP-TVSeries
                tag.Series = importer.UpdateTags(tag.Series, file);

                try
                {
                    int exitCode = MatroskaLoader.WriteTagToMatroska(mkvFile.FullName, tag);

                    if (exitCode == 0)
                    {
                        worker.ReportProgress(100 * current / total, new FileBasedLogEntry(mkvFile.FullName, "MKV updated: "));
                        if (args.DeleteXmlAfterMkvUpdate)
                        {
                            // build xml file name
                            string xmlFile = GetXmlFilename(file);
                            File.Delete(xmlFile);
                        }
                    }
                    else
                    {
                        worker.ReportProgress(100 * current / total,
                                              new FileBasedLogEntry(mkvFile.FullName,
                                                                    string.Format(
                                                                        "MKV updated with MKVPropEdit exit code = {0} file :",
                                                                        exitCode)));
                    }
                }
                catch (Exception ex)
                {
                    worker.ReportProgress(100 * current / total, new FileBasedLogEntry(mkvFile.FullName, ex.Message));
                }
            }

            importer.CloseConnection();
        }