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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -1
app.py CHANGED
@@ -96,6 +96,29 @@ def yt_download(url):
96
  ys.download()
97
  return video_path, yt.title
98
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  def insta_download(permalink):
100
  # Create an instance of Instaloader
101
  L = instaloader.Instaloader()
@@ -280,7 +303,7 @@ def create_subtitle_clips(subtitles, videosize, fontsize, font, color, debug):
280
  def process_video(url, type):
281
 
282
  if type=="insta":
283
- input_video=insta_download(url)
284
  input_video_name = input_video.replace(".mp4", "")
285
  input_audio = extract_audio(input_video)
286
  elif type=="youtube":
 
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):
111
+ if chunk:
112
+ file.write(chunk)
113
+ print(f"Downloaded successfully")
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
121
+
122
  def insta_download(permalink):
123
  # Create an instance of Instaloader
124
  L = instaloader.Instaloader()
 
303
  def process_video(url, type):
304
 
305
  if type=="insta":
306
+ input_video=insta_oneapi(url)
307
  input_video_name = input_video.replace(".mp4", "")
308
  input_audio = extract_audio(input_video)
309
  elif type=="youtube":