Ben 11 ヶ月 前
コミット
757e943383
1 ファイル変更3 行追加9 行削除
  1. 3 9
      app.py

+ 3 - 9
app.py

@@ -45,7 +45,7 @@ def p():
     return {"status": 0}
 
 
-def convert_dto(info, region):
+def convert_dto(info):
     thumbnails = []
     for item in info.get("thumbnails", []):
         if item.get("width"):
@@ -60,9 +60,7 @@ def convert_dto(info, region):
                 "acodec") != "none" and item.get("vcodec"):
             format_id = item.get("format_id")
             if format_id:
-                url = item.get("url")
-                if region != "US":
-                    url = f"http://d2rueqse8qhuiu.cloudfront.net/p?videoId={info['display_id']}&formatId={format_id}",
+                url = f"http://d2rueqse8qhuiu.cloudfront.net/p?videoId={info['display_id']}&formatId={format_id}",
                 formats.append({
                     "width": f"{item.get('width', 0)}",
                     "height": f"{item.get('height', 0)}",
@@ -108,14 +106,10 @@ def convert_dto(info, region):
 
 @app.route("/extract", methods=["GET", "POST"])
 def extract():
-    ip = request.headers.get("X-Forwarded-For")
-    response = requests.get(f"https://ipinfo.ipidea.io/?ip={ip}").json()
-    logging.info(f"ip: {ip}, response: {response}")
-    region = response.get("country_code", "")
     url: str = request.json.get("url")
     logging.info(f"url: {url}")
     info = fetch_info(url=url)
-    return convert_dto(info=info, region=region)
+    return convert_dto(info=info)
 
 
 @app.route("/health", methods=["GET"])