Skip to content

Commit 91a4aac

Browse files
ChunkyProgrammerAlban Dumas
authored and
Alban Dumas
committed
Add support for hms timestamp in query string (FreeTubeApp#6012)
* Add support for hms timestamp in query string * undo change in index.js
1 parent e9761af commit 91a4aac

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/renderer/helpers/utils.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,26 @@ export function getVideoParamsFromUrl(url) {
611611

612612
function extractParams(videoId) {
613613
paramsObject.videoId = videoId
614-
paramsObject.timestamp = urlObject.searchParams.get('t')
614+
let timestamp = urlObject.searchParams.get('t')
615+
if (timestamp && (timestamp.includes('h') || timestamp.includes('m') || timestamp.includes('s'))) {
616+
const { seconds, minutes, hours } = timestamp.match(/(?:(?<hours>(\d+))h)?(?:(?<minutes>(\d+))m)?(?:(?<seconds>(\d+))s)?/).groups
617+
let time = 0
618+
619+
if (seconds) {
620+
time += Number(seconds)
621+
}
622+
623+
if (minutes) {
624+
time += 60 * Number(minutes)
625+
}
626+
627+
if (hours) {
628+
time += 3600 * Number(hours)
629+
}
630+
631+
timestamp = time
632+
}
633+
paramsObject.timestamp = timestamp
615634
}
616635

617636
const extractors = [

0 commit comments

Comments
 (0)