Browse Source

add: proxy

Ben 11 months ago
parent
commit
ece5f8782f
2 changed files with 5 additions and 16 deletions
  1. 5 1
      app.py
  2. 0 15
      test.py

+ 5 - 1
app.py

@@ -17,7 +17,11 @@ def get_key(url: str) -> str:
 @cachetools.cached(cache=cachetools.TTLCache(maxsize=100000, ttl=60 * 5))
 def fetch_info(url):
     logging.info(f"fetching: {url}")
-    with yt_dlp.YoutubeDL({"flat-playlist": True, "extract_flat": "flat-playlist"}) as ydl:
+    with yt_dlp.YoutubeDL({
+        "flat-playlist": True,
+        "extract_flat": "flat-playlist",
+        "proxy": "socks5-proxy-69759aa5e4d9b48a.elb.us-east-1.amazonaws.com"
+    }) as ydl:
         info = ydl.extract_info(url, download=False)
         return info
 

+ 0 - 15
test.py

@@ -1,15 +0,0 @@
-import logging
-
-import yt_dlp
-
-if __name__ == '__main__':
-    url = "https://www.youtube.com/watch?v=szWDP5CBtyY"
-    logging.info(f"fetching: {url}")
-
-    with yt_dlp.YoutubeDL({
-        "flat-playlist": True,
-        "extract_flat": "flat-playlist",
-        "proxy": f'http://3.89.30.178:38080'
-    }) as ydl:
-        info = ydl.extract_info(url, download=False)
-    logging.info(f"info: {info}")