Skip to content

Commit

Permalink
changes for 3.28.2
Browse files Browse the repository at this point in the history
Remove user details calls to gfycat since service will be shutdown
  • Loading branch information
argorar committed Jul 30, 2023
1 parent 3d540a6 commit a001e07
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 123 deletions.
6 changes: 3 additions & 3 deletions Dialogs/ConverterDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -522,10 +522,10 @@ private async void buttonUpload_ClickAsync(object sender, EventArgs e)
{
try
{
if (String.IsNullOrEmpty(Program.token))
((MainForm)Owner).BrowserAuthentication();
//if (String.IsNullOrEmpty(Program.token))
// ((MainForm)Owner).BrowserAuthentication();

((MainForm)Owner).GetToken(string.Empty, Token.Refresh);
//((MainForm)Owner).GetToken(string.Empty, Token.Refresh);
boxOutput.AppendText($"{Environment.NewLine}{Environment.NewLine} --- UPLOAD FILE TO GFYCAT---");
boxOutput.AppendText($"{Environment.NewLine}Creating request for gfycat name");

Expand Down
119 changes: 1 addition & 118 deletions MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,7 @@ public MainForm()
InitializeComponent();
this.KeyPreview = true;
taskbarManager = TaskbarManager.Instance;

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

groupGfycat.Visible = false;
CheckAppSettings();
CheckProccess();
LoadConfiguration();
Expand Down Expand Up @@ -2664,118 +2659,6 @@ private string GetTemporaryLogFile()

#endregion

public void BrowserAuthentication()
{
HttpListener http = new HttpListener();
try
{
// Creates an HttpListener to listen for requests on that redirect URI.
http.Prefixes.Add(prefixe);
http.Start();

// Creates the OAuth 2.0 authorization request.
string authorizationRequest = $"https://gfycat.com/oauth/authorize?client_id={client_id}&scope=all&state=all&response_type=code&redirect_uri={prefixe}";

// Opens request in the browser.
Process.Start(authorizationRequest);
string code = string.Empty;
bool demon = true;
while (demon)
{
string responseString;
// Waits for the OAuth authorization response.
var context = http.GetContext();
HttpListenerResponse response = context.Response;
if (context.Request.QueryString.Get("error") != null)
{
MessageBox.Show(String.Format("OAuth authorization error: {0}.", context.Request.QueryString.Get("error")), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}

if (context.Request.Url.Query.Contains("code"))
{
demon = false;
code = context.Request.Url.Query.Substring(6).Split('&')[0];
responseString = "<HTML><body><script>location.replace(\"https://thumbs.gfycat.com/WanDescriptiveCrossbill-small.gif\");</script></body></HTML>";
}
else
{
responseString = "<HTML><body> Working...... <script>setTimeout(function(){ location.replace(\"http://127.0.0.1:57585/\"+window.location.href.split('/')[3].split('#')[1].split('&')[0]); }, 100); </script></body></HTML>";
}

byte[] buffer = Encoding.UTF8.GetBytes(responseString);
response.ContentLength64 = buffer.Length;
Stream output = response.OutputStream;
output.Write(buffer, 0, buffer.Length);
output.Close();
}

if (!String.IsNullOrEmpty(code))
GetToken(code, Token.New);
}
catch (WebException ex)
{
if (ex.Status == WebExceptionStatus.ProtocolError)
{
var response = ex.Response as HttpWebResponse;
if (response != null)
{
MessageBox.Show("HTTP: " + response.StatusCode);
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
{
string responseText = reader.ReadToEnd();
MessageBox.Show(responseText);
}
}

}
}
catch (Exception ex)
{
this.Activate();
MessageBox.Show(ex.Message);
}
finally
{
http.Stop();
this.Activate();
}
}

public void GetToken(string code, Token action)
{
try
{
string postData;

if (action == Token.New)
postData = String.Format("\"code\":\"{0}\", \"client_id\":\"{1}\", \"client_secret\": \"{2}\", \"grant_type\": \"authorization_code\",\"redirect_uri\":\"{3}\"", code, client_id, client_secret, prefixe);
else
postData = String.Format("\"grant_type\":\"refresh\", \"client_id\":\"{0}\", \"client_secret\": \"{1}\", \"refresh_token\":\"{2}\"", client_id, client_secret, configuration.AppSettings.Settings["RefreshToken"].Value);

postData = "{" + postData + "}";

TokenResponse tokenResponse = JsonConvert.DeserializeObject<TokenResponse>(
PostWebRequest($"https://api.gfycat.com/v1/oauth/token", postData));
Program.token = tokenResponse.access_token;
UpdateConfiguration("RefreshToken", tokenResponse.refresh_token);
_ = Task.Run(() => GetUserDetails());
}
catch (WebException ex)
{
if (ex.Status == WebExceptionStatus.ProtocolError && ex.Response is HttpWebResponse response)
{
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
MessageBox.Show(reader.ReadToEnd());
}
}
catch (Exception ex)
{
this.Activate();
MessageBox.Show(ex.Message);
}
}

private void GetUserDetails()
{
UserDetailsResponse userDetail = JsonConvert.DeserializeObject<UserDetailsResponse>(
Expand Down
Binary file added NewUpdate/3.28.2.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion NewUpdate/latest
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.28.1
3.28.2
2 changes: 1 addition & 1 deletion Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.28.1")]
[assembly: AssemblyVersion("3.28.2")]
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ Drag and drop two or more video files inside the application, select what do you
* 3nly

## Changelog
#### Version 3.28.2
* Remove user details calls to gfycat since service will be shutdown

#### Version 3.28.1
* Add support to external webvtt subtitles

Expand Down

0 comments on commit a001e07

Please sign in to comment.