Skip to content

Commit 1a2333b

Browse files
committed
Fix playback issues and video upload QOL changes
1 parent 67ed614 commit 1a2333b

File tree

4 files changed

+58
-36
lines changed

4 files changed

+58
-36
lines changed

src/main/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ ipcMain.handle('get-tournament-folders', async(event, arg) => {
6969
})
7070

7171
ipcMain.handle('upload-videos', async(event, args) => {
72-
const credentials = { email: args.email, pass: safeStorage.decryptString(Buffer.from(store.get('ytPassword') as Buffer))}
72+
const credentials = { email: args.email, recoveryemail: args.recoveryemail, pass: safeStorage.decryptString(Buffer.from(store.get('ytPassword') as Buffer))}
7373
const videoList: Video[] = []
7474
fs.readdirSync(args.path).forEach((videoName: any) => {
7575
if (path.extname(videoName).toLowerCase() === '.mp4') {
76-
const videoMetadata = { path: args.path + videoName, title: videoName.replace(/\.[^/.]+$/, ""), description: 'description 1' }
76+
const videoMetadata = { path: args.path + videoName, title: videoName.replace(/\.[^/.]+$/, ""), description: args.description, playlist: args.playlistName, isNotForKid: true }
7777
videoList.push(videoMetadata)
7878
console.log("videoMetadata", videoMetadata)
7979
}

src/renderer/components/VideoSearch.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ const RetrieveSets = (
1919
eventId: string,
2020
vodUrl: string,
2121
stationNumber: number,
22-
buttonDisabled: boolean
22+
buttonDisabled: boolean,
23+
setButtonDisabled: React.Dispatch<React.SetStateAction<boolean>>,
2324
): JSX.Element => {
2425
const navigate = useNavigate();
2526
const theme = useTheme();
@@ -42,6 +43,14 @@ const RetrieveSets = (
4243
options
4344
);
4445

46+
useEffect(() => {
47+
if (loading || waiting) {
48+
setButtonDisabled(true)
49+
} else if (error) {
50+
setButtonDisabled(false)
51+
}
52+
})
53+
4554
useEffect(() => {
4655
if (data) {
4756
window.electron.ipcRenderer
@@ -76,10 +85,10 @@ const RetrieveSets = (
7685
}
7786
let metadata: VODMetadata = {
7887
title:
79-
set.slots[0].entrant.name +
88+
set.slots[0].entrant.name.split('|').pop().trim() +
8089
characterStrings[0] +
8190
' vs ' +
82-
set.slots[1].entrant.name +
91+
set.slots[1].entrant.name.split('|').pop().trim() +
8392
characterStrings[1] +
8493
' - ' +
8594
set.fullRoundText +
@@ -96,6 +105,7 @@ const RetrieveSets = (
96105
return metadata;
97106
});
98107
setWaiting(false);
108+
console.log("All sets", formattedSets)
99109
navigate('/SetsView', {
100110
state: {
101111
sets: formattedSets,
@@ -218,7 +228,7 @@ const VideoSearch = () => {
218228
helperText="The station number the stream is assigned to."
219229
sx={{ marginBottom: '25px' }}
220230
/>
221-
{RetrieveSets(eventId, vodUrl, stationNumber, buttonDisabled)}
231+
{RetrieveSets(eventId, vodUrl, stationNumber, buttonDisabled, setButtonDisabled)}
222232
</Box>
223233
);
224234
};

src/renderer/pages/SetsView.tsx

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ const SetsView = () => {
7575
const [embedLink, setEmbedLink] = useState("")
7676
const [newTitle, setNewTitle] = useState(set.title)
7777
const [timeError, setTimeError] = useState(false)
78+
const [randomKey, setRandomKey] = useState(Math.random())
7879

7980
let partUrl = location.state.vodUrl.split('/')
8081
let twitchId = partUrl.pop() || partUrl.pop()
@@ -88,32 +89,26 @@ const SetsView = () => {
8889
})
8990

9091
useEffect(() => {
91-
setSkipTime(newStartTime)
92-
}, [newStartTime])
93-
94-
useEffect(() => {
95-
if (skipTime) {
96-
let split = skipTime.format('HH:mm:ss').split(':')
97-
if (split.length === 3) {
98-
let hours = split[0]
99-
let minutes = split[1]
100-
let seconds = split[2]
101-
let twitchFormat = ""
102-
if (hours !== "00") {
103-
twitchFormat = twitchFormat.concat(hours.replace(/^0+/, ''), "h")
104-
}
105-
if (minutes !== "00") {
106-
twitchFormat = twitchFormat.concat(minutes.replace(/^0+/, ''), "m")
107-
} else {
108-
twitchFormat = twitchFormat.concat("0m")
109-
}
110-
if (seconds !== "00") {
111-
twitchFormat = twitchFormat.concat(seconds.replace(/^0+/, ''), "s")
112-
} else {
113-
twitchFormat = twitchFormat.concat("0s")
114-
}
115-
setEmbedLink("https://player.twitch.tv/?video=" + twitchId + "&t=" + twitchFormat + "&parent=localhost&muted=true")
92+
let split = skipTime.format('HH:mm:ss').split(':')
93+
if (split.length === 3) {
94+
let hours = split[0]
95+
let minutes = split[1]
96+
let seconds = split[2]
97+
let twitchFormat = ""
98+
if (hours !== "00") {
99+
twitchFormat = twitchFormat.concat(hours.replace(/^0+/, ''), "h")
100+
}
101+
if (minutes !== "00") {
102+
twitchFormat = twitchFormat.concat(minutes.replace(/^0+/, ''), "m")
103+
} else {
104+
twitchFormat = twitchFormat.concat("0m")
105+
}
106+
if (seconds !== "00") {
107+
twitchFormat = twitchFormat.concat(seconds.replace(/^0+/, ''), "s")
108+
} else {
109+
twitchFormat = twitchFormat.concat("0s")
116110
}
111+
setEmbedLink("https://player.twitch.tv/?video=" + twitchId + "&t=" + twitchFormat + "&parent=localhost&muted=true")
117112
}
118113
})
119114

@@ -127,7 +122,7 @@ const SetsView = () => {
127122
// onClick={(event: any) => event.stopPropagation()}
128123
>
129124
<LocalizationProvider dateAdapter={AdapterMoment}>
130-
<Box sx={{ display: 'flex', flexDirection: 'column', justifyContent: 'space-around', height:'100vh', width: '70vw', padding: '20px' }}>
125+
<Box sx={{ display: 'flex', flexDirection: 'column', justifyContent: 'space-around', height:'100vh', minWidth: '50vw', padding: '20px' }}>
131126
<Typography variant="h6" component="h2" textAlign="center" gutterBottom>
132127
Edit Match
133128
</Typography>
@@ -137,18 +132,20 @@ const SetsView = () => {
137132
src={embedLink}
138133
height='100%'
139134
width='100%'
135+
key={randomKey}
140136
>
141137
</iframe>
142138
</Card>
143139
<TextField
144140
className="textfield"
145141
label="Title"
146142
defaultValue={newTitle}
147-
onBlur={(event) => {
143+
onChange={(event) => {
148144
event.stopPropagation()
149145
event.preventDefault()
150146
setNewTitle(event.target.value)
151147
}}
148+
helperText={newTitle.length + "/100 | YouTube title character limit"}
152149
/>
153150
<Box sx={{ width: '100%', display: 'flex', justifyContent: 'space-between' }}>
154151
<TimePicker
@@ -165,7 +162,7 @@ const SetsView = () => {
165162
className="timepicker"
166163
/>
167164
<Tooltip title="Skip to start">
168-
<IconButton onClick={() => setSkipTime(newStartTime)}>
165+
<IconButton onClick={() => newStartTime === skipTime ? setRandomKey(Math.random()) : setSkipTime(newStartTime)}>
169166
<SkipNextIcon />
170167
</IconButton>
171168
</Tooltip>
@@ -185,7 +182,7 @@ const SetsView = () => {
185182
className="timepicker"
186183
/>
187184
<Tooltip title="Skip to end">
188-
<IconButton onClick={() => setSkipTime(newEndTime)}>
185+
<IconButton onClick={() => newEndTime === skipTime ? setRandomKey(Math.random()) : setSkipTime(newEndTime)}>
189186
<SkipNextIcon />
190187
</IconButton>
191188
</Tooltip>

src/renderer/pages/YTUploadView.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,18 @@ const YTUploadView = () => {
2525
const [ytPassword, setYtPassword] = useState(
2626
window.electron.store.getSecret('ytPassword')
2727
);
28+
const [description, setDescription] = useState("")
2829
const [ytEmailError, setYtEmailError] = useState(false);
2930
const [ytRecoveryEmailError, setYtRecoveryEmailError] = useState(false);
3031
const [tounamentFolders, setTournamentFolders] = useState<string[]>([]);
3132
const [selectedFolder, setSelectedFolder] = useState('');
3233
const [buttonDisabled, setButtonDisabled] = useState(true);
3334
const [successOpen, setSuccessOpen] = useState(false);
3435
const [errorOpen, setErrorOpen] = useState(false);
36+
const [infoOpen, setInfoOpen] = useState(false);
3537
const [successMessage, setSuccessMessage] = useState('');
3638
const [errorMessage, setErrorMessage] = useState('');
39+
const [infoMessage, setInfoMessage] = useState('')
3740
const path = './downloadedVODs';
3841

3942
useEffect(() => {
@@ -80,10 +83,14 @@ const YTUploadView = () => {
8083
};
8184

8285
const uploadVideos = () => {
86+
setInfoMessage('Your videos are being uploaded! Check your YouTube account for progress updates.');
87+
setInfoOpen(true);
8388
const params = {
8489
path: './downloadedVODs/' + selectedFolder + '/',
8590
email: ytEmail,
8691
recoveryemail: ytRecoveryEmail,
92+
description: description,
93+
playlistName: selectedFolder,
8794
};
8895
window.electron.ipcRenderer
8996
.uploadVideos(params)
@@ -105,7 +112,8 @@ const YTUploadView = () => {
105112
</Typography>
106113
{SnackbarPopup(successMessage, 'success', successOpen, setSuccessOpen)}
107114
{SnackbarPopup(errorMessage, 'error', errorOpen, setErrorOpen)}
108-
<Box className="background-card">
115+
{SnackbarPopup(infoMessage, 'info', infoOpen, setInfoOpen)}
116+
<Box className="background-card" sx={{ height: '70vh' }}>
109117
<TextField
110118
required
111119
className="textfield"
@@ -152,6 +160,13 @@ const YTUploadView = () => {
152160
);
153161
})}
154162
</TextField>
163+
<TextField
164+
onChange={(event) => setDescription(event.target.value as string)}
165+
label="Video Description"
166+
variant="filled"
167+
rows={3}
168+
multiline
169+
/>
155170
<Button
156171
disabled={buttonDisabled}
157172
variant="contained"

0 commit comments

Comments
 (0)