Example #1
0
        public static void AddDefaults()
        {
            DBReplacements replacement = new DBReplacements();

            replacement[DBReplacements.cIndex] = "0";
            replacement[DBReplacements.cEnabled] = "1";
            replacement[DBReplacements.cTagEnabled] = "0";
            replacement[DBReplacements.cBefore] = "0";
            replacement[DBReplacements.cToReplace] = ".";
            replacement[DBReplacements.cWith] = @"<space>";
            replacement.Commit();

            replacement[DBReplacements.cIndex] = "1";
            replacement[DBReplacements.cEnabled] = "1";
            replacement[DBReplacements.cTagEnabled] = "0";
            replacement[DBReplacements.cBefore] = "0";
            replacement[DBReplacements.cToReplace] = "_";
            replacement[DBReplacements.cWith] = @"<space>";
            replacement.Commit();

            // to avoid being parsed as second episode 20/80
            replacement[DBReplacements.cIndex] = "2";
            replacement[DBReplacements.cEnabled] = "1";
            replacement[DBReplacements.cBefore] = "1";
            replacement[DBReplacements.cTagEnabled] = "1";
            replacement[DBReplacements.cToReplace] = "720p";
            replacement[DBReplacements.cWith] = @"<empty>";
            replacement.Commit();

            replacement[DBReplacements.cIndex] = "3";
            replacement[DBReplacements.cEnabled] = "1";
            replacement[DBReplacements.cBefore] = "1";
            replacement[DBReplacements.cTagEnabled] = "1";
            replacement[DBReplacements.cToReplace] = "1080i";
            replacement[DBReplacements.cWith] = @"<empty>";
            replacement.Commit();

            replacement[DBReplacements.cIndex] = "4";
            replacement[DBReplacements.cEnabled] = "1";
            replacement[DBReplacements.cBefore] = "1";
            replacement[DBReplacements.cTagEnabled] = "1";
            replacement[DBReplacements.cToReplace] = "1080p";
            replacement[DBReplacements.cWith] = @"<empty>";
            replacement.Commit();

            replacement[DBReplacements.cIndex] = "5";
            replacement[DBReplacements.cEnabled] = "1";
            replacement[DBReplacements.cBefore] = "1";
            replacement[DBReplacements.cTagEnabled] = "1";
            replacement[DBReplacements.cToReplace] = "x264";
            replacement[DBReplacements.cWith] = @"<empty>";
            replacement.Commit();

            replacement[DBReplacements.cIndex] = "6";
            replacement[DBReplacements.cEnabled] = "1";
            replacement[DBReplacements.cTagEnabled] = "1";
            replacement[DBReplacements.cBefore] = "0";
            replacement[DBReplacements.cToReplace] = "DSR";
            replacement[DBReplacements.cWith] = @"<empty>";
            replacement.Commit();

            replacement[DBReplacements.cIndex] = "7";
            replacement[DBReplacements.cEnabled] = "1";
            replacement[DBReplacements.cTagEnabled] = "1";
            replacement[DBReplacements.cBefore] = "0";
            replacement[DBReplacements.cToReplace] = "HR-HDTV";
            replacement[DBReplacements.cWith] = @"<empty>";
            replacement.Commit();

            replacement[DBReplacements.cIndex] = "8";
            replacement[DBReplacements.cEnabled] = "1";
            replacement[DBReplacements.cTagEnabled] = "1";
            replacement[DBReplacements.cBefore] = "0";
            replacement[DBReplacements.cToReplace] = "HR.HDTV";
            replacement.Commit();

            replacement[DBReplacements.cIndex] = "9";
            replacement[DBReplacements.cEnabled] = "1";
            replacement[DBReplacements.cTagEnabled] = "1";
            replacement[DBReplacements.cBefore] = "0";
            replacement[DBReplacements.cToReplace] = "HDTV";
            replacement[DBReplacements.cWith] = @"<empty>";
            replacement.Commit();

            replacement[DBReplacements.cIndex] = "10";
            replacement[DBReplacements.cEnabled] = "1";
            replacement[DBReplacements.cTagEnabled] = "1";
            replacement[DBReplacements.cBefore] = "0";
            replacement[DBReplacements.cToReplace] = "DVDMux";
            replacement[DBReplacements.cWith] = @"<empty>";
            replacement.Commit();

            DBReplacements.GlobalSet(new DBReplacements(), DBReplacements.cIsRegex, new DBValue(0), new SQLCondition());

            // low roman numerals preceded by Part or pt (for eg. Part 4 => 1x04)
            replacement = new DBReplacements();
            replacement[DBReplacements.cIndex] = 11;
            replacement[DBReplacements.cEnabled] = 1;
            replacement[DBReplacements.cTagEnabled] = 0;
            replacement[DBReplacements.cBefore] = "1";
            replacement[DBReplacements.cToReplace] = @"(?<=(\s?\.?P[ar]*t\s?)) (X)?(IX|IV|V?I{0,3})";
            replacement[DBReplacements.cWith] = @"<RomanToArabic>"; // special operator that causes them to be converted to arabics
            replacement[DBReplacements.cIsRegex] = true;
            try
            {
              replacement.Commit();
            }
            catch (Exception) { }

            // Part n or Part n of m - not preceded by 1x01 or s1e01
            replacement = new DBReplacements();
            replacement[DBReplacements.cIndex] = 12;
            replacement[DBReplacements.cEnabled] = 1;
            replacement[DBReplacements.cTagEnabled] = 0;
            replacement[DBReplacements.cBefore] = "1";
            replacement[DBReplacements.cToReplace] = @"(?<!(?:S\d+.?E\\d+\-E\d+.*|S\d+.?E\d+.*|\s\d+x\d+.*))P[ar]*t\s?(\d+)(\s?of\s\d{1,2})?";
            replacement[DBReplacements.cWith] = @" S01E${1} ";
            replacement[DBReplacements.cIsRegex] = true;
            try
            {
              replacement.Commit();
            }
            catch (Exception) { }

            // n of m - not preceded by 1x01 or s1e01
            replacement = new DBReplacements();
            replacement[DBReplacements.cIndex] = 13;
            replacement[DBReplacements.cEnabled] = 1;
            replacement[DBReplacements.cTagEnabled] = 0;
            replacement[DBReplacements.cBefore] = "1";
            replacement[DBReplacements.cToReplace] = @"(?<!(?:S\d+.?E\\d+\-E\d+.*|S\d+.?E\d+.*|\s\d+x\d+\s.*))(\d{1,2})\s?of\s\d{1,2}";
            replacement[DBReplacements.cWith] = @" S01E${1} ";
            replacement[DBReplacements.cIsRegex] = true;
            try
            {
              replacement.Commit();
            }
            catch (Exception) { }
        }
Example #2
0
        static DBReplacements()
        {
            s_FieldToDisplayNameMap.Add(cEnabled, "Enabled");
            s_FieldToDisplayNameMap.Add(cTagEnabled, "Used As Tag");
            s_FieldToDisplayNameMap.Add(cBefore, "Run before matching");
            s_FieldToDisplayNameMap.Add(cToReplace, "Replace this..");
            s_FieldToDisplayNameMap.Add(cWith, "With this");
            s_FieldToDisplayNameMap.Add(cIsRegex, "Is Regex");

            DBReplacements dummy = new DBReplacements();

            int nCurrentDBVersion = cDBVersion;
            int nUpgradeDBVersion = DBOption.GetOptions(DBOption.cDBReplacementsVersion);

            while (nUpgradeDBVersion != nCurrentDBVersion)
            // take care of the upgrade in the table
            {
                DBReplacements replacement = new DBReplacements();
                switch (nUpgradeDBVersion)
                {
                    case 2:
                        //Add tagEnabled colum
                        DBReplacements.GlobalSet(new DBReplacements(), DBReplacements.cTagEnabled, new DBValue(0), new SQLCondition());

                        replacement = new DBReplacements(3);
                        replacement[DBReplacements.cTagEnabled] = 1;
                        replacement.Commit();

                        replacement = new DBReplacements(4);
                        replacement[DBReplacements.cTagEnabled] = 1;
                        replacement.Commit();

                        replacement = new DBReplacements(5);
                        replacement[DBReplacements.cTagEnabled] = 1;
                        replacement.Commit();

                        //adding new replacement
                        DBReplacements[] replacements = DBReplacements.GetAll();

                        replacement = new DBReplacements();
                        replacement[DBReplacements.cIndex] = replacements.Length;
                        replacement[DBReplacements.cEnabled] = 1;
                        replacement[DBReplacements.cTagEnabled] = 1;
                        replacement[DBReplacements.cBefore] = "0";
                        replacement[DBReplacements.cToReplace] = "DSR";
                        replacement[DBReplacements.cWith] = @"<empty>";
                        try
                        {
                            replacement.Commit();
                        }
                        catch (Exception) { }

                        replacement = new DBReplacements();
                        replacement[DBReplacements.cIndex] = replacements.Length + 1;
                        replacement[DBReplacements.cEnabled] = 1;
                        replacement[DBReplacements.cTagEnabled] = 1;
                        replacement[DBReplacements.cBefore] = "0";
                        replacement[DBReplacements.cToReplace] = "HR-HDTV";
                        replacement[DBReplacements.cWith] = @"<empty>";
                        try
                        {
                            replacement.Commit();
                        }
                        catch (Exception) { }

                        replacement = new DBReplacements();
                        replacement[DBReplacements.cIndex] = replacements.Length + 2;
                        replacement[DBReplacements.cEnabled] = 1;
                        replacement[DBReplacements.cTagEnabled] = 1;
                        replacement[DBReplacements.cBefore] = "0";
                        replacement[DBReplacements.cToReplace] = "HR.HDTV";
                        replacement[DBReplacements.cWith] = @"<empty>";
                        try
                        {
                            replacement.Commit();
                        }
                        catch (Exception) { }

                        replacement = new DBReplacements();
                        replacement[DBReplacements.cIndex] = replacements.Length + 3;
                        replacement[DBReplacements.cEnabled] = 1;
                        replacement[DBReplacements.cTagEnabled] = 1;
                        replacement[DBReplacements.cBefore] = "0";
                        replacement[DBReplacements.cToReplace] = "HDTV";
                        replacement[DBReplacements.cWith] = @"<empty>";
                        try
                        {
                            replacement.Commit();
                        }
                        catch (Exception) { }

                        replacement = new DBReplacements();
                        replacement[DBReplacements.cIndex] = replacements.Length + 4;
                        replacement[DBReplacements.cEnabled] = 1;
                        replacement[DBReplacements.cTagEnabled] = 1;
                        replacement[DBReplacements.cBefore] = "0";
                        replacement[DBReplacements.cToReplace] = "DVDMux";
                        replacement[DBReplacements.cWith] = @"<empty>";
                        try
                        {
                            replacement.Commit();
                        }
                        catch (Exception) { }

                        nUpgradeDBVersion++;
                        break;

                    case 3:
                        //Disable regex setting for all
                        DBReplacements.GlobalSet(new DBReplacements(), DBReplacements.cIsRegex, new DBValue(0), new SQLCondition());
                        nUpgradeDBVersion++;
                        break;
                    case 4:
                        // add the part/roman stuff - defaults for comments
                        var newIndex  = DBReplacements.GetAll().Length;
                        replacement = new DBReplacements();
                        replacement[DBReplacements.cIndex] = newIndex++;
                        replacement[DBReplacements.cEnabled] = 1;
                        replacement[DBReplacements.cTagEnabled] = 0;
                        replacement[DBReplacements.cBefore] = "1";
                        replacement[DBReplacements.cToReplace] = @"(?<=(\s?\.?P[ar]*t\s?)) (X)?(IX|IV|V?I{0,3})";
                        replacement[DBReplacements.cWith] = @"<RomanToArabic>";
                        try
                        {
                            replacement.Commit();
                        }
                        catch (Exception) { }

                        replacement = new DBReplacements();
                        replacement[DBReplacements.cIndex] = newIndex++;
                        replacement[DBReplacements.cEnabled] = 1;
                        replacement[DBReplacements.cTagEnabled] = 0;
                        replacement[DBReplacements.cBefore] = "1";
                        replacement[DBReplacements.cToReplace] = @"(?<!(?:S\d+.?E\\d+\-E\d+.*|S\d+.?E\d+.*|\s\d+x\d+.*))P[ar]*t\s?(\d+)(\s?of\s\d{1,2})?";
                        replacement[DBReplacements.cWith] = @" S01E${1} ";
                        try
                        {
                            replacement.Commit();
                        }
                        catch (Exception) { }

                        replacement = new DBReplacements();
                        replacement[DBReplacements.cIndex] = newIndex++;
                        replacement[DBReplacements.cEnabled] = 1;
                        replacement[DBReplacements.cTagEnabled] = 0;
                        replacement[DBReplacements.cBefore] = "1";
                        replacement[DBReplacements.cToReplace] = @"(?<!(?:S\d+.?E\\d+\-E\d+.*|S\d+.?E\d+.*|\s\d+x\d+\s.*))(\d{1,2})\s?of\s\d{1,2}";
                        replacement[DBReplacements.cWith] = @" S01E${1} ";
                        replacement[DBReplacements.cIsRegex] = true;
                        try
                        {
                          replacement.Commit();
                        }
                        catch (Exception) { }

                        nUpgradeDBVersion++;
                        break;
                    default:
                        {
                            // no replacements in the db => put the default ones
                            AddDefaults();

                            nUpgradeDBVersion=5;
                        }
                        break;
                }
            }

            DBOption.SetOptions(DBOption.cDBReplacementsVersion, nCurrentDBVersion);
        }
Example #3
0
        private void linkLabelImportStringReplacements_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) {
            OpenFileDialog fd = new OpenFileDialog();
            fd.Filter = "Exported String Replacements (*.strrep)|*.strrep";
            if (fd.ShowDialog() == DialogResult.OK && System.IO.File.Exists(fd.FileName)) {
                StreamReader r = new StreamReader(fd.FileName);
                DBReplacements replacement;

                // Dialog box to make sure they want to clear out current replacements to import new ones.
                if (DialogResult.Yes ==
                    MessageBox.Show("You are about to delete all current string replacements," + Environment.NewLine +
                        "and replace them with the imported file." + Environment.NewLine + Environment.NewLine +
                        "Any current Replacements will be lost.  Would you like to proceed?", "Import Replacements", MessageBoxButtons.YesNo)) {
                    dataGridView_Replace.Rows.Clear();
                    DBReplacements.ClearAll();
                    MPTVSeriesLog.Write("Replacements cleared");
                }

                string line = string.Empty;
                string[] parts;
                int index = 0;

                // read file and import into database
                while ((line = r.ReadLine()) != null) {
                    char[] c = { ';' };
                    parts = line.Split(c, 6);
                    
                    // support older relacements file 
                    if (parts.Length < 5 || parts.Length > 6) continue;

                    replacement = new DBReplacements();                   
                    replacement[DBReplacements.cIndex] = index;
                    
                    if (Convert.ToInt32(parts[0]) == 0 || Convert.ToInt32(parts[0]) == 1) replacement[DBReplacements.cEnabled] = parts[0]; else continue;
                    if (Convert.ToInt32(parts[1]) == 0 || Convert.ToInt32(parts[1]) == 1) replacement[DBReplacements.cBefore] = parts[1]; else continue;
                    if (Convert.ToInt32(parts[2]) == 0 || Convert.ToInt32(parts[2]) == 1) replacement[DBReplacements.cTagEnabled] = parts[2]; else continue;
                    
                    // handle upgrade, first version does not contain IsRegEx part
                    if (parts.Length == 6) {
                        if (Convert.ToInt32(parts[3]) == 0 || Convert.ToInt32(parts[3]) == 1) replacement[DBReplacements.cIsRegex] = parts[3]; else continue;
                        replacement[DBReplacements.cToReplace] = parts[4];
                        replacement[DBReplacements.cWith] = parts[5];
                    }
                    else {
                        replacement[DBReplacements.cIsRegex] = "0";
                        replacement[DBReplacements.cToReplace] = parts[3];
                        replacement[DBReplacements.cWith] = parts[4];
                    }
                    if (replacement.Commit()) index++;
                }

                r.Close();
                MPTVSeriesLog.Write("String Replacements succesfully imported!");

                LoadReplacements();                
            }
        }
Example #4
0
        private void SaveAllReplacements()
        {
            // need to save back all the rows
            DBReplacements.ClearAll();

            foreach (DataGridViewRow row in dataGridView_Replace.Rows)
            {
                if (row.Index != dataGridView_Replace.NewRowIndex)
                {
                    DBReplacements replacement = new DBReplacements();
                    replacement[DBReplacements.cIndex] = row.Index.ToString();
                    foreach (DataGridViewCell cell in row.Cells)
                    {
                        if (cell.Value == null)
                            return;
                        if (cell.ValueType.Name == "Boolean")
                            replacement[cell.OwningColumn.Name] = (Boolean)cell.Value;
                        else
                            replacement[cell.OwningColumn.Name] = (String)cell.Value;
                    }              
                    replacement.Commit();
                }
            }
        }
Example #5
0
        private void dataGridView_Replace_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            DBReplacements replacement = new DBReplacements();
            replacement[DBReplacements.cIndex] = e.RowIndex.ToString();
            foreach (DataGridViewCell cell in dataGridView_Replace.Rows[e.RowIndex].Cells)
            {
                if (cell.Value == null) {
                    return;
                }

                if (cell.ValueType.Name == "Boolean") {
                    replacement[cell.OwningColumn.Name] = (Boolean)cell.Value;
                } else {
                    replacement[cell.OwningColumn.Name] = (String)cell.Value;
                }
            }
            replacement.Commit();
        }
Example #6
0
        static DBReplacements()
        {
            s_FieldToDisplayNameMap.Add(cEnabled, "Enabled");
            s_FieldToDisplayNameMap.Add(cTagEnabled, "Used As Tag");
            s_FieldToDisplayNameMap.Add(cBefore, "Run before matching");
            s_FieldToDisplayNameMap.Add(cToReplace, "Replace this..");
            s_FieldToDisplayNameMap.Add(cWith, "With this");
            s_FieldToDisplayNameMap.Add(cIsRegex, "Is Regex");

            DBReplacements dummy = new DBReplacements();

            int nCurrentDBVersion = cDBVersion;
            int nUpgradeDBVersion = DBOption.GetOptions(DBOption.cDBReplacementsVersion);

            while (nUpgradeDBVersion != nCurrentDBVersion)
            // take care of the upgrade in the table
            {
                DBReplacements replacement = new DBReplacements();
                switch (nUpgradeDBVersion)
                {
                case 2:
                    //Add tagEnabled colum
                    DBReplacements.GlobalSet(new DBReplacements(), DBReplacements.cTagEnabled, new DBValue(0), new SQLCondition());

                    replacement = new DBReplacements(3);
                    replacement[DBReplacements.cTagEnabled] = 1;
                    replacement.Commit();

                    replacement = new DBReplacements(4);
                    replacement[DBReplacements.cTagEnabled] = 1;
                    replacement.Commit();

                    replacement = new DBReplacements(5);
                    replacement[DBReplacements.cTagEnabled] = 1;
                    replacement.Commit();

                    //adding new replacement
                    DBReplacements[] replacements = DBReplacements.GetAll();

                    replacement = new DBReplacements();
                    replacement[DBReplacements.cIndex]      = replacements.Length;
                    replacement[DBReplacements.cEnabled]    = 1;
                    replacement[DBReplacements.cTagEnabled] = 1;
                    replacement[DBReplacements.cBefore]     = "0";
                    replacement[DBReplacements.cToReplace]  = "DSR";
                    replacement[DBReplacements.cWith]       = @"<empty>";
                    try
                    {
                        replacement.Commit();
                    }
                    catch (Exception) { }

                    replacement = new DBReplacements();
                    replacement[DBReplacements.cIndex]      = replacements.Length + 1;
                    replacement[DBReplacements.cEnabled]    = 1;
                    replacement[DBReplacements.cTagEnabled] = 1;
                    replacement[DBReplacements.cBefore]     = "0";
                    replacement[DBReplacements.cToReplace]  = "HR-HDTV";
                    replacement[DBReplacements.cWith]       = @"<empty>";
                    try
                    {
                        replacement.Commit();
                    }
                    catch (Exception) { }

                    replacement = new DBReplacements();
                    replacement[DBReplacements.cIndex]      = replacements.Length + 2;
                    replacement[DBReplacements.cEnabled]    = 1;
                    replacement[DBReplacements.cTagEnabled] = 1;
                    replacement[DBReplacements.cBefore]     = "0";
                    replacement[DBReplacements.cToReplace]  = "HR.HDTV";
                    replacement[DBReplacements.cWith]       = @"<empty>";
                    try
                    {
                        replacement.Commit();
                    }
                    catch (Exception) { }

                    replacement = new DBReplacements();
                    replacement[DBReplacements.cIndex]      = replacements.Length + 3;
                    replacement[DBReplacements.cEnabled]    = 1;
                    replacement[DBReplacements.cTagEnabled] = 1;
                    replacement[DBReplacements.cBefore]     = "0";
                    replacement[DBReplacements.cToReplace]  = "HDTV";
                    replacement[DBReplacements.cWith]       = @"<empty>";
                    try
                    {
                        replacement.Commit();
                    }
                    catch (Exception) { }

                    replacement = new DBReplacements();
                    replacement[DBReplacements.cIndex]      = replacements.Length + 4;
                    replacement[DBReplacements.cEnabled]    = 1;
                    replacement[DBReplacements.cTagEnabled] = 1;
                    replacement[DBReplacements.cBefore]     = "0";
                    replacement[DBReplacements.cToReplace]  = "DVDMux";
                    replacement[DBReplacements.cWith]       = @"<empty>";
                    try
                    {
                        replacement.Commit();
                    }
                    catch (Exception) { }

                    nUpgradeDBVersion++;
                    break;

                case 3:
                    //Disable regex setting for all
                    DBReplacements.GlobalSet(new DBReplacements(), DBReplacements.cIsRegex, new DBValue(0), new SQLCondition());
                    nUpgradeDBVersion++;
                    break;

                case 4:
                    // add the part/roman stuff - defaults for comments
                    var newIndex = DBReplacements.GetAll().Length;
                    replacement = new DBReplacements();
                    replacement[DBReplacements.cIndex]      = newIndex++;
                    replacement[DBReplacements.cEnabled]    = 1;
                    replacement[DBReplacements.cTagEnabled] = 0;
                    replacement[DBReplacements.cBefore]     = "1";
                    replacement[DBReplacements.cToReplace]  = @"(?<=(\s?\.?P[ar]*t\s?)) (X)?(IX|IV|V?I{0,3})";
                    replacement[DBReplacements.cWith]       = @"<RomanToArabic>";
                    try
                    {
                        replacement.Commit();
                    }
                    catch (Exception) { }

                    replacement = new DBReplacements();
                    replacement[DBReplacements.cIndex]      = newIndex++;
                    replacement[DBReplacements.cEnabled]    = 1;
                    replacement[DBReplacements.cTagEnabled] = 0;
                    replacement[DBReplacements.cBefore]     = "1";
                    replacement[DBReplacements.cToReplace]  = @"(?<!(?:S\d+.?E\\d+\-E\d+.*|S\d+.?E\d+.*|\s\d+x\d+.*))P[ar]*t\s?(\d+)(\s?of\s\d{1,2})?";
                    replacement[DBReplacements.cWith]       = @" S01E${1} ";
                    try
                    {
                        replacement.Commit();
                    }
                    catch (Exception) { }

                    replacement = new DBReplacements();
                    replacement[DBReplacements.cIndex]      = newIndex++;
                    replacement[DBReplacements.cEnabled]    = 1;
                    replacement[DBReplacements.cTagEnabled] = 0;
                    replacement[DBReplacements.cBefore]     = "1";
                    replacement[DBReplacements.cToReplace]  = @"(?<!(?:S\d+.?E\\d+\-E\d+.*|S\d+.?E\d+.*|\s\d+x\d+\s.*))(\d{1,2})\s?of\s\d{1,2}";
                    replacement[DBReplacements.cWith]       = @" S01E${1} ";
                    replacement[DBReplacements.cIsRegex]    = true;
                    try
                    {
                        replacement.Commit();
                    }
                    catch (Exception) { }

                    nUpgradeDBVersion++;
                    break;

                case 5:
                    newIndex = DBReplacements.GetAll().Length;

                    replacement = new DBReplacements();
                    replacement[DBReplacements.cIndex]      = newIndex++;
                    replacement[DBReplacements.cEnabled]    = 1;
                    replacement[DBReplacements.cTagEnabled] = 0;
                    replacement[DBReplacements.cBefore]     = "1";
                    replacement[DBReplacements.cToReplace]  = @"(?-i)([A-Z])\.(?=[A-Z])";
                    replacement[DBReplacements.cWith]       = @"${1}";
                    replacement[DBReplacements.cIsRegex]    = true;
                    try
                    {
                        replacement.Commit();
                    }
                    catch (Exception) { }

                    replacement = new DBReplacements();
                    replacement[DBReplacements.cIndex]      = newIndex++;
                    replacement[DBReplacements.cEnabled]    = 1;
                    replacement[DBReplacements.cTagEnabled] = 0;
                    replacement[DBReplacements.cBefore]     = "0";
                    replacement[DBReplacements.cToReplace]  = "<space><space>";
                    replacement[DBReplacements.cWith]       = @"<space>";
                    replacement[DBReplacements.cIsRegex]    = false;
                    try
                    {
                        replacement.Commit();
                    }
                    catch (Exception) { }

                    nUpgradeDBVersion++;
                    break;

                default:
                {
                    // no replacements in the db => put the default ones
                    AddDefaults();

                    nUpgradeDBVersion = 6;
                }
                break;
                }
            }

            DBOption.SetOptions(DBOption.cDBReplacementsVersion, nCurrentDBVersion);
        }
Example #7
0
        public static void AddDefaults()
        {
            DBReplacements replacement = new DBReplacements();

            replacement[DBReplacements.cIndex]      = "0";
            replacement[DBReplacements.cEnabled]    = "1";
            replacement[DBReplacements.cTagEnabled] = "0";
            replacement[DBReplacements.cBefore]     = "0";
            replacement[DBReplacements.cToReplace]  = ".";
            replacement[DBReplacements.cWith]       = @"<space>";
            replacement.Commit();

            replacement[DBReplacements.cIndex]      = "1";
            replacement[DBReplacements.cEnabled]    = "1";
            replacement[DBReplacements.cTagEnabled] = "0";
            replacement[DBReplacements.cBefore]     = "0";
            replacement[DBReplacements.cToReplace]  = "_";
            replacement[DBReplacements.cWith]       = @"<space>";
            replacement.Commit();

            replacement[DBReplacements.cIndex]      = "2";
            replacement[DBReplacements.cEnabled]    = "1";
            replacement[DBReplacements.cTagEnabled] = "0";
            replacement[DBReplacements.cBefore]     = "0";
            replacement[DBReplacements.cToReplace]  = "<space><space>";
            replacement[DBReplacements.cWith]       = @"<space>";
            replacement.Commit();

            // to avoid being parsed as second episode 20/80
            replacement[DBReplacements.cIndex]      = "3";
            replacement[DBReplacements.cEnabled]    = "1";
            replacement[DBReplacements.cBefore]     = "1";
            replacement[DBReplacements.cTagEnabled] = "1";
            replacement[DBReplacements.cToReplace]  = "720p";
            replacement[DBReplacements.cWith]       = @"<empty>";
            replacement.Commit();

            replacement[DBReplacements.cIndex]      = "4";
            replacement[DBReplacements.cEnabled]    = "1";
            replacement[DBReplacements.cBefore]     = "1";
            replacement[DBReplacements.cTagEnabled] = "1";
            replacement[DBReplacements.cToReplace]  = "1080i";
            replacement[DBReplacements.cWith]       = @"<empty>";
            replacement.Commit();

            replacement[DBReplacements.cIndex]      = "5";
            replacement[DBReplacements.cEnabled]    = "1";
            replacement[DBReplacements.cBefore]     = "1";
            replacement[DBReplacements.cTagEnabled] = "1";
            replacement[DBReplacements.cToReplace]  = "1080p";
            replacement[DBReplacements.cWith]       = @"<empty>";
            replacement.Commit();

            replacement[DBReplacements.cIndex]      = "6";
            replacement[DBReplacements.cEnabled]    = "1";
            replacement[DBReplacements.cBefore]     = "1";
            replacement[DBReplacements.cTagEnabled] = "1";
            replacement[DBReplacements.cToReplace]  = "x264";
            replacement[DBReplacements.cWith]       = @"<empty>";
            replacement.Commit();

            replacement[DBReplacements.cIndex]      = "7";
            replacement[DBReplacements.cEnabled]    = "1";
            replacement[DBReplacements.cTagEnabled] = "1";
            replacement[DBReplacements.cBefore]     = "0";
            replacement[DBReplacements.cToReplace]  = "DSR";
            replacement[DBReplacements.cWith]       = @"<empty>";
            replacement.Commit();

            replacement[DBReplacements.cIndex]      = "8";
            replacement[DBReplacements.cEnabled]    = "1";
            replacement[DBReplacements.cTagEnabled] = "1";
            replacement[DBReplacements.cBefore]     = "0";
            replacement[DBReplacements.cToReplace]  = "HR-HDTV";
            replacement[DBReplacements.cWith]       = @"<empty>";
            replacement.Commit();

            replacement[DBReplacements.cIndex]      = "9";
            replacement[DBReplacements.cEnabled]    = "1";
            replacement[DBReplacements.cTagEnabled] = "1";
            replacement[DBReplacements.cBefore]     = "0";
            replacement[DBReplacements.cToReplace]  = "HR.HDTV";
            replacement.Commit();

            replacement[DBReplacements.cIndex]      = "10";
            replacement[DBReplacements.cEnabled]    = "1";
            replacement[DBReplacements.cTagEnabled] = "1";
            replacement[DBReplacements.cBefore]     = "0";
            replacement[DBReplacements.cToReplace]  = "HDTV";
            replacement[DBReplacements.cWith]       = @"<empty>";
            replacement.Commit();

            replacement[DBReplacements.cIndex]      = "11";
            replacement[DBReplacements.cEnabled]    = "1";
            replacement[DBReplacements.cTagEnabled] = "1";
            replacement[DBReplacements.cBefore]     = "0";
            replacement[DBReplacements.cToReplace]  = "DVDMux";
            replacement[DBReplacements.cWith]       = @"<empty>";
            replacement.Commit();

            DBReplacements.GlobalSet(new DBReplacements(), DBReplacements.cIsRegex, new DBValue(0), new SQLCondition());

            // low roman numerals preceded by Part or pt (for eg. Part 4 => 1x04)
            replacement = new DBReplacements();
            replacement[DBReplacements.cIndex]      = 12;
            replacement[DBReplacements.cEnabled]    = 1;
            replacement[DBReplacements.cTagEnabled] = 0;
            replacement[DBReplacements.cBefore]     = "1";
            replacement[DBReplacements.cToReplace]  = @"(?<=(\s?\.?P[ar]*t\s?)) (X)?(IX|IV|V?I{0,3})";
            replacement[DBReplacements.cWith]       = @"<RomanToArabic>"; // special operator that causes them to be converted to arabics
            replacement[DBReplacements.cIsRegex]    = true;
            try
            {
                replacement.Commit();
            }
            catch (Exception) { }

            // Part n or Part n of m - not preceded by 1x01 or s1e01
            replacement = new DBReplacements();
            replacement[DBReplacements.cIndex]      = 13;
            replacement[DBReplacements.cEnabled]    = 1;
            replacement[DBReplacements.cTagEnabled] = 0;
            replacement[DBReplacements.cBefore]     = "1";
            replacement[DBReplacements.cToReplace]  = @"(?<!(?:S\d+.?E\\d+\-E\d+.*|S\d+.?E\d+.*|\s\d+x\d+.*))P[ar]*t\s?(\d+)(\s?of\s\d{1,2})?";
            replacement[DBReplacements.cWith]       = @" S01E${1} ";
            replacement[DBReplacements.cIsRegex]    = true;
            try
            {
                replacement.Commit();
            }
            catch (Exception) { }

            // n of m - not preceded by 1x01 or s1e01
            replacement = new DBReplacements();
            replacement[DBReplacements.cIndex]      = 14;
            replacement[DBReplacements.cEnabled]    = 1;
            replacement[DBReplacements.cTagEnabled] = 0;
            replacement[DBReplacements.cBefore]     = "1";
            replacement[DBReplacements.cToReplace]  = @"(?<!(?:S\d+.?E\\d+\-E\d+.*|S\d+.?E\d+.*|\s\d+x\d+\s.*))(\d{1,2})\s?of\s\d{1,2}";
            replacement[DBReplacements.cWith]       = @" S01E${1} ";
            replacement[DBReplacements.cIsRegex]    = true;
            try
            {
                replacement.Commit();
            }
            catch (Exception) { }

            replacement = new DBReplacements();
            replacement[DBReplacements.cIndex]      = 15;
            replacement[DBReplacements.cEnabled]    = 1;
            replacement[DBReplacements.cTagEnabled] = 0;
            replacement[DBReplacements.cBefore]     = "1";
            replacement[DBReplacements.cToReplace]  = @"(?-i)([A-Z])\.(?=[A-Z]\.)";
            replacement[DBReplacements.cWith]       = @"${1}";
            replacement[DBReplacements.cIsRegex]    = true;
            try
            {
                replacement.Commit();
            }
            catch (Exception) { }
        }