public static string[] getFinalEpisodes(string[] pathOFfiles) { int i = 0; List <string> pathFinalEpisode = new List <string>(); string currentserie = nameserie(Fonction.OnlyFileName(pathOFfiles[0])); string currentseason = numberSeason(Fonction.OnlyFileName(pathOFfiles[0])); string currentepisode = numberEpisode(Fonction.OnlyFileName(pathOFfiles[0])); int maxcurrentepisode = 0; int indexmaxepisode = 0; while (i < pathOFfiles.Length) { if (currentserie != nameserie(Fonction.OnlyFileName(pathOFfiles[i])) || currentseason != numberSeason(Fonction.OnlyFileName(pathOFfiles[i]))) { string FileNameOfCurrentSerie = Fonction.OnlyFileName(pathOFfiles[indexmaxepisode]); int MyNbMaxEpisode = int.Parse(numberEpisode(FileNameOfCurrentSerie)); int MovieDBMaxEpisode = MovieDB.getFinalNumberEpispdeTV(nameserie(FileNameOfCurrentSerie), int.Parse(numberSeason(FileNameOfCurrentSerie))); if (MyNbMaxEpisode == MovieDBMaxEpisode) { pathFinalEpisode.Add(pathOFfiles[indexmaxepisode]); } maxcurrentepisode = 0; currentserie = nameserie(Fonction.OnlyFileName(pathOFfiles[i])); currentseason = numberSeason(Fonction.OnlyFileName(pathOFfiles[i])); } else if (maxcurrentepisode < int.Parse(numberEpisode(Fonction.OnlyFileName(pathOFfiles[i])))) { maxcurrentepisode = int.Parse(numberEpisode(Fonction.OnlyFileName(pathOFfiles[i]))); indexmaxepisode = i; } i++; } return(pathFinalEpisode.ToArray()); }
public static string numberEpisode(string namefile) { ///Trouve le numero de l'episode apres renameserie/// char[] c = namefile.ToCharArray(); char[] tmp = new char[2]; int i = 0; bool find = false; while (i < c.Length) { if ((i > 6) && Fonction.IsNumeric(c[i]) && Fonction.IsNumeric(c[i - 1]) && Fonction.IsNumeric(c[i - 3]) && Fonction.IsNumeric(c[i - 4]) && ((c[i - 5] == (char)83 || c[i - 5] == (char)115) && (c[i - 2] == (char)69 || c[i - 2] == (char)101))) { tmp[0] = c[i - 1]; tmp[1] = c[i]; find = true; break; } i++; } if (find == false) { return("99"); } string result = new string(tmp); result = result.TrimEnd('\0'); return(result); }
public static string[] getFinalEpisodesdos(string[] pathOFfiles) { int i = 0; List <string> pathFinalEpisode = new List <string>(); string currentserie = nameserie(Fonction.OnlyFileName(pathOFfiles[0])); string currentseason = numberSeason(Fonction.OnlyFileName(pathOFfiles[0])); string currentepisode = numberEpisode(Fonction.OnlyFileName(pathOFfiles[0])); int maxcurrentepisode = 0; int indexmaxepisode = 0; while (i < pathOFfiles.Length) { if (currentserie != nameserie(Fonction.OnlyFileName(pathOFfiles[i])) || currentseason != numberSeason(Fonction.OnlyFileName(pathOFfiles[i]))) { pathFinalEpisode.Add(pathOFfiles[indexmaxepisode]); maxcurrentepisode = 0; currentserie = nameserie(Fonction.OnlyFileName(pathOFfiles[i])); currentseason = numberSeason(Fonction.OnlyFileName(pathOFfiles[i])); } else if (maxcurrentepisode < int.Parse(numberEpisode(Fonction.OnlyFileName(pathOFfiles[i])))) { maxcurrentepisode = int.Parse(numberEpisode(Fonction.OnlyFileName(pathOFfiles[i]))); indexmaxepisode = i; } i++; } return(pathFinalEpisode.ToArray()); }
public static bool isSerie(string namefile) { char[] c = namefile.ToCharArray(); string extention = Fonction.OnlyExtention(namefile); int i = 6; if (c[0] == '.' && c[1] == '_') { return(false); } if (extention == ".mkv" || extention == ".avi" || extention == ".mp4") { while (i < c.Length) { //if (Fonction.IsNumeric(c[i]) && ((c[i - 5] == (char)83 || c[i - 5] == (char)115) && (c[i - 2] == (char)69 || c[i - 2] == (char)101))) if ((i > 6) && Fonction.IsNumeric(c[i]) && Fonction.IsNumeric(c[i - 1]) && Fonction.IsNumeric(c[i - 3]) && Fonction.IsNumeric(c[i - 4]) && ((c[i - 5] == (char)83 || c[i - 5] == (char)115) && (c[i - 2] == (char)69 || c[i - 2] == (char)101))) { return(true); } i++; } return(false); } else { return(false); } }
private void cpy_btn_addFinal_Click(object sender, EventArgs e) { int i = cpy_list_episode_renommer.Items.Count - 1; while (i >= 0) { string currentfile = cpy_list_episode_renommer.Items[cpy_list_episode_renommer.Items.Count - 1].ToString(); string currentserie = Code.nameserie(currentfile); int currentseason = int.Parse(Code.numberSeason(currentfile)); int currentepisode = int.Parse(Code.numberEpisode(currentfile)); if (MovieDB.getFinalNumberEpispdeTV(currentserie, currentseason) == currentepisode) { int y = 0; char[] c = currentfile.ToCharArray(); while (y < c.Length) { if ((y > 6) && Fonction.IsNumeric(c[y]) && Fonction.IsNumeric(c[y - 1]) && Fonction.IsNumeric(c[y - 3]) && Fonction.IsNumeric(c[y - 4]) && ((c[y - 5] == (char)83 || c[y - 5] == (char)115) && (c[y - 2] == (char)69 || c[y - 2] == (char)101))) { currentfile = currentfile.Insert(y + 1, " FiNAL"); break; } y++; } //currentfile = currentfile.Insert(currentfile.Length - 4, " Final"); cpy_list_episode_renommer.Items.RemoveAt(i); cpy_list_episode_renommer.Items.Insert(i, currentfile); return; } i--; } logbox_addtext("L'episode final n'est pas present"); }
private void load_Serie(string DirectoryPath) { SND_TB_Directory_Path.Text = DirectoryPath; string[] tabfiles; int i = 0; try { tabfiles = Directory.GetFiles(DirectoryPath, "*", SearchOption.AllDirectories); string[] tabserie = new string[tabfiles.Length]; foreach (string file in tabfiles) { if (Code.isSerie(Fonction.OnlyFileName(file))) { tabserie[i] = file; i++; } } tabserie = tabserie.Where(episode => !string.IsNullOrEmpty(episode)).ToArray(); Array.Sort(tabserie); } catch (Exception expt) { MessageBox.Show("L'erreur suivante s'est declaree :" + expt.Message); } }
private void cpy_cb_SeasonNumber_SelectedIndexChanged(object sender, EventArgs e) { string tmp; DataTable EpisodeTable = new DataTable(); EpisodeTable.Columns.Add("Path"); EpisodeTable.Columns.Add("Display"); cpy_list_episode.Enabled = true; cpy_list_episode_renommer.Enabled = true; cpy_list_episode.DataSource = null; cpy_list_episode.Items.Clear(); cpy_list_episode_renommer.Items.Clear(); foreach (string file in Code.tabepisodeserie) { DataRow OneEpisode = EpisodeTable.NewRow(); tmp = Code.RenameSerie(Fonction.OnlyFileName(file)); if (Code.nameserie(tmp) == cpy_cb_Serie.SelectedItem.ToString() && Code.numberSeason(tmp) == cpy_cb_SeasonNumber.SelectedItem.ToString()) { OneEpisode["Path"] = file; OneEpisode["Display"] = file.Replace(cpy_tb_sourcepath.Text, "."); EpisodeTable.Rows.Add(OneEpisode); //cpy_list_episode.Items.Add(file); if (cpy_checkrename.Checked == true) { cpy_list_episode_renommer.Items.Add(tmp); } } } cpy_list_episode.DataSource = EpisodeTable; cpy_list_episode.DisplayMember = "Display"; cpy_list_episode.ValueMember = "Path"; cpy_btn_findTitle.Enabled = true; }
private void rnm_btn_parcourir_Click(object sender, EventArgs e) { rnm_TB_Directory_Path.Text = ""; if (rnm_src_path()) { string[] tabfiles; if (sousdossier.Checked == true) { tabfiles = Directory.GetFiles(rnm_TB_Directory_Path.Text, "*", SearchOption.AllDirectories); } else { tabfiles = Directory.GetFiles(rnm_TB_Directory_Path.Text); } rnm_listBox1.Items.Clear(); rnm_listBox2.Items.Clear(); progressBar2.Maximum = tabfiles.Length; progressBar2.Step = 100; if (checkBox1.Checked == true) { foreach (string file in tabfiles) { progressBar2.PerformStep(); if (Code.isSerie(Fonction.OnlyFileName(file))) { if ((Code.RenameSerie(Fonction.OnlyFileName(file)) != Fonction.OnlyFileName(file)) && Code.isBlackListed(@file) == false) { rnm_listBox1.Items.Add(file); } } } } else { foreach (string file in tabfiles) { if (Code.isSerie(Fonction.OnlyFileName(file))) { progressBar2.PerformStep(); rnm_listBox1.Items.Add(file); } } } if (rnm_listBox1.Items.Count == 0) { MessageBox.Show("Aucune serie n'a ete trouvee"); } else { foreach (string path in rnm_listBox1.Items) { string newname = Code.RenameSerie(Fonction.OnlyFileName(path)); rnm_listBox2.Items.Add(newname); progressBar2.PerformStep(); } } progressBar2.Value = 0; } }
//Travaille Arriere Plan private void back_Worker_DoWork(object sender, DoWorkEventArgs e) { int i = 0; int nbrows = wl_dataGridView.Rows.Count; string source = ""; string destination = ""; foreach (DataGridViewRow row in wl_dataGridView.Rows) { try { source = Fonction.pathCreator(row.Cells[1].Value.ToString()); destination = Fonction.pathCreator(row.Cells[2].Value.ToString()); switch (row.Cells[0].Value) { case "Copy": File.Copy(source, destination); //File.Copy(row.Cells[1].Value.ToString(), row.Cells[2].Value.ToString(),false); this.Invoke(new Action(() => { logbox_addtext("Fichier copié : " + row.Cells[2].Value.ToString()); })); break; case "CopyDelete": File.Copy(source, destination); this.Invoke(new Action(() => { logbox_addtext("Fichier copié : " + row.Cells[2].Value.ToString()); })); File.SetAttributes(source, FileAttributes.Normal); File.Delete(source); this.Invoke(new Action(() => { logbox_addtext("Fichier supprimer : " + row.Cells[2].Value.ToString()); })); break; case "Rename": File.Move(source, destination); //File.Move ne fonctionne pas comme pour cpoy pour faire ;archer les chemin long //File.Move(row.Cells[1].Value.ToString(), row.Cells[2].Value.ToString()); this.Invoke(new Action(() => { logbox_addtext(Fonction.OnlyFileName(row.Cells[1].Value.ToString()) + " --TO-> " + Fonction.OnlyFileName(row.Cells[2].Value.ToString())); })); break; } } catch (Exception ex) { this.Invoke(new Action(() => { logbox_addtext("ERREUR : " + ex.Message); })); } back_Worker.ReportProgress((i + 1) * 100 / nbrows); i++; } }
private void rnm_btn_WaitList_Click(object sender, EventArgs e) { for (int i = 0; i < rnm_listBox2.Items.Count; i++) { string directorypath = Fonction.OnlyDirectoryPath(rnm_listBox1.Items[i].ToString()); this.wl_dataGridView.Rows.Add("Rename", rnm_listBox1.Items[i].ToString(), directorypath + rnm_listBox2.Items[i].ToString()); } }
private void backCopy_DoWork(object sender, DoWorkEventArgs e) { string path = folderBrowserEnregister.SelectedPath; try { string selectedserie = ""; string Number = ""; this.Invoke(new Action(() => { selectedserie = Code.nameserie(cpy_list_episode_renommer.Items[0].ToString()); Number = cpy_cb_SeasonNumber.SelectedItem.ToString(); })); if (cpy_checkcreate.Checked == true) { path = path + "\\" + selectedserie + "\\" + Number; Directory.CreateDirectory(path); } if (cpy_checkrename.Checked == true) { for (int i = 0; i < cpy_list_episode.Items.Count; i++) { File.Copy(cpy_list_episode.Items[i].ToString(), path + "\\" + cpy_list_episode_renommer.Items[i].ToString(), false); this.Invoke(new Action(() => { logBox.Text += "Fichier copié : " + cpy_list_episode_renommer.Items[i].ToString() + Environment.NewLine; })); backCopy.ReportProgress((i + 1) * 100 / cpy_list_episode.Items.Count); } } else { for (int i = 0; i < cpy_list_episode.Items.Count; i++) { File.Copy(cpy_list_episode.Items[1].ToString(), path + "\\" + Fonction.OnlyFileName(cpy_list_episode.Items[i].ToString()), false); this.Invoke(new Action(() => { logBox.Text += "Fichier copié : " + Fonction.OnlyFileName(cpy_list_episode.Items[i].ToString()) + Environment.NewLine; })); } } } catch (Exception exp) { MessageBox.Show("Erreur : " + exp.Message); } this.Invoke(new Action(() => { changed_enable(true); })); }
private void cpy_btn_WaitList_Click(object sender, EventArgs e) { if (cpy_list_episode.Items.Count != 0) { if (cpy_destinationPath()) { string path = cpy_tb_DestinationPath.Text; string selectedserie = ""; string Number = ""; selectedserie = Code.nameserie(cpy_list_episode_renommer.Items[0].ToString()); Number = cpy_cb_SeasonNumber.SelectedItem.ToString(); if (cpy_checkcreate.Checked == true) { path = path + "\\" + selectedserie + "\\" + Number; Directory.CreateDirectory(path); } if (cpy_checkrename.Checked == true) { for (int i = 0; i < cpy_list_episode.Items.Count; i++) { DataRowView ItemRow = (DataRowView)cpy_list_episode.Items[i]; string source = ItemRow.Row.ItemArray[0].ToString(); this.wl_dataGridView.Rows.Add("Copy", source, path + "\\" + cpy_list_episode_renommer.Items[i].ToString()); //this.wl_dataGridView.Rows.Add("Copy", cpy_list_episode.SelectedValue, path + "\\" + cpy_list_episode_renommer.Items[i].ToString()); } } else { for (int i = 0; i < cpy_list_episode.Items.Count; i++) { this.wl_dataGridView.Rows.Add("Copy", cpy_list_episode.Items[i].ToString(), path + "\\" + Fonction.OnlyFileName(cpy_list_episode.Items[i].ToString())); this.Invoke(new Action(() => { logbox_addtext("Fichier copié : " + Fonction.OnlyFileName(cpy_list_episode.Items[i].ToString())); })); } } } } else { MessageBox.Show("Vous n'avez pas d'episode a traiter", "Veuillez selectioner des episodes", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//Menu Contextuel private void cpy_CMenu_btn_WaitList_CopyDelete_Click(object sender, EventArgs e) { DialogResult dialogResult = MessageBox.Show("Etes-Vous sure de vouloir supprimer les Episodes ?", Path.GetFileNameWithoutExtension(AppDomain.CurrentDomain.FriendlyName), MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { if (cpy_list_episode.Items.Count != 0) { if (cpy_destinationPath()) { string path = cpy_tb_DestinationPath.Text; string selectedserie = ""; string Number = ""; selectedserie = Code.nameserie(cpy_list_episode_renommer.Items[0].ToString()); Number = cpy_cb_SeasonNumber.SelectedItem.ToString(); if (cpy_checkcreate.Checked == true) { path = path + "\\" + selectedserie + "\\" + Number; } if (cpy_checkrename.Checked == true) { for (int i = 0; i < cpy_list_episode.Items.Count; i++) { this.wl_dataGridView.Rows.Add("CopyDelete", cpy_list_episode.Items[i].ToString(), path + "\\" + cpy_list_episode_renommer.Items[i].ToString()); } } else { for (int i = 0; i < cpy_list_episode.Items.Count; i++) { this.wl_dataGridView.Rows.Add("CopyDelete", cpy_list_episode.Items[i].ToString(), path + "\\" + Fonction.OnlyFileName(cpy_list_episode.Items[i].ToString())); this.Invoke(new Action(() => { logbox_addtext("Fichier copié : " + Fonction.OnlyFileName(cpy_list_episode.Items[i].ToString())); })); } } } } else { MessageBox.Show("Vous n'avez pas d'episode a traiter", "Veuillez selectioner des episodes", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
//Fonction Speciale void cpy_load_series(string DirectoryPath) { cpy_tb_sourcepath.Text = DirectoryPath; string[] tabfiles; int i = 0; try { tabfiles = Directory.GetFiles(DirectoryPath, "*", SearchOption.AllDirectories); string[] tabserie = new string[tabfiles.Length]; cpy_cb_Serie.Enabled = true; foreach (string file in tabfiles) { if (Code.isSerie(Fonction.OnlyFileName(file))) { tabserie[i] = file; i++; } } cpy_list_episode.DataSource = null; cpy_list_episode.Items.Clear(); cpy_cb_Serie.Items.Clear(); cpy_cb_SeasonNumber.Items.Clear(); cpy_list_episode_renommer.Items.Clear(); tabserie = tabserie.Where(episode => !string.IsNullOrEmpty(episode)).ToArray(); Array.Sort(tabserie); i = 0; string[] tabepisoderename = new string[tabserie.Length]; foreach (string episode in tabserie) { tabepisoderename[i] = Code.RenameSerie(Fonction.OnlyFileName(tabserie[i])); i++; } Code.tabepisodeserie = tabserie; Code.tabepisodeserierename = tabepisoderename; Code.remplirlisteSerie(tabserie); } catch (Exception expt) { MessageBox.Show("L'erreur suivante s'est declaree :" + expt.Message); } }
public static void remplirlisteSerie(string[] tab) { string tmp = Code.nameserie(Code.RenameSerie(Fonction.OnlyFileName(tab[0]))); List <string> MyListSerie = new List <string>(); Form1.cpy_cb_Serie.Items.Add("-------------------"); Form1.cpy_cb_Serie.SelectedIndex = 0; Form1.cpy_cb_Serie.Items.Add(tmp); foreach (string filename in tab) { if (Code.nameserie(Code.RenameSerie(Fonction.OnlyFileName(filename))) != tmp) { tmp = Code.nameserie(Code.RenameSerie(Fonction.OnlyFileName(filename))); MyListSerie.Add(tmp); } } string[] MyTabSerie = new string[MyListSerie.Count]; MyTabSerie = MyListSerie.Distinct().ToArray(); foreach (string serieName in MyTabSerie) { Form1.cpy_cb_Serie.Items.Add(serieName); } }
public static string nameserie(string namefile) { ///Trouve le nom de la serie apres transformation/// char[] c = namefile.ToCharArray(); char[] newc = new char[c.Length]; string result; int i = 0; while (i < c.Length) { if ((i >= 6) && Fonction.IsNumeric(c[i + 2]) && Fonction.IsNumeric(c[i + 3]) && Fonction.IsNumeric(c[i + 5]) && Fonction.IsNumeric(c[i + 6]) && ((c[i + 1] == (char)83 || c[i + 1] == (char)115) && (c[i + 4] == (char)69 || c[i + 4] == (char)101))) { result = new string(newc); result = result.TrimEnd('\0'); return(result); } newc[i] = c[i]; i++; } result = new string(newc); result = result.TrimEnd('\0'); return(result); }
//Code pour COMBOBOX private void cpy_cb_Serie_SelectedIndexChanged(object sender, EventArgs e) { string[] saisons = new string[Code.tabepisodeserie.Length]; int i = 0; string tmp; cpy_cb_SeasonNumber.Enabled = true; cpy_cb_SeasonNumber.Items.Clear(); if (cpy_cb_Serie.SelectedIndex != 0) { foreach (string file in Code.tabepisodeserie) { tmp = Code.RenameSerie(Fonction.OnlyFileName(file)); if (Code.nameserie(tmp) == cpy_cb_Serie.SelectedItem.ToString()) { saisons[i] = Code.numberSeason(tmp); i++; } } saisons = saisons.Distinct().ToArray(); saisons = saisons.Where(episode => !string.IsNullOrEmpty(episode)).ToArray(); Array.Sort(saisons); foreach (string s in saisons) { cpy_cb_SeasonNumber.Items.Add(s); } if (saisons.Length == 1) { cpy_cb_SeasonNumber.SelectedIndex = 0; } else { cpy_cb_SeasonNumber.SelectedIndex = 0; } } }
public static string RenameSerie(string oldname) { oldname = Fonction.RemoveBetween(oldname, '[', ']'); //Supprime " [*] " string newname = ""; char[] c = oldname.ToCharArray(); int i = 0; //1 int y = 1; int ybis = 0; int tablength = c.Length; char[] newc = new char[tablength]; while (c[i] == ' ' || c[i] == '.' || c[i] == '-') { i++; } if (c[i] >= 'a' && c[i] <= 'z') { newc[i] = (char)(c[i] - 32); i++; } else { newc[0] = c[i]; i++; } while (i <= tablength - 5) { if (c[i] == 46) //point en espace { c[i] = (char)32; } if ((c[i] >= 'a' && c[i] <= 'z') && (c[i - 1] == 32 || c[i - 1] == 46))//Maj des mots { c[i] = (char)(c[i] - 32); } if ((i > 6) && Fonction.IsNumeric(c[i]) && Fonction.IsNumeric(c[i - 1]) && Fonction.IsNumeric(c[i - 3]) && Fonction.IsNumeric(c[i - 4]) && ((c[i - 5] == (char)83 || c[i - 5] == (char)115) && (c[i - 2] == (char)69 || c[i - 2] == (char)101))) { if (c[i - 2] == (char)101 || c[i - 5] == (char)115) { newc[i - 2] = 'E'; newc[i - 5] = 'S'; } newc[y] = c[i]; i = tablength - 4; //place le curseur sur le point de .mkv y++; while (i < tablength) { newc[y] = c[i]; i++; y++; } break; } ybis = y + 1; newc[y] = c[i]; y++; i++; } newname = new string(newc); newname = newname.TrimEnd('\0'); return(newname); }