public void Populate(RenameScript contract)
 {
     RenameScriptID    = contract.RenameScriptID;
     ScriptName        = contract.ScriptName;
     Script            = contract.Script;
     IsEnabledOnImport = contract.IsEnabledOnImport;
 }
        private static void CreateInitialRenameScript()
        {
            RenameScriptRepository repScripts = new RenameScriptRepository();

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

            RenameScript initialScript = new RenameScript();

            Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(ServerSettings.Culture);

            initialScript.ScriptName        = JMMServer.Properties.Resources.Rename_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);
        }
 public RenameScript GetDefaultScript()
 {
     using (var session = JMMService.SessionFactory.OpenSession())
     {
         RenameScript cr = session
                           .CreateCriteria(typeof(RenameScript))
                           .Add(Restrictions.Eq("IsEnabledOnImport", 1))
                           .UniqueResult <RenameScript>();
         return(cr);
     }
 }
 public void Save(RenameScript obj)
 {
     using (var session = JMMService.SessionFactory.OpenSession())
     {
         // populate the database
         using (var transaction = session.BeginTransaction())
         {
             session.SaveOrUpdate(obj);
             transaction.Commit();
         }
     }
 }
Exemple #5
0
        // returns false if we should retry
        private bool RenameIfRequired()
        {
            try
            {
                RenameScript defaultScript = RepoFactory.RenameScript.GetDefaultScript();

                return(defaultScript == null || RenameFile(defaultScript.Script));
            }
            catch (Exception ex)
            {
                logger.Error(ex, ex.ToString());
                return(true);
            }
        }
Exemple #6
0
        private static IRenamer GetRenamerFor(RenameScript script)
        {
            if (!LegacyScriptImplementations.ContainsKey(script.RenamerType))
            {
                return(null);
            }

            try
            {
                return((IRenamer)Activator.CreateInstance(LegacyScriptImplementations[script.RenamerType], script));
            }
            catch (MissingMethodException)
            {
                return((IRenamer)Activator.CreateInstance(LegacyScriptImplementations[script.RenamerType]));
            }
        }
 public void Delete(int id)
 {
     using (var session = JMMService.SessionFactory.OpenSession())
     {
         // populate the database
         using (var transaction = session.BeginTransaction())
         {
             RenameScript cr = GetByID(id);
             if (cr != null)
             {
                 session.Delete(cr);
                 transaction.Commit();
             }
         }
     }
 }
    // Use this for initialization
    void Start()
    {
        this.gameObject.AddComponent <RenameScript>();
        RenameScript ren      = this.gameObject.GetComponent <RenameScript>();
        int          childNum = this.gameObject.transform.childCount;

        for (int i = 0; i < childNum; i++)
        {
            Transform child    = this.gameObject.transform.GetChild(i);
            Transform newChild = child.GetChild(0);
            string    hemisphere;
            if (this.gameObject.name.Contains("LH"))
            {
                hemisphere = "Left";
            }
            else
            {
                hemisphere = "Right";
            }
            child.name = ren.reName(child.name, hemisphere);
        }
    }
        void btnNewScript_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                DialogText dlg = new DialogText();
                dlg.Init(Shoko.Commons.Properties.Resources.Rename_EnterScriptName, "");
                dlg.Owner = Window.GetWindow(this);
                bool?res = dlg.ShowDialog();
                if (res.HasValue && res.Value)
                {
                    if (string.IsNullOrEmpty(dlg.EnteredText))
                    {
                        Utils.ShowErrorMessage(Shoko.Commons.Properties.Resources.Rename_BlankScript);
                        return;
                    }

                    RenameScript script = new RenameScript();
                    script.IsEnabledOnImport = 0;
                    script.Script            = "";
                    script.ScriptName        = dlg.EnteredText;
                    script.RenamerType       = "Legacy";
                    CL_Response <RenameScript> resp = VM_ShokoServer.Instance.ShokoServices.SaveRenameScript(script);

                    if (!string.IsNullOrEmpty(resp.ErrorMessage))
                    {
                        Utils.ShowErrorMessage(resp.ErrorMessage);
                        return;
                    }
                    defaultScriptID = resp.Result.RenameScriptID;
                    // refresh data
                    RefreshScripts();
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }
Exemple #10
0
    // Use this for initialization
    void Start()
    {
        thisObject = this.gameObject;
        int childNum = thisObject.transform.childCount;

        for (int i = 0; i < childNum; i++)
        {
            Transform child    = thisObject.transform.GetChild(i);
            Transform newchild = child.GetChild(0);
            newchild.gameObject.AddComponent <Rigidbody>();
            newchild.gameObject.GetComponent <Rigidbody>().useGravity  = true;
            newchild.gameObject.GetComponent <Rigidbody>().isKinematic = true;
            newchild.gameObject.AddComponent <MeshCollider>();
            // newchild.gameObject.GetComponent<SphereCollider>().radius = 4;
            newchild.transform.name = child.name;
            newchild.GetComponent <MeshRenderer>().material = culloff;
            // newchild.gameObject.AddComponent<FlipMesh>();
            newchild.gameObject.AddComponent <resetScript>();
            newchild.gameObject.AddComponent <resetColor>();
            newchild.gameObject.AddComponent <RenameScript>();
            newchild.gameObject.AddComponent <States>();
            resetScript  go     = newchild.GetComponent <resetScript>();
            RenameScript rename = newchild.GetComponent <RenameScript>();
            go.initialPosition();
        }
        for (int i = 0; i < childNum; i++)
        {
            Transform child    = thisObject.transform.GetChild(i);
            Transform newchild = child.GetChild(0);
            if (child.name == "rh.bankssts")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(25, 100, 40, 0);
            }
            else if (child.name == "rh.caudalanteriorcingulate")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(125, 100, 160, 0);
            }
            else if (child.name == "rh.caudalmiddlefrontal")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(100, 25, 0, 0);
            }
            else if (child.name == "rh.corpuscallosum")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(120, 70, 50, 0);
            }
            else if (child.name == "rh.cuneus")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(220, 20, 100, 0);
            }
            else if (child.name == "rh.entorhinal")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(220, 20, 10, 0);
            }
            else if (child.name == "rh.fusiform")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(180, 220, 140, 0);
            }
            else if (child.name == "rh.inferiorparietal")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(220, 60, 220, 0);
            }
            else if (child.name == "rh.inferiortemporal")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(180, 40, 120, 0);
            }
            else if (child.name == "rh.isthmuscingulate")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(140, 20, 140, 0);
            }
            else if (child.name == "rh.lateraloccipital")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(20, 30, 140, 0);
            }
            else if (child.name == "rh.lateralorbitofrontal")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(35, 75, 50, 0);
            }
            else if (child.name == "rh.lingual")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(225, 140, 140, 0);
            }
            else if (child.name == "rh.medialorbitofrontal")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(200, 35, 75, 0);
            }
            else if (child.name == "rh.middletemporal")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(160, 100, 50, 0);
            }
            else if (child.name == "rh.parahippocampal")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(20, 220, 60, 0);
            }
            else if (child.name == "rh.paracentral")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(60, 220, 60, 0);
            }
            else if (child.name == "rh.parsopercularis")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(220, 180, 140, 0);
            }
            else if (child.name == "rh.parsorbitalis")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(20, 100, 50, 0);
            }
            else if (child.name == "rh.parstriangularis")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(220, 60, 20, 0);
            }
            else if (child.name == "rh.pericalcarine")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(120, 100, 60, 0);
            }
            else if (child.name == "rh.postcentral")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(220, 20, 20, 0);
            }
            else if (child.name == "rh.posteriorcingulate")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(220, 180, 220, 0);
            }
            else if (child.name == "rh.precentral")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(60, 20, 220, 0);
            }
            else if (child.name == "rh.precuneus")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(160, 140, 180, 0);
            }
            else if (child.name == "rh.rostralanteriorcingulate")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(80, 20, 140, 0);
            }
            else if (child.name == "rh.rostralmiddlefrontal")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(75, 50, 125, 0);
            }
            else if (child.name == "rh.superiorfrontal")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(20, 220, 160, 0);
            }
            else if (child.name == "rh.superiorparietal")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(20, 180, 140, 0);
            }
            else if (child.name == "rh.superiortemporal")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(140, 220, 220, 0);
            }
            else if (child.name == "rh.supramarginal")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(80, 160, 20, 0);
            }
            else if (child.name == "rh.frontalpole")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(100, 0, 100, 0);
            }
            else if (child.name == "rh.temporalpole")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(70, 70, 70, 0);
            }
            else if (child.name == "rh.transversetemporal")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(150, 150, 200, 0);
            }
            else if (child.name == "rh.insula")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(255, 192, 32, 0);
            }
            else if (child.name == "rh.unlabelled")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(25, 5, 25, 0);
            }
            resetColor   col    = newchild.GetComponent <resetColor>();
            RenameScript rename = newchild.GetComponent <RenameScript>();
            newchild.name = rename.reName(newchild.name, "Right");
            col.initialColor();
        }
    }
Exemple #11
0
 public LuaRenamer(RenameScript rawScript)
 {
     this._rawScript = rawScript;
 }
 public NoSpaceRenamer(RenameScript script)
 {
     this.script = new LegacyRenamer(script);
 }
Exemple #13
0
 public MxFlixRenamer(RenameScript script)
 {
     this.script = new LegacyRenamer(script);
 }