Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lay295 committed Apr 24, 2020
1 parent ddb6473 commit b47d88b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
18 changes: 17 additions & 1 deletion TwitchDownloaderWPF/PageChatDownload.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
Expand Down Expand Up @@ -312,7 +313,7 @@ private void btnDownload_Click(object sender, RoutedEventArgs e)
}
else
{
TimeSpan vodLength = TimeSpan.Parse(Regex.Replace(videoData["data"][0]["duration"].ToString(), @"[^\d]", ":").TrimEnd(':'));
TimeSpan vodLength = GenerateTimespan(((JValue)videoData["data"][0]["duration"]).ToString(CultureInfo.InvariantCulture));
duration = (int)Math.Ceiling(vodLength.TotalSeconds);
}
info = new ChatDownloadInfo(downloadType, textUrl.Text, saveFileDialog.FileName, videoData["data"][0]["id"].ToString(), startTime, duration, (bool)radioJson.IsChecked, textStreamer.Text, streamerId);
Expand Down Expand Up @@ -340,6 +341,21 @@ private void btnDownload_Click(object sender, RoutedEventArgs e)
}
}

private TimeSpan GenerateTimespan(string input)
{
//There might be a better way to do this, gets string 0h0m0s and returns timespan
TimeSpan returnSpan = new TimeSpan(0);
string[] inputArray = input.Remove(input.Length - 1).Replace('h', ':').Replace('m', ':').Split(':');

returnSpan = returnSpan.Add(TimeSpan.FromSeconds(Int32.Parse(inputArray[inputArray.Length - 1])));
if (inputArray.Length > 1)
returnSpan = returnSpan.Add(TimeSpan.FromMinutes(Int32.Parse(inputArray[inputArray.Length - 2])));
if (inputArray.Length > 2)
returnSpan = returnSpan.Add(TimeSpan.FromHours(Int32.Parse(inputArray[inputArray.Length - 3])));

return returnSpan;
}

public void SetImage(string imageUri, bool isGif)
{
var image = new BitmapImage();
Expand Down
4 changes: 2 additions & 2 deletions TwitchDownloaderWPF/PageChatRender.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1356,14 +1356,14 @@ private bool ValidateInputs()

if (colorBackground.SelectedColor.Value.A < 255)
{
if ((((VideoContainer)comboFormat.SelectedItem).Name == "MOV" && ((Codec)comboCodec.SelectedItem).Name == "RLE") || ((VideoContainer)comboFormat.SelectedItem).Name == "WEBM")
if ((((VideoContainer)comboFormat.SelectedItem).Name == "MOV" && ( ((Codec)comboCodec.SelectedItem).Name == "RLE") || ((Codec)comboCodec.SelectedItem).Name == "ProRes") || ((VideoContainer)comboFormat.SelectedItem).Name == "WEBM")
{
return true;
}
else
{
AppendLog("ERROR: You've selected an alpha channel (transparency) for a container/codec that does not support it.");
AppendLog("Remove transparency or encode with MOV and RLE (file size will be large)");
AppendLog("Remove transparency or encode with MOV and RLE/PRORES (file size will be large)");
return false;
}
}
Expand Down
6 changes: 3 additions & 3 deletions TwitchDownloaderWPF/PageVodDownload.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ private async void btnGetInfo_Click(object sender, RoutedEventArgs e)
numEndHour.Value = vodLength.Hours;
numEndMinute.Value = vodLength.Minutes;
numEndSecond.Value = vodLength.Seconds;
labelLength.Text = String.Format("{0:00}:{1:00}:{2:00}", vodLength.TotalHours, vodLength.Minutes, vodLength.Seconds);
labelLength.Text = String.Format("{0:00}:{1:00}:{2:00}", vodLength.Hours, vodLength.Minutes, vodLength.Seconds);

SetEnabled(true);
}
Expand Down Expand Up @@ -502,7 +502,7 @@ private int ValidateUrl(string text)

private bool ValidateInput()
{
TimeSpan videoLength = TimeSpan.Parse(labelLength.Text);
TimeSpan videoLength = TimeSpan.Parse(labelLength.Text.ToString(CultureInfo.InvariantCulture));
TimeSpan beginTime = new TimeSpan((int)numStartHour.Value, (int)numStartMinute.Value, (int)numStartSecond.Value);
TimeSpan endTime = new TimeSpan((int)numEndHour.Value, (int)numEndMinute.Value, (int)numEndSecond.Value);

Expand Down Expand Up @@ -601,7 +601,7 @@ public void UpdateValues(PageVodDownload currentPage)
title = currentPage.textTitle.Text;
quality = (string)currentPage.comboQuality.SelectedItem;
streamer = currentPage.textStreamer.Text;
length = TimeSpan.Parse(currentPage.labelLength.Text);
length = TimeSpan.Parse(currentPage.labelLength.Text.ToString(CultureInfo.InvariantCulture));
cropped_begin = (bool)currentPage.checkStart.IsChecked;
cropped_end = (bool)currentPage.checkEnd.IsChecked;
cropped_begin_time = new TimeSpan((int)currentPage.numStartHour.Value, (int)currentPage.numStartMinute.Value, (int)currentPage.numStartSecond.Value);
Expand Down

0 comments on commit b47d88b

Please sign in to comment.