forked from Schroedinger-Hat/youtube-to-spotify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupload-episode.js
47 lines (32 loc) · 1.49 KB
/
upload-episode.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const puppeteer = require('puppeteer');
const fs = require('fs');
const email = process.env.ANCHOR_EMAIL;
const password = process.env.ANCHOR_PASSWORD;
const episode = JSON.parse(fs.readFileSync('episode.json', 'utf-8'));
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
const navigationPromise = page.waitForNavigation();
await page.goto('https://anchor.fm/dashboard/episode/new');
await page.setViewport({ width: 1600, height: 789 });
await navigationPromise;
await page.type('#email', email);
await page.type('#password', password);
await page.click('button[type=submit]');
await navigationPromise;
await page.waitForSelector('input[type=file]');
const inputFile = await page.$('input[type=file]');
await inputFile.uploadFile('episode.webm');
await page.waitFor(25*1000);
await page.waitForFunction('document.querySelector(".styles__saveButton___lWrNZ").getAttribute("disabled") === null', {timeout: 60*5*1000});
await page.click('.styles__saveButton___lWrNZ');
await navigationPromise;
await page.waitForSelector('#title');
await page.type('#title', episode.title);
await page.click('.styles__modeToggleText___26-xx');
await page.waitForSelector('textarea[name=description]');
await page.type('textarea[name=description]', episode.description);
await page.click('.styles__saveButtonWrapper___TrQYl button');
await navigationPromise;
await browser.close()
})()