Skip to content

Commit

Permalink
fix extraction of videoId in page processing
Browse files Browse the repository at this point in the history
  • Loading branch information
blackforestboi committed Aug 8, 2024
1 parent c1901c6 commit db2421f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion external/@worldbrain/memex-common
6 changes: 4 additions & 2 deletions src/page-analysis/background/analyse-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type TabManagementBackground from 'src/tab-management/background'
import { runInTab } from 'src/util/webextensionRPC'
import { CLOUDFLARE_WORKER_URLS } from '@worldbrain/memex-common/lib/content-sharing/storage/constants'
import { fetchYoutubeTranscript } from 'src/util/fetch-youtube-transcript'
import { extractIdFromUrl } from '@worldbrain/memex-common/lib/utils/youtube-url'

export interface PageAnalysis extends Partial<ExtractedPDFData> {
content: PageContent
Expand Down Expand Up @@ -38,8 +39,9 @@ const analysePage: PageAnalyzer = async (options) => {
return
}

const ytVideoUrlPattern = /^.*(?:(?:youtu.be\/)|(?:v\/)|(?:\/u\/\w\/)|(?:embed\/)|(?:watch\?))\??(?:v=)?([^#&?]*).*/
const [, videoId] = options.url.match(ytVideoUrlPattern) ?? []
const videoId = extractIdFromUrl(options.url)

console.log('videoId', videoId)

const rawContent = await options.tabManagement.extractRawPageContent(
options.tabId,
Expand Down

0 comments on commit db2421f

Please sign in to comment.