Implement autocreation of proxy.json, removing tempout after execution
Signed-off-by: hax <hax@lainlounge.xyz>
This commit is contained in:
parent
3a73d9fc75
commit
3605c5a2c4
1 changed files with 11 additions and 13 deletions
24
main.py
24
main.py
|
|
@ -93,20 +93,18 @@ def update_proxies():
|
||||||
def run_yt_dlp():
|
def run_yt_dlp():
|
||||||
"""Run yt-dlp with a randomly selected proxy."""
|
"""Run yt-dlp with a randomly selected proxy."""
|
||||||
while True:
|
while True:
|
||||||
with open("proxy.json", "r") as f:
|
try:
|
||||||
proxies = json.load(f)
|
with open("proxy.json", "r") as f:
|
||||||
if not proxies:
|
proxy = random.choice(json.load(f))
|
||||||
print("No proxies available. Please run the update command first.")
|
proxy_str = construct_proxy_string(proxy)
|
||||||
break
|
print(f"Using proxy from {proxy['city']}, {proxy['country']}")
|
||||||
|
if execute_yt_dlp_command(proxy_str):
|
||||||
proxy = random.choice(proxies)
|
os.remove("tempout")
|
||||||
proxy_str = construct_proxy_string(proxy)
|
|
||||||
print(f"Using proxy from {proxy['city']}, {proxy['country']}")
|
|
||||||
|
|
||||||
if execute_yt_dlp_command(proxy_str):
|
|
||||||
break # Exit loop if command was successful
|
break # Exit loop if command was successful
|
||||||
print("Got 'Sign in to confirm' error. Trying again with another proxy...")
|
print("Got 'Sign in to confirm' error. Trying again with another proxy...")
|
||||||
time.sleep(1) # Small delay before retrying
|
except FileNotFoundError as e:
|
||||||
|
print("'proxy.json' not found. Starting proxy list update...")
|
||||||
|
update_proxies()
|
||||||
|
|
||||||
def execute_yt_dlp_command(proxy_str):
|
def execute_yt_dlp_command(proxy_str):
|
||||||
"""Execute the yt-dlp command with the given proxy."""
|
"""Execute the yt-dlp command with the given proxy."""
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue