コード例 #1
0
        //public Dictionary<string,Episode> GetAllEpisodes()
        //{
        //  string db = DatabasePath;
        //  OpenConnection(db);

        //  Dictionary<string,Episode> episodes = new Dictionary<string, Episode>();
        //  using (var command = new SQLiteCommand(connection))
        //  {
        //    command.CommandText = "SELECT * FROM local_episodes";

        //    using (SQLiteDataReader reader = command.ExecuteReader())
        //    {
        //      while (reader.Read())
        //      {
        //        Episode ep = FillLocalEpisodeInfo(new Episode(), reader);
        //        episodes.Add(ep.Filename,ep);
        //      }
        //      reader.Close();
        //    }
        //  }

        //  foreach (Episode episode in episodes.Values)
        //  {

        //  }

        //  CloseConnection();
        //  return episodes;
        //}

        //public Dictionary<int, Series> GetAllSeries()
        //{
        //  string db = DatabasePath;
        //  OpenConnection(db);

        //  Dictionary<int, Series> series = new Dictionary<int, Series>();
        //  using (var command = new SQLiteCommand(connection))
        //  {
        //    command.CommandText = "SELECT * FROM online_series";

        //    using (SQLiteDataReader reader = command.ExecuteReader())
        //    {
        //      while (reader.Read())
        //      {
        //        Series s = FillSeriesInfo(new Series(), reader);
        //        series.Add(s.ID, s);
        //      }
        //      reader.Close();
        //    }
        //  }

        //  CloseConnection();
        //  return series;
        //}

        public SeriesTag UpdateTags(SeriesTag seriesTag, string filename)
        {
            Episode ep = null;

            try
            {
                MPTVSeriesImporter i = new MPTVSeriesImporter();
                ep = i.GetEpisodeInfo(filename);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(seriesTag);
            }

            if (ep == null)
            {
                return(seriesTag);
            }

            return(CopyEpisodeToTag(seriesTag, ep));
        }
コード例 #2
0
        //public Dictionary<string,Episode> GetAllEpisodes()
        //{
        //  string db = DatabasePath;
        //  OpenConnection(db);
        //  Dictionary<string,Episode> episodes = new Dictionary<string, Episode>();
        //  using (var command = new SQLiteCommand(connection))
        //  {
        //    command.CommandText = "SELECT * FROM local_episodes";
        //    using (SQLiteDataReader reader = command.ExecuteReader())
        //    {
        //      while (reader.Read())
        //      {
        //        Episode ep = FillLocalEpisodeInfo(new Episode(), reader);
        //        episodes.Add(ep.Filename,ep);
        //      }
        //      reader.Close();
        //    }
        //  }
        //  foreach (Episode episode in episodes.Values)
        //  {
        //  }
        //  CloseConnection();
        //  return episodes;
        //}
        //public Dictionary<int, Series> GetAllSeries()
        //{
        //  string db = DatabasePath;
        //  OpenConnection(db);
        //  Dictionary<int, Series> series = new Dictionary<int, Series>();
        //  using (var command = new SQLiteCommand(connection))
        //  {
        //    command.CommandText = "SELECT * FROM online_series";
        //    using (SQLiteDataReader reader = command.ExecuteReader())
        //    {
        //      while (reader.Read())
        //      {
        //        Series s = FillSeriesInfo(new Series(), reader);
        //        series.Add(s.ID, s);
        //      }
        //      reader.Close();
        //    }
        //  }
        //  CloseConnection();
        //  return series;
        //}
        public SeriesTag UpdateTags(SeriesTag seriesTag, string filename)
        {
            Episode ep = null;
              try
              {
            MPTVSeriesImporter i = new MPTVSeriesImporter();
            ep = i.GetEpisodeInfo(filename);
              }
              catch (Exception ex)
              {
            MessageBox.Show(ex.Message);
            return seriesTag;
              }

              if (ep == null)
            return seriesTag;

              return CopyEpisodeToTag(seriesTag, ep);
        }
コード例 #3
0
        private void mpTVSeries_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.Series = UpdateTagFromGUI(tag.Series);

              // Update from TVSeries
              try
              {
            MPTVSeriesImporter importer = new MPTVSeriesImporter();
            tag.Series = importer.UpdateTags(tag.Series, txtFilename.Text);
              }
              catch (Exception ex)
              {
            MessageBox.Show(ex.Message);
            return;
              }

              UpdateGUI(tag.Series);
        }
コード例 #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();
        }
コード例 #5
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();
        }