Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,28 @@ function runApp() {
}

if (params.has('timestamp')) {
newParams.set('t', params.get('timestamp'))
let timestamp = params.get('timestamp')
if (timestamp && (timestamp.includes('h') || timestamp.includes('m') || timestamp.includes('s'))) {
if (timestamp && (timestamp.includes('h') || timestamp.includes('m') || timestamp.includes('s'))) {
const { seconds, minutes, hours } = timestamp.match(/(?:(?<hours>(\d+))h)?(?:(?<minutes>(\d+))m)?(?:(?<seconds>(\d+))s)?/).groups
let time = 0

if (seconds) {
time += Number(seconds)
}

if (minutes) {
time += 60 * Number(minutes)
}

if (hours) {
time += 3600 * Number(hours)
}

timestamp = time
}
}
newParams.set('t', timestamp)
hasParams = true
}

Expand Down
21 changes: 20 additions & 1 deletion src/renderer/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,26 @@ export function getVideoParamsFromUrl(url) {

function extractParams(videoId) {
paramsObject.videoId = videoId
paramsObject.timestamp = urlObject.searchParams.get('t')
let timestamp = urlObject.searchParams.get('t')
if (timestamp && (timestamp.includes('h') || timestamp.includes('m') || timestamp.includes('s'))) {
const { seconds, minutes, hours } = timestamp.match(/(?:(?<hours>(\d+))h)?(?:(?<minutes>(\d+))m)?(?:(?<seconds>(\d+))s)?/).groups
let time = 0

if (seconds) {
time += Number(seconds)
}

if (minutes) {
time += 60 * Number(minutes)
}

if (hours) {
time += 3600 * Number(hours)
}

timestamp = time
}
paramsObject.timestamp = timestamp
}

const extractors = [
Expand Down