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);
        }
Example #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);
        }
        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;
        }
Example #4
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();
        }
Example #5
0
        private void UpdateGUI(MatroskaTags tags)
        {
            #region Album

            if (!ReferenceEquals(tags.MusicVideo.AlbumArtist, null))
            {
                albumArtist.Value = tags.MusicVideo.AlbumArtist;
            }

            if (!ReferenceEquals(tags.MusicVideo.AlbumTitle, null))
            {
                albumTitle.Value = tags.MusicVideo.AlbumTitle;
            }

            //if (!ReferenceEquals(tags.MusicVideo.AlbumReleaseDate, null))
            //  albumReleaseDate.Value = tags.MusicVideo.AlbumReleaseDate.Value;

            if (!ReferenceEquals(tags.MusicVideo.AlbumReleaseDate, null))
            {
                albumReleaseDate.Value = tags.MusicVideo.AlbumReleaseDate;
            }

            #endregion Album

            #region Track

            if (!ReferenceEquals(tags.MusicVideo.TrackArtist, null))
            {
                trackArtist.Value = tags.MusicVideo.TrackArtist;
            }

            if (!ReferenceEquals(tags.MusicVideo.TrackTitle, null))
            {
                trackTitle.Value = tags.MusicVideo.TrackTitle;
            }

            if (!ReferenceEquals(tags.MusicVideo.TrackReleaseDate, null))
            {
                trackReleaseDate.Value = tags.MusicVideo.TrackReleaseDate;
            }

            trackGenre.Value = tags.MusicVideo.GenreList;

            #endregion Track
        }
Example #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;
            }
        }
Example #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;
        }
Example #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();
        }