|
@@ -45,7 +45,7 @@ def p():
|
|
return {"status": 0}
|
|
return {"status": 0}
|
|
|
|
|
|
|
|
|
|
-def convert_dto(info, region):
|
|
|
|
|
|
+def convert_dto(info):
|
|
thumbnails = []
|
|
thumbnails = []
|
|
for item in info.get("thumbnails", []):
|
|
for item in info.get("thumbnails", []):
|
|
if item.get("width"):
|
|
if item.get("width"):
|
|
@@ -60,9 +60,7 @@ def convert_dto(info, region):
|
|
"acodec") != "none" and item.get("vcodec"):
|
|
"acodec") != "none" and item.get("vcodec"):
|
|
format_id = item.get("format_id")
|
|
format_id = item.get("format_id")
|
|
if 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({
|
|
formats.append({
|
|
"width": f"{item.get('width', 0)}",
|
|
"width": f"{item.get('width', 0)}",
|
|
"height": f"{item.get('height', 0)}",
|
|
"height": f"{item.get('height', 0)}",
|
|
@@ -108,14 +106,10 @@ def convert_dto(info, region):
|
|
|
|
|
|
@app.route("/extract", methods=["GET", "POST"])
|
|
@app.route("/extract", methods=["GET", "POST"])
|
|
def extract():
|
|
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")
|
|
url: str = request.json.get("url")
|
|
logging.info(f"url: {url}")
|
|
logging.info(f"url: {url}")
|
|
info = fetch_info(url=url)
|
|
info = fetch_info(url=url)
|
|
- return convert_dto(info=info, region=region)
|
|
|
|
|
|
+ return convert_dto(info=info)
|
|
|
|
|
|
|
|
|
|
@app.route("/health", methods=["GET"])
|
|
@app.route("/health", methods=["GET"])
|