Skip to content

Commit

Permalink
feat: Add setting to auto-open uploaded videos (#234)
Browse files Browse the repository at this point in the history
  • Loading branch information
Segergren authored Oct 8, 2024
1 parent 710208f commit ed0fd53
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Classes/Uploaders/RePlaysUploader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,13 @@ public override async Task<string> Upload(string id, string title, string file,
Logger.WriteLine(response.StatusCode.ToString() + " " + content);
var result = JsonSerializer.Deserialize<RePlaysResult>(content);
if (result.shortcode != null) {
Process browserProcess = new Process();
browserProcess.StartInfo.UseShellExecute = true;
browserProcess.StartInfo.FileName = "https://replays.app/Video/" + result.shortcode;
browserProcess.Start();
if (SettingsService.Settings.uploadSettings.openAfterUpload) {
Process browserProcess = new Process();
browserProcess.StartInfo.UseShellExecute = true;
browserProcess.StartInfo.FileName = "https://replays.app/Video/" + result.shortcode;
browserProcess.Start();
}

return "https://replays.app/Video/" + result.shortcode;
}

Expand Down
8 changes: 8 additions & 0 deletions Classes/Uploaders/StreamableUploader.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using RePlays.Services;
using RePlays.Utils;
using System;
using System.Diagnostics;
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
Expand Down Expand Up @@ -41,6 +42,13 @@ public override async Task<string> Upload(string id, string title, string file,
Logger.WriteLine(response.StatusCode.ToString() + " " + content);
var result = JsonSerializer.Deserialize<StreamableResult>(content);
if (result.shortcode != null) {
if (SettingsService.Settings.uploadSettings.openAfterUpload) {
Process browserProcess = new Process();
browserProcess.StartInfo.UseShellExecute = true;
browserProcess.StartInfo.FileName = "https://streamable.com/" + result.shortcode;
browserProcess.Start();
}

return "https://streamable.com/" + result.shortcode;
}
else {
Expand Down
2 changes: 2 additions & 0 deletions Classes/Utils/JSONObjects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ public class StorageSettings {
public class UploadSettings {
private List<string> _recentLinks = new();
public List<string> recentLinks { get { return _recentLinks; } set { _recentLinks = value; } }
private bool _openAfterUpload = true;
public bool openAfterUpload { get { return _openAfterUpload; } set { _openAfterUpload = value; } }

public class StreamableSettings {
private string _email = "";
Expand Down
1 change: 1 addition & 0 deletions ClientApp/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ declare global {
}
interface UploadSettings {
recentLinks: string[];
openAfterUpload: boolean;
streamableSettings: {
email: string;
password: string;
Expand Down
1 change: 1 addition & 0 deletions ClientApp/src/internationalization/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
"settingsUploadItem17": "Response Path",
"settingsUploadItem18": "The url to the video using",
"settingsUploadItem19": "Streamable.com",
"settingsUploadItem20": "Open In Browser After Upload",
"settingsStorageItem01": "Save Locations",
"settingsStorageItem02": "Game Recordings Directory",
"settingsStorageItem03": "Open Folder",
Expand Down
28 changes: 28 additions & 0 deletions ClientApp/src/pages/Settings/Upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,20 @@ const RePlays: React.FC<Props> = ({ settings, updateSettings }) => {
}}
/>
</div>
<label className='inline-flex items-center'>
<input
type='checkbox'
className='form-checkbox h-4 w-4 text-gray-600'
defaultChecked={settings === undefined ? false : settings.openAfterUpload}
onChange={(e) => {
settings!.openAfterUpload = e.target.checked;
updateSettings();
}}
/>
<span className='ml-2 inline-flex items-center text-gray-700 dark:text-gray-400'>
{t('settingsUploadItem20')}
</span>
</label>
<a
onClick={(e) => {
postMessage('OpenLink', 'https://replays.app');
Expand Down Expand Up @@ -155,6 +169,20 @@ const Streamable: React.FC<Props> = ({ settings, updateSettings }) => {
}}
/>
</div>
<label className='inline-flex items-center'>
<input
type='checkbox'
className='form-checkbox h-4 w-4 text-gray-600'
defaultChecked={settings === undefined ? false : settings.openAfterUpload}
onChange={(e) => {
settings!.openAfterUpload = e.target.checked;
updateSettings();
}}
/>
<span className='ml-2 inline-flex items-center text-gray-700 dark:text-gray-400'>
{t('settingsUploadItem20')}
</span>
</label>
<a
onClick={(e) => {
postMessage('OpenLink', 'https://streamable.com/');
Expand Down

0 comments on commit ed0fd53

Please sign in to comment.