File size: 1,110 Bytes
5b6153e
 
 
d493838
 
21cb796
5b6153e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d493838
21cb796
0fc5368
21cb796
 
 
 
 
0fc5368
d493838
21cb796
0fc5368
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
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
import gradio as gr

def get_youtube_cookies(url):
    # Set up Selenium with Chrome
    options = webdriver.ChromeOptions()
    options.add_argument('--headless')  # Run in headless mode
    driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)

    # Log in to YouTube
    driver.get("https://www.youtube.com")
    # You would need to add steps here to log in

    # Navigate to the URL
    driver.get(url)

    # Extract cookies
    cookies = driver.get_cookies()
    driver.quit()

    # Format cookies as a string
    cookie_str = "\n".join([f"{cookie['name']}={cookie['value']}" for cookie in cookies])
    return cookie_str

# Create the Gradio interface
iface = gr.Interface(
    fn=get_youtube_cookies,
    inputs=gr.Textbox(label="YouTube URL"),
    outputs=gr.Textbox(label="Cookies"),
    title="YouTube Cookies Extractor",
    description="Enter a YouTube URL to extract cookies."
)

# Launch the app
iface.launch()