Created
March 9, 2022 08:35
-
-
Save tommasoturchi/eb2abd1bde7feebf076f6108b1956d6f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
from selenium.webdriver.common.by import By | |
import json | |
import subprocess | |
import time | |
driver = webdriver.Chrome() | |
driver.get("https://...") | |
input("Press Enter to continue...") | |
while 1: | |
try: | |
try: | |
title = driver.find_element( | |
by=By.CSS_SELECTOR, value="div[data-test=activity-title]" | |
).get_attribute("innerText") | |
if "[" in title: | |
process = subprocess.Popen( | |
'ffmpeg -i {} -c copy -bsf:a aac_adtstoasc "{}.mp4"'.format( | |
json.loads( | |
driver.find_elements(by=By.CLASS_NAME, value="w-json-ld")[ | |
-1 | |
].get_attribute("innerHTML") | |
)["contentUrl"], | |
title, | |
), | |
shell=True, | |
stdout=subprocess.PIPE, | |
) | |
process.wait() | |
except: | |
print("No Video URL found") | |
driver.find_element( | |
by=By.CSS_SELECTOR, value="button[data-test='continue-button']" | |
).click() | |
except: | |
print("Couldn't find continue button...") | |
driver.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment