Esempio n. 1
0
		public void Save(RenameScript obj)
		{
			using (var session = JMMService.SessionFactory.OpenSession())
			{
				// populate the database
				using (var transaction = session.BeginTransaction())
				{
					session.SaveOrUpdate(obj);
					transaction.Commit();
				}
			}
		}
Esempio n. 2
0
        public void RenameIfRequired()
        {
            try
            {
                RenameScript defaultScript = RepoFactory.RenameScript.GetDefaultScript();

                if (defaultScript == null)
                {
                    return;
                }

                RenameFile(defaultScript.Script);
            }
            catch (Exception ex)
            {
                logger.Error(ex, ex.ToString());
                return;
            }
        }
Esempio n. 3
0
        public void RenameIfRequired()
        {
            try
            {
                RenameScriptRepository repScripts    = new RenameScriptRepository();
                RenameScript           defaultScript = repScripts.GetDefaultScript();

                if (defaultScript == null)
                {
                    return;
                }

                RenameFile(defaultScript.Script);
            }
            catch (Exception ex)
            {
                logger.ErrorException(ex.ToString(), ex);
                return;
            }
        }
Esempio n. 4
0
        public Contract_RenameScript_SaveResponse SaveRenameScript(Contract_RenameScript contract)
        {
            Contract_RenameScript_SaveResponse response = new Contract_RenameScript_SaveResponse();
            response.ErrorMessage = "";
            response.RenameScript = null;

            try
            {

                RenameScriptRepository repScripts = new RenameScriptRepository();
                RenameScript script = null;
                if (contract.RenameScriptID.HasValue)
                {
                    // update
                    script = repScripts.GetByID(contract.RenameScriptID.Value);
                    if (script == null)
                    {
                        response.ErrorMessage = "Could not find Rename Script ID: " + contract.RenameScriptID.Value.ToString();
                        return response;
                    }
                }
                else
                {
                    // create
                    script = new RenameScript();
                }

                if (string.IsNullOrEmpty(contract.ScriptName))
                {
                    response.ErrorMessage = "Must specify a Script Name";
                    return response;
                }

                // check to make sure we multiple scripts enable on import (only one can be selected)
                List<RenameScript> allScripts = repScripts.GetAll();

                if (contract.IsEnabledOnImport == 1)
                {
                    foreach (RenameScript rs in allScripts)
                    {
                        if (rs.IsEnabledOnImport == 1 && (!contract.RenameScriptID.HasValue || (contract.RenameScriptID.Value != rs.RenameScriptID)))
                        {
                            rs.IsEnabledOnImport = 0;
                            repScripts.Save(rs);
                        }
                    }
                }

                script.IsEnabledOnImport = contract.IsEnabledOnImport;
                script.Script = contract.Script;
                script.ScriptName = contract.ScriptName;
                repScripts.Save(script);

                response.RenameScript = script.ToContract();

                return response;
            }
            catch (Exception ex)
            {
                logger.ErrorException(ex.ToString(), ex);
                response.ErrorMessage = ex.Message;
                return response;
            }
        }
Esempio n. 5
0
		private static void CreateInitialRenameScript()
		{
			RenameScriptRepository repScripts = new RenameScriptRepository();

			if (repScripts.GetAll().Count() > 0) return;

			RenameScript initialScript = new RenameScript();

			initialScript.ScriptName = "Default";
			initialScript.IsEnabledOnImport = 0;
			initialScript.Script = "// Sample Output: [Coalgirls]_Highschool_of_the_Dead_-_01_(1920x1080_Blu-ray_H264)_[90CC6DC1].mkv" + Environment.NewLine +
				"// Sub group name" + Environment.NewLine +
				"DO ADD '[%grp] '" + Environment.NewLine +
				"// Anime Name, use english name if it exists, otherwise use the Romaji name" + Environment.NewLine +
				"IF I(eng) DO ADD '%eng '" + Environment.NewLine +
				"IF I(ann);I(!eng) DO ADD '%ann '" + Environment.NewLine +
				"// Episode Number, don't use episode number for movies" + Environment.NewLine +
				"IF T(!Movie) DO ADD '- %enr'" + Environment.NewLine +
				"// If the file version is v2 or higher add it here" + Environment.NewLine +
				"IF F(!1) DO ADD 'v%ver'" + Environment.NewLine +
				"// Video Resolution" + Environment.NewLine +
				"DO ADD ' (%res'" + Environment.NewLine +
				"// Video Source (only if blu-ray or DVD)" + Environment.NewLine +
				"IF R(DVD),R(Blu-ray) DO ADD ' %src'" + Environment.NewLine +
				"// Video Codec" + Environment.NewLine +
				"DO ADD ' %vid'" + Environment.NewLine +
				"// Video Bit Depth (only if 10bit)" + Environment.NewLine +
				"IF Z(10) DO ADD ' %bitbit'" + Environment.NewLine +
				"DO ADD ') '" + Environment.NewLine +
				"DO ADD '[%CRC]'" + Environment.NewLine +
				"" + Environment.NewLine +
				"// Replacement rules (cleanup)" + Environment.NewLine +
				"DO REPLACE ' ' '_' // replace spaces with underscores" + Environment.NewLine +
				"DO REPLACE 'H264/AVC' 'H264'" + Environment.NewLine +
				"DO REPLACE '0x0' ''" + Environment.NewLine +
				"DO REPLACE '__' '_'" + Environment.NewLine +
				"DO REPLACE '__' '_'" + Environment.NewLine +
				"" + Environment.NewLine +
				"// Replace all illegal file name characters" + Environment.NewLine +
				"DO REPLACE '<' '('" + Environment.NewLine +
				"DO REPLACE '>' ')'" + Environment.NewLine +
				"DO REPLACE ':' '-'" + Environment.NewLine +
				"DO REPLACE '" + ((Char)34).ToString() + "' '`'" + Environment.NewLine +
				"DO REPLACE '/' '_'" + Environment.NewLine +
				"DO REPLACE '/' '_'" + Environment.NewLine +
				"DO REPLACE '\\' '_'" + Environment.NewLine +
				"DO REPLACE '|' '_'" + Environment.NewLine +
				"DO REPLACE '?' '_'" + Environment.NewLine +
				"DO REPLACE '*' '_'" + Environment.NewLine;

			repScripts.Save(initialScript);


		}