Skip to content
Open
Changes from all commits
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
13 changes: 12 additions & 1 deletion src/renderer/helpers/api/local.js
Original file line number Diff line number Diff line change
Expand Up @@ -1537,6 +1537,8 @@ const VIEWS_OR_WATCHING_REGEX = /views?|watching|waiting/i
const WAITING_REGEX = /waiting/i
const VIEWS_IN_NUMBER_ONLY = /^\d+(\.\d)?[km]?$/i
const PREMIERES_TIME_REGEX = /^(premieres|scheduled for) /i
// Sometimes got `Streamed N (unit) ago`
const PUBLISH_TIME_REGEX = /^(streamed )?\d+ \w+? ago/i

/**
* @param {string | undefined} text
Expand Down Expand Up @@ -1565,6 +1567,15 @@ function isPremieresTimeText(text) {
return PREMIERES_TIME_REGEX.test(text)
}

/**
* @param {string | undefined} text
*/
function isPublishTimeText(text) {
if (typeof text !== 'string') { return false }

return PUBLISH_TIME_REGEX.test(text)
}

/**
* @param {import('youtubei.js').YTNodes.LockupView} lockupView
* @param {string | undefined} channelId
Expand Down Expand Up @@ -1644,7 +1655,7 @@ function parseLockupView(lockupView, channelId = undefined, channelName = undefi

if (lockupView.metadata.metadata?.metadata_rows != null) {
for (const row of lockupView.metadata.metadata.metadata_rows) {
const foundText = row.metadata_parts?.find(part => part.text?.text?.endsWith('ago'))?.text?.text
const foundText = row.metadata_parts?.find(part => isPublishTimeText(part.text?.text))?.text?.text
if (foundText != null) {
publishedText = foundText
break
Expand Down