Initial commit

This commit is contained in:
Tibo De Peuter 2024-12-28 21:44:45 +01:00
commit 36cd2213f7
Signed by: tdpeuter
GPG key ID: 38297DE43F75FFE2
5 changed files with 481 additions and 0 deletions

37
src/lucida.ts Normal file
View file

@ -0,0 +1,37 @@
import { firefox, Page, BrowserContext } from 'playwright';
async function lucida(album: URL, context: BrowserContext): Promise<void> {
const page: Page = await context.newPage();
await page.goto('/');
// Fill in the album URL
await page.fill('input[id="download"]', album.href);
// Wait for the XHR request to complete
await Promise.all([
page.waitForResponse(res => res.url().includes('/api/load') && res.status() == 200),
page.click('input[id="go"]'),
page.waitForLoadState('domcontentloaded')
]);
// Check 'Hide my download from recently downloaded' checkbox
await page.check('input[id="hide-from-ticker"]');
await page.close();
}
(async () => {
// Launch a new Firefox browser instance
const browser = await firefox.launch({ headless: false }); // Set headless: true to run without UI
const context = await browser.newContext({
acceptDownloads: true, // Enable download handling
baseURL: 'https://lucida.to'
});
const album = new URL('https://www.qobuz.com/us-en/album/liquid-spirit-gregory-porter/0060253743200');
await lucida(album, context);
// Close the browser
await browser.close();
})();