Skip to content

Commit

Permalink
changes for 3.7.0
Browse files Browse the repository at this point in the history
* Display original FPS in interpolate box
* If value in interpolate box is 0, it will be removed
* Gfycat stats, see them in tab General
* Add option to log out of Gfycat
* Add feedback to merge files to avoid errors
  • Loading branch information
argorar committed Nov 8, 2020
1 parent 72670cc commit 0f6a1e0
Show file tree
Hide file tree
Showing 9 changed files with 238 additions and 230 deletions.
172 changes: 135 additions & 37 deletions MainForm.Designer.cs

Large diffs are not rendered by default.

79 changes: 73 additions & 6 deletions MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ public MainForm()

if (!String.IsNullOrEmpty(configuration.AppSettings.Settings["RefreshToken"].Value))
GetToken(string.Empty, Token.Refresh);
else
groupGfycat.Visible = false;

if (!configuration.AppSettings.Settings.AllKeys.Contains("VP9"))
configuration.AppSettings.Settings.Add("VP9", "false");
Expand All @@ -152,6 +154,11 @@ private void LoadConfiguration()
else
boxAudio.Checked = false;

if (configuration.AppSettings.Settings["VP9"].Value.Equals("true"))
boxNGOV.Checked = true;
else
boxNGOV.Checked = false;

if (!String.IsNullOrEmpty(configuration.AppSettings.Settings["PathDownload"].Value))
textPathDownloaded.Text = configuration.AppSettings.Settings["PathDownload"].Value;

Expand Down Expand Up @@ -261,6 +268,9 @@ private bool MergeVideoFile(string[] files)
Array.Sort(files);
foreach (string fileName in files)
{
if (!CheckFileName(fileName))
return true;

content += $"file '{fileName}'\n";
tempExtension = Path.GetExtension(fileName);
if (!extensions.ContainsKey(tempExtension))
Expand All @@ -285,6 +295,16 @@ private bool MergeVideoFile(string[] files)
return true;
}

private bool CheckFileName(string fileName)
{
if (fileName.Contains("'"))
{
MessageBox.Show($"Check the videos, the filename can't contain -> ' ","Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return false;
}
return true;
}

void MainForm_Shown(object sender, EventArgs e)
{
clearToolTip();
Expand Down Expand Up @@ -1286,7 +1306,6 @@ private void DefaultSettings()

boxDeinterlace.Checked =
boxDenoise.Checked =
boxNGOV.Checked =
false;

numericCrf.Value = 30;
Expand Down Expand Up @@ -1700,6 +1719,7 @@ void SetFile(string path)
Program.VideoInterlaced = frame.InterlacedFrame;
SetCRF(frame.EncodedResolution);
SetSlices(frame.EncodedResolution);
SetFPS();
LoadFonts(msg => logIndexingProgress((string)msg));
});
indexbw.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e)
Expand Down Expand Up @@ -1817,6 +1837,15 @@ void SetFile(string path)
indexbw.RunWorkerAsync();
}

private void SetFPS()
{
double originalFPS = Program.VideoSource.NumberOfFrames / Program.VideoSource.LastTime;
this.InvokeIfRequired(() =>
{
SendMessage(boxFrameRate.Handle, EM_SETCUEBANNER, 0, $"Original FPS {Math.Round(originalFPS, 1)}");
});
}

private void SetCRF(Size resolution)
{
if (resolution.Width > 2000)
Expand Down Expand Up @@ -2419,11 +2448,6 @@ private string GetTemporaryLogFile()

#endregion

private async void button1_ClickAsync(object sender, EventArgs e)
{
BrowserAuthentication();
}

public void BrowserAuthentication()
{
HttpListener http = new HttpListener();
Expand Down Expand Up @@ -2533,6 +2557,7 @@ public void GetToken(string code, Token action)
TokenResponse tokenResponse = JsonConvert.DeserializeObject<TokenResponse>(textJson);
Program.token = tokenResponse.access_token;
UpdateConfiguration("RefreshToken", tokenResponse.refresh_token);
_ = Task.Run(() => GetUserDetails());
}
catch (WebException ex)
{
Expand All @@ -2559,6 +2584,35 @@ public void GetToken(string code, Token action)
}
}

private void GetUserDetails()
{
try
{
WebRequest httpWRequest = WebRequest.Create("https://api.gfycat.com/v1/me");
httpWRequest.ContentType = "application/json";
httpWRequest.Method = "GET";
httpWRequest.Headers.Add("Authorization", "Bearer " + Program.token);
HttpWebResponse httpWResponse = (HttpWebResponse)httpWRequest.GetResponse();
Stream strm = httpWResponse.GetResponseStream();
StreamReader sr = new StreamReader(strm);
string textJson = sr.ReadToEnd();
UserDetailsResponse userDetail = JsonConvert.DeserializeObject<UserDetailsResponse>(textJson);
SetUserDetails(userDetail);
}
catch {}
}

private void SetUserDetails(UserDetailsResponse userDetail)
{
groupGfycat.Visible = true;
lblUser.Text = string.Format(lblUser.Text, userDetail.name);
lblPublicGfys.Text = string.Format(lblPublicGfys.Text, userDetail.publishedGfycats);
lblTotalGfys.Text = string.Format(lblTotalGfys.Text, userDetail.totalGfycats);
lblViews.Text = string.Format(lblViews.Text, string.Format("{0:#,0}", userDetail.views));
lblFollowers.Text = string.Format(lblFollowers.Text, userDetail.followers);
pictureBox.LoadAsync(userDetail.profileImageUrl);
}

private void UpdateConfiguration(string key, string value)
{
configuration.AppSettings.Settings[key].Value = value;
Expand Down Expand Up @@ -2608,6 +2662,19 @@ private void comboLevels_SelectedIndexChanged_1(object sender, EventArgs e)
{
UpdateArguments(sender, e);
}

private void boxFrameRate_Leave(object sender, EventArgs e)
{
if (boxFrameRate.Text.Equals("0"))
boxFrameRate.Text = string.Empty;
}

private void buttonLogOut_Click(object sender, EventArgs e)
{
UpdateConfiguration("RefreshToken", string.Empty);
Program.token = string.Empty;
groupGfycat.Visible = false;
}
}

public enum EncodingMode
Expand Down
Loading

0 comments on commit 0f6a1e0

Please sign in to comment.