Permalink
Browse files

Commit an experiment with download link

  • Loading branch information...
TomasHubelbauer committed Jan 12, 2018
1 parent 8ded071 commit 16cc520120119525b9f3044063717dd9108e96a7
Showing with 281 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +1 −0 .nvmrc
  3. +14 −0 package.json
  4. +30 −0 src/index.mjs
  5. +235 −0 yarn.lock
@@ -0,0 +1 @@
node_modules
1 .nvmrc
@@ -0,0 +1 @@
9.4.0
@@ -0,0 +1,14 @@
{
"name": "puppeteer-youtube-downloader",
"version": "1.0.0",
"main": "src/index.mjs",
"repository": "https://github.com/TomasHubelbauer/puppeteer-youtube-downloader.git",
"author": "Tomáš Hübelbauer <tomas@hubelbauer.net>",
"license": "MIT",
"scripts": {
"start": "node --experimental-modules src/index.mjs"
},
"dependencies": {
"puppeteer": "^1.0.0"
}
}
@@ -0,0 +1,30 @@
import puppeteer from 'puppeteer';
async function run() {
const browser = await puppeteer.launch({ headless: false, slowMo: 100 });
const page = (await browser.pages())[0];
// Experiment 0: Playing non-VP video formats.
// Won't work: https://www.chromium.org/audio-video
await page.goto('https://www.youtube.com/watch?v=P73REgj-3UE');
// Experiment 1: Creating a download link from the BLOB URL.
// Won't work: https://stackoverflow.com/a/36488042/2715716
await page.goto('https://www.youtube.com/watch?v=E8C8ouiXHHk');
await page.evaluate(() => {
const a = document.createElement('a');
a.href = document.querySelector('video').src;
a.download = document.title;
a.textContent = 'Download';
a.style.position = 'fixed';
a.style.left = 0;
a.style.top = 0;
a.style.zIndex = 100000;
document.body.appendChild(a);
});
// Experiment 2: Stitching together `videoplayback` responses.
// ?
}
run();
235 yarn.lock

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit 16cc520

Please sign in to comment.