private void button2_Click(object sender, RoutedEventArgs e) { int season = Int32.Parse(textBox2.Text); int episode = Int32.Parse(textBox3.Text); string name = DownloadFromApi.apiGet("https://api.thetvdb.com/series/" + ID + "/episodes/query?airedSeason=" + season + "&airedEpisode=" + episode, tkn, 0); string showName = DownloadFromApi.apiGet("https://api.thetvdb.com/series/" + ID, tkn, 0); JObject parsed = JObject.Parse(name); JObject parsedSN = JObject.Parse(info); name = parsed["data"][0]["episodeName"].ToString(); showName = parsedSN["data"][0]["seriesName"].ToString(); string invalid = new string(System.IO.Path.GetInvalidFileNameChars()) + new string(System.IO.Path.GetInvalidPathChars()); foreach (char znak in invalid) { name = name.Replace(znak.ToString(), ""); } if (season < 10) { if (episode < 10) { name = showName + " - S0" + season + "E0" + episode + " - " + name; } if (episode >= 10) { name = showName + " - S0" + season + "E" + episode + " - " + name; } } else if (season < 10) { if (episode < 10) { name = showName + " - S" + season + "E0" + episode + " - " + name; } if (episode >= 10) { name = showName + " - S" + season + "E" + episode + " - " + name;; } } if (!File.Exists(path)) { } else { string nameOrig = name; string ext = Path.GetExtension(path); int filenumber = 1; do { name = nameOrig + "_" + filenumber + ext; filenumber++; } while (File.Exists(path)); try { File.Move(path, Path.GetDirectoryName(path) + "\\" + name + Path.GetExtension(path)); MessageBox.Show("File was renamed!"); } catch (IOException) { MessageBox.Show("Something went wrong\nAre you sure file " + path + " isn't being used?"); } } }
private string checkNameExists() { string showNameNoSpaces = showName.Replace(" ", "+"); string getName = DownloadFromApi.apiGet("https://api.thetvdb.com/search/series?name=" + showNameNoSpaces, token, 0); info = getName; if (info == "Error") { return("Error!"); } var w = new SelectShow(info); w.ShowDialog(); return(w.Return); }
private string checkNameExistsIMDb() { string getName = DownloadFromApi.apiGet("https://api.thetvdb.com/search/series?imdbId=" + showName, token, 0); string name; if (info == "error") { return("Error!"); } JObject parsed = JObject.Parse(getName); TVID = parsed["data"][0]["id"].ToString(); info = DownloadFromApi.apiGet("https://api.thetvdb.com/series" + TVID, token, 0); name = parsed["data"][0]["seriesName"].ToString(); return(name); }
private string getFromID() { TVID = checkNameExists(); if (TVID != "Error!") { info = DownloadFromApi.apiGet("https://api.thetvdb.com/series/" + TVID, token, 0); if (info == "Error") { return("Error!"); } JObject tvShowName = JObject.Parse(info); return(tvShowName["data"]["seriesName"].ToString()); } else { return("Error!"); } }
private void findShow_Click(object sender, RoutedEventArgs e) { string showNameNoSpaces = textBox_Copy.Text.Replace(" ", "+"); string getName = DownloadFromApi.apiGet("https://api.thetvdb.com/search/series?name=" + showNameNoSpaces, tkn, 0); info = getName; if (info == "Error") { MessageBox.Show("Re-check your data or make sure that you are connected to the internet."); } else { var w = new SelectShow(info); w.ShowDialog(); ID = w.Return; enableStart(); } }
private void Grid_Loaded(object sender, RoutedEventArgs e) { string info = DownloadFromApi.apiGet("https://api.thetvdb.com/search/series?name=The%20100", token, 1); if (info == null) { token = DownloadFromApi.getToken(); if (token == null) { MessageBox.Show("You are either not connected to the internet or API is not responding. TVS Renamer will now close"); this.Close(); } else { Properties.Settings.Default["Token"] = token; Properties.Settings.Default.Save(); } } }
private string getName(int season, int episode) { string name = null; string final = null; string info = DownloadFromApi.apiGet("https://api.thetvdb.com/series/" + TVID + "/episodes/query?airedSeason=" + season + "&airedEpisode=" + episode, token, 0); JObject parse = JObject.Parse(info); name = parse["data"][0]["episodeName"].ToString(); string invalid = new string(System.IO.Path.GetInvalidFileNameChars()) + new string(System.IO.Path.GetInvalidPathChars()); foreach (char znak in invalid) { name = name.Replace(znak.ToString(), ""); } if (season < 10) { new System.IO.FileInfo(location + "\\" + "Season 0" + season).Directory.Create(); if (episode < 10) { final = showName + " - S0" + season + "E0" + episode + " - " + name; } if (episode >= 10) { final = showName + " - S0" + season + "E" + episode + " - " + name; } } else if (season < 10) { new System.IO.FileInfo(location + "\\" + "Season 0" + season).Directory.Create(); if (episode < 10) { final = showName + " - S" + season + "E0" + episode + " - " + name; } if (episode >= 10) { final = showName + " - S" + season + "E" + episode + " - " + name;; } } return(final); }