SPACERUNNER99 commited on
Commit
e9724c9
·
verified ·
1 Parent(s): fc4e5a1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -96,15 +96,19 @@ def yt_download(url):
96
  ys.download()
97
  return video_path, yt.title
98
 
99
- def insta_oneapi(url):
100
  shortcode = url.split("/")[-1]
101
- request_body = {"shortcode": shortcode}
 
 
102
  headers = {"one-api-token": api_key, "Content-Type": "application/json"}
103
- response = requests.post(url, headers=headers, json=request_body)
 
104
  if response.status_code == 200:
 
105
  result = response.json()
106
  try:
107
- response = requests.get(result['media']["url"], stream=True)
108
  response.raise_for_status()
109
  with open("video.mp4", 'wb') as file:
110
  for chunk in response.iter_content(chunk_size=8192):
@@ -114,7 +118,6 @@ def insta_oneapi(url):
114
  return "video.mp4"
115
  except requests.exceptions.RequestException as e:
116
  print(f"An error occurred: {e}")
117
- return result['media']["url"]
118
  else:
119
  print(f"Error: {response.status_code}, {response.text}")
120
  return None
 
96
  ys.download()
97
  return video_path, yt.title
98
 
99
+ def insta_oneapi(url, api_key):
100
  shortcode = url.split("/")[-1]
101
+ print(shortcode)
102
+ url_one="https://api.one-api.ir/instagram/v1/post/?shortcode="+shortcode
103
+ request_body = [{"shortcode": shortcode},]
104
  headers = {"one-api-token": api_key, "Content-Type": "application/json"}
105
+ response = requests.get(url_one, headers=headers)
106
+ print(response)
107
  if response.status_code == 200:
108
+
109
  result = response.json()
110
  try:
111
+ response = requests.get(result["result"]['media'][0]["url"], stream=True)
112
  response.raise_for_status()
113
  with open("video.mp4", 'wb') as file:
114
  for chunk in response.iter_content(chunk_size=8192):
 
118
  return "video.mp4"
119
  except requests.exceptions.RequestException as e:
120
  print(f"An error occurred: {e}")
 
121
  else:
122
  print(f"Error: {response.status_code}, {response.text}")
123
  return None