Skip to content

Instantly share code, notes, and snippets.

@Zeko369
Last active May 31, 2024 12:34
Show Gist options
  • Save Zeko369/219d00945d72b91ab7b61c85bcca3366 to your computer and use it in GitHub Desktop.
Save Zeko369/219d00945d72b91ab7b61c85bcca3366 to your computer and use it in GitHub Desktop.
from playwright.sync_api import Playwright, sync_playwright, expect
from time import sleep
from shutil import copyfile
# 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(headless=False)
# 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_role("button", name="Choose files").set_input_files(FILE)
sleep(5)
page.query_selector("#enhance-file-upload").set_input_files(FILE)
print("Reached this")
# 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(.output(FILE[:-4] + " (enhanced).mp3", acodec="mp3")
# ffmpeg.execute()
# copy file from download.path() into same directory as this script
copyfile(download.path(), "output.mp3")
# ---------------------
# 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, "thingy.mp3")
ffmpeg==1.4
greenlet==3.0.3
playwright==1.44.0
pyee==11.1.0
typing_extensions==4.12.0
@Zeko369
Copy link
Author

Zeko369 commented May 31, 2024

Loving this

@Zeko369
Copy link
Author

Zeko369 commented May 31, 2024

Thank you so much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment