Skip to content

Instantly share code, notes, and snippets.

@abe-101
Created February 6, 2023 15:45
Show Gist options
  • Save abe-101/7a4286ea43bc0bbef22a2cc6bed7c18a to your computer and use it in GitHub Desktop.
Save abe-101/7a4286ea43bc0bbef22a2cc6bed7c18a to your computer and use it in GitHub Desktop.
from playwright.sync_api import Playwright, sync_playwright, expect
from ffmpeg import FFmpeg
# Function to run the audio enhancement process using Adobe Podcast
def run(playwright: Playwright, FILE) -> None:
# Launch the chromium browser
browser = playwright.chromium.launch()
# Create a new context with saved authentication information
# For first-time users, sign in manually and save the session and cookies using the command:
# playwright codegen --save-storage=auth.json https://podcast.adobe.com/enhance#
# More details: https://playwright.dev/python/docs/cli#preserve-authenticated-state
context = browser.new_context(storage_state="auth.json")
page = context.new_page()
# Go to the Adobe Podcast enhance page
page.goto("https://podcast.adobe.com/enhance#")
# Upload the audio file
page.get_by_label("Upload").set_input_files(FILE)
# Wait for the "Download" button to become available
page.get_by_role("button", name="Download").wait_for(timeout=600000)
print("Downloading the enhanced file")
# Triggers the download of the enhanced file and gets its info
with page.expect_download() as download_info:
# Perform the action that initiates download
page.get_by_role("button", name="Download").click()
download = download_info.value
# Waits for the download process to complete
print(download.path())
# Converts the enhanced audio from WAV to MP3 using FFmpeg
print("doint the ffmpeg thing")
ffmpeg = FFmpeg().input(download.path()).output(FILE[:-4] + " (enhanced).mp3", acodec="mp3")
ffmpeg.execute()
# ---------------------
# Closes the context and browser instance
context.close()
browser.close()
with sync_playwright() as playwright:
# Prompts the user for the audio file to enhance
FILE = input("Which file would you like to enhance? ")
run(playwright, FILE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment