Skip to content

Commit

Permalink
adjusted search
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirdock committed Jul 4, 2019
1 parent 31688f2 commit a1d1d57
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Rename.9/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.4.*")]
[assembly: AssemblyFileVersion("1.4.18")]
[assembly: AssemblyFileVersion("1.4.19")]
[assembly: NeutralResourcesLanguageAttribute("")]
2 changes: 1 addition & 1 deletion Rename.9/View/Data_Insert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private void Data_InsertCons()
private void setRichTextData(IEnumerable<string> data)
{

richTextBox1.Text = string.Join("\n", data);
richTextBox1.Text = string.Join("\n", data ?? Enumerable.Empty<string>());

richTextBox1.SelectAll();
richTextBox1.SelectionFont = richTextBox1.Font;
Expand Down
38 changes: 19 additions & 19 deletions Rename.9/View/SearchWebsite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private void btnOk_Click(object sender, EventArgs e)
{
result = getEpisodeList(url, language);
}
else if (selectedIndex == 3 && (valid = checkUrlTVDB()))
else if (selectedIndex == 3 && (valid = checkUrlTVDB(url, out url)))
{

result = GetEpisodeListTVDB(urlTVDB, language);
Expand All @@ -144,11 +144,11 @@ private void btnOk_Click(object sender, EventArgs e)
{
result = getEpisodeListAniDB(url);
}
else if (valid = checkUrlFernsehserien())
else if (valid = checkUrlFernsehserien(url, out url))
{
result = getEpisodeListFernsehserien(url, season);
}

setUrl(url);
episodeList = result;

}
Expand All @@ -171,22 +171,22 @@ private void btnOk_Click(object sender, EventArgs e)
}).Start();
}

private bool checkUrlFernsehserien()
private bool checkUrlFernsehserien(string inputUrl, out string url)
{
bool valid;
string url = txtUrl.Text;
url = string.Empty;
string startText = "https://www.fernsehserien.de/";
if (valid = url.StartsWith(startText))
if (valid = inputUrl.StartsWith(startText))
{
url = url.Replace(startText, string.Empty);
string searchText = url.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries)[0];
inputUrl = inputUrl.Replace(startText, string.Empty);
string searchText = inputUrl.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries)[0];
string changedUrl = startText + searchText + "/episodenguide";
HtmlWeb htmlWeb = new HtmlWeb();
HtmlAgilityPack.HtmlDocument doc = htmlWeb.Load(changedUrl);

if (valid = doc.DocumentNode.SelectSingleNode("//nav[@id='serienmenu']") != null)
{
txtUrl.Text = changedUrl;
url = changedUrl;
}
}
return valid;
Expand Down Expand Up @@ -746,11 +746,11 @@ private void btnCheckURL_Click(object sender, EventArgs e)

new Thread(() =>
{
if (selectedIndex == 3 && (valid = checkUrlTVDB())) {
if (selectedIndex == 3 && (valid = checkUrlTVDB(url, out url))) {

getSeasons(url);
}
else if(selectedIndex == 2 && (valid = checkUrlFernsehserien()))
else if(selectedIndex == 2 && (valid = checkUrlFernsehserien(url, out url)))
{
getSeasonsFernsehserien(url);
}
Expand All @@ -760,17 +760,18 @@ private void btnCheckURL_Click(object sender, EventArgs e)
{
ErrorMessage(new UriFormatException());
}
setUrl(url);
}).Start();
}

private bool checkUrlTVDB()
private bool checkUrlTVDB(string inputUrl, out string url)
{
bool valid = false;
string url = txtUrl.Text;
url = string.Empty;
string startText = "https://www.thetvdb.com/series/";
if (url.StartsWith(startText))
if (inputUrl.StartsWith(startText))
{
string search = url.Replace(startText, string.Empty);
string search = inputUrl.Replace(startText, string.Empty);

if(search.IndexOf("/") != -1)
{
Expand All @@ -787,11 +788,10 @@ private bool checkUrlTVDB()
lastStatusCode = response.StatusCode;
}
};
htmlWeb.Load(url);
if(lastStatusCode == HttpStatusCode.OK)
htmlWeb.Load(inputUrl);
if(valid = (lastStatusCode == HttpStatusCode.OK))
{
valid = true;
txtUrl.Text = $"{startText}{search}";
url = $"{startText}{search}";
}
}
return valid;
Expand Down

0 comments on commit a1d1d57

Please sign in to comment.