Skip to content

Commit

Permalink
Added error handling to searching
Browse files Browse the repository at this point in the history
  • Loading branch information
ShujianDou authored Aug 20, 2020
1 parent 28eed0f commit b5699bf
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions CS/Sites/VidStreaming/VidStreamingMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,13 @@ public static String Search(string name)
}
}
Expressions.vidStreamRegex = new Regex(Expressions.searchVideoRegex); // Don't say anything about parsing html with REGEX. This is a better than importing another library for this case.
return "https://vidstreaming.io" + Expressions.vidStreamRegex.Match(node.innerHTML).Groups[1].Value;
if (node == null)
return "E";
Match m = Expressions.vidStreamRegex.Match(node.innerHTML);
return m.Groups.Count >= 1 ? "https://vidstreaming.io" + m.Groups[1].Value : "E";
}

public static List<String> FindAllVideos(string link, Boolean dwnld, [Optional] String fileDestDirectory)
public static String FindAllVideos(string link, Boolean dwnld, [Optional] String fileDestDirectory)
{
Console.WriteLine($"Found link: {link}\nDownloading Page...");
string Data = Storage.wc.DownloadString(link);
Expand Down Expand Up @@ -118,7 +121,7 @@ public static List<String> FindAllVideos(string link, Boolean dwnld, [Optional]
}
case false:
{
System.IO.File.AppendAllText(fileDestDirectory, val);
System.IO.File.AppendAllText($"{fileDestDirectory}_VDLI_temp.txt", $"\n{val}");
continue;
}
default:
Expand All @@ -128,7 +131,7 @@ public static List<String> FindAllVideos(string link, Boolean dwnld, [Optional]
}
}
}
return videoUrls;
return dwnld ? null : $"{fileDestDirectory}_VDLI_temp.txt";
}
}

Expand Down

0 comments on commit b5699bf

Please sign in to comment.