Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

174
Views
Obtener la altura y el ancho del video a través de Node.js

Estoy buscando una manera de obtener el ancho y la altura del video mediante Node.js (todo lo que tengo es la URL del video).

Para el caso, también estoy usando Puppeteer para obtener URL de video de la web, por lo que cualquier manipulación necesaria que requiera DOM es prácticamente factible opcionalmente: en el proceso de rastreo de datos tengo acceso al elemento.

¿Alguna sugerencia para ese problema?

CÓDIGO:

 export async function _getSourcesLinks(targetUrl: string): Promise < string[] > { return await puppeteer.launch({ args: ['--no-sandbox', '--disable-setuid-sandbox'], headless: true, }).then(async browser => { try { const page = await browser.newPage() page.setJavaScriptEnabled(true) await page.goto(targetUrl, { waitUntil: 'load' }) try { // waiting for video to appear await page.waitForTimeout(1500) // await page.waitForSelector('video', { timeout: 2500 }) // die after 2.5 seconds } catch (error) { console.error(error) } const srcs = await page.$$eval < Element > ('video, .video, [src]', (videos) => { // TODO get also width and height return videos.map(video => { // @ts-ignore return video.getAttribute('src') }) }) as never as string[] const downloadTargets = srcs.filter(src => { console.log(src) if (!src) return false const fitPattern = new RegExp('.*\.mp4.*') return fitPattern.test(src) }) browser.close() return downloadTargets } catch (error) { console.error(error) } }) }

En cuanto al video de prueba, no tengo uno, solo sucedió de vez en cuando

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!