Skip to content

Commit

Permalink
Removed depracted net code
Browse files Browse the repository at this point in the history
  • Loading branch information
cairthenn committed Jul 13, 2019
1 parent 8b15ebb commit 4536d24
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
4 changes: 2 additions & 2 deletions TwitchChatVideo/Colors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ public static Color GetCorrected(Color color, Color background, string name)
var darkMode = IsDark(background);

var hsl = HSL.FromRGB(color.R, color.G, color.B);

if(darkMode)
// Color correction concept from: https://github.com/fourtf/chatterino
if (darkMode)
{
hsl.L = Math.Max(hsl.L, .5);
if(hsl.L < .6 && hsl.H > 196 && hsl.H < 300)
Expand Down
29 changes: 22 additions & 7 deletions TwitchChatVideo/TwitchDownloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,30 @@ class TwitchDownloader

public static Image GetImage(string local_path, string url)
{
if (!File.Exists(local_path))
var image = DownloadImageFromURL(url);

image?.Save(local_path);

return image;
}

public static Image DownloadImageFromURL(string url)
{

try
{
using (var client = new WebClient())
{
client.DownloadFile(url, local_path);
}
var request = WebRequest.Create(url);
request.Timeout = 10000;
var response = request.GetResponse();
var stream = response.GetResponseStream();
var image = Image.FromStream(stream);
response.Close();
return image;
}
catch (WebException ex)
{
return null;
}

return Image.FromFile(local_path);
}

public static async Task<VodInfo> DownloadVideoInfoAsync(string id, IProgress<VideoProgress> progress = null, CancellationToken ct = default(CancellationToken))
Expand Down

0 comments on commit 4536d24

Please sign in to comment.