CSL.TorrentBuilder.RebuildCustomPath C# (CSharp) Method

RebuildCustomPath() public static method

public static RebuildCustomPath ( string information ) : string
information string
return string
        public static string RebuildCustomPath(string[] information)
        {
            string directoryName = null;
            char[] directoryArray = SettingsHandler.GetCustomDirectory().ToCharArray();

            for (int a = 0; a < directoryArray.Length; a++)
            {
                if (directoryArray[a] == ('%'))
                {
                    switch (directoryArray[a + 1])
                    {
                        /* information
                             * 0: artist
                             * 1: album
                             * 2: release format
                             * 3: bitrate
                             * 4: year
                             * 5: physical format
                             * 6: bit format
                             * */

                        case ('a'):
                            {
                                string artist = information[0];

                                if (SettingsHandler.GetArtistFlip() && information != null)
                                {
                                    if (artist.StartsWith("The") || artist.StartsWith("A "))
                                    {
                                        string[] modifiedArtist = artist.Split(' ');
                                        artist = "";
                                        for (int b = 1; b < modifiedArtist.Length; b++)
                                        {
                                            artist += modifiedArtist[b];
                                            if (!((b + 1) == modifiedArtist.Length))
                                            {
                                                artist += " ";
                                            }
                                        }
                                        artist += ", " + modifiedArtist[0];
                                    }
                                }
                                else if (SettingsHandler.GetDeleteThe())
                                {
                                    if (artist.StartsWith("The"))
                                    {
                                        string[] modifiedArtist = artist.Split(' ');
                                        artist = "";
                                        for (int b = 1; b < modifiedArtist.Length; b++)
                                        {
                                            artist += modifiedArtist[b];
                                            if (!((b + 1) == modifiedArtist.Length))
                                            {
                                                artist += " ";
                                            }
                                        }
                                    }
                                }
                                directoryName += artist;
                                a++;
                            } break;
                        case ('y'):
                            {

                                string year = information[4];
                                directoryName += year;

                                a++;
                            } break;
                        case ('b'):
                            {

                                string bitrate = information[3];
                                directoryName += bitrate;

                                a++;
                            } break;
                        case ('d'):
                            {

                                string bitformat = information[6];
                                directoryName += bitformat;

                                a++;
                            } break;
                        case ('p'):
                            {

                                string pformat = information[5];
                                directoryName += pformat;

                                a++;
                            } break;
                        case ('t'):
                            {
                                string album = information[1];
                                directoryName += album;

                                a++;
                            } break;
                        case ('z'):
                            {
                                string format = information[2];
                                directoryName += format;

                                a++;
                            } break;
                        case ('l'):
                            {

                                string format = information[2];
                                if (format.Equals(Live))
                                {
                                    directoryName += Live;
                                }

                                a++;
                            } break;
                        case ('c'):
                            {

                                string format = information[2];

                                if (format.Equals(Compilation))
                                {
                                    directoryName += Compilation;
                                }

                                a++;
                            } break;
                        case ('e'):
                            {

                                string format = information[2];

                                if (format.Equals(EP))
                                {
                                    directoryName += EP;
                                }

                                a++;
                            } break;
                        case ('r'):
                            {

                                string format = information[2];

                                if (format.Equals(Remix))
                                {
                                    directoryName += Remix;
                                }

                                a++;
                            } break;
                        case ('v'):
                            {

                                string format = information[2];

                                if (format.Equals(Interview))
                                {
                                    directoryName += Interview;
                                }

                                a++;
                            } break;
                        case ('n'):
                            {

                                string format = information[2];

                                if (format.Equals(Single))
                                {
                                    directoryName += Single;
                                }

                                a++;
                            } break;
                        case ('x'):
                            {

                                string format = information[2];

                                if (format.Equals(Bootleg))
                                {
                                    directoryName += Bootleg;
                                }

                                a++;
                            } break;
                        case ('s'):
                            {
                                string format = information[2];

                                if (format.Equals(Soundtrack))
                                {
                                    directoryName += Soundtrack;
                                }

                                a++;
                            } break;
                        case ('m'):
                            {
                                string format = information[2];

                                if (format.Equals(Mixtape))
                                {
                                    directoryName += Mixtape;
                                }

                                a++;
                            } break;
                        case ('u'):
                            {

                                string format = information[2];
                                if (format.Equals(Unknown))
                                {
                                    directoryName += Unknown;
                                }

                                a++;
                            } break;
                        case ('f'):
                            {
                                string format = information[2];
                                if (format.Equals(Album))
                                {
                                    directoryName += Album;
                                }

                                a++;
                            } break;
                        case ('i'):
                            {
                                string artist;

                                if (SettingsHandler.GetArtistFlip() && information != null)
                                {
                                    if (information[0].StartsWith("The") || information[0].StartsWith("A "))
                                    {
                                        string[] modifiedArtist = information[0].Split(' ');
                                        artist = "";
                                        for (int b = 1; b < modifiedArtist.Length; b++)
                                        {
                                            artist += modifiedArtist[b];
                                            if (!((b + 1) == modifiedArtist.Length))
                                            {
                                                artist += " ";
                                            }
                                        }
                                        artist += ", " + modifiedArtist[0];
                                        information[0] = artist;
                                    }
                                }
                                else if (SettingsHandler.GetDeleteThe())
                                {
                                    if (information[0].StartsWith("The"))
                                    {
                                        string[] modifiedArtist = information[0].Split(' ');
                                        artist = "";
                                        for (int b = 1; b < modifiedArtist.Length; b++)
                                        {
                                            artist += modifiedArtist[b];
                                            if (!((b + 1) == modifiedArtist.Length))
                                            {
                                                artist += " ";
                                            }
                                        }
                                        information[0] = artist;
                                    }
                                }

                                try
                                {
                                    directoryName += information[0][0]; //Will throw an index out of bounds error once if "Remove Artist". OK to ignore
                                }
                                catch { }
                                a++;
                            } break;
                    }
                }
                else
                {
                    directoryName += directoryArray[a];
                }
            }

            return SettingsHandler.GetDownloadDirectory() + directoryName.Trim();
        }