Lookimi commited on
Commit
fe13e9b
·
1 Parent(s): 53747cb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -1
app.py CHANGED
@@ -7,6 +7,9 @@ def fetch(url, name, ext):
7
  elif ext == "webm zip":
8
  opts = ""
9
  ext = "webm"
 
 
 
10
  else:
11
  opts = {
12
  "mp3": "-f \"ba\" -x --audio-format mp3 --audio-quality 1",
@@ -23,13 +26,21 @@ def fetch(url, name, ext):
23
  if ext == "webm" or ext == "webm zip":
24
  os.system(f"zip -9 {filename}.zip {filename}")
25
  return filename.rstrip(".webm") + ".zip"
 
 
 
 
 
 
 
 
26
  return filename
27
 
28
  gr.Interface(
29
  fetch,
30
  [gr.Textbox(label="Media link", placeholder="URL goes here..."),
31
  gr.Textbox(label="File name", placeholder="best-vid"),
32
- gr.Dropdown(["mp3", "mp4", "webm", "webm zip"], value="mp4", label="File type")],
33
  gr.outputs.File(label="Download!"),
34
  description="Download web media! Works on most sites like YouTube, Reddit, Twitter, Instagram, etc.",
35
  enable_queue=True
 
7
  elif ext == "webm zip":
8
  opts = ""
9
  ext = "webm"
10
+ elif ext == "transcript":
11
+ opts = "--write-auto-sub --skip-download"
12
+ ext = "vtt"
13
  else:
14
  opts = {
15
  "mp3": "-f \"ba\" -x --audio-format mp3 --audio-quality 1",
 
26
  if ext == "webm" or ext == "webm zip":
27
  os.system(f"zip -9 {filename}.zip {filename}")
28
  return filename.rstrip(".webm") + ".zip"
29
+
30
+ if ext == "transcript":
31
+ with open(filename, "r") as file:
32
+ text = file.read()
33
+ text = text.replace("\n\n", "\n").replace("WEBVTT\n\n", "")
34
+ with open(f"{name}.txt", "w") as file:
35
+ file.write(text)
36
+ return f"{name}.txt"
37
  return filename
38
 
39
  gr.Interface(
40
  fetch,
41
  [gr.Textbox(label="Media link", placeholder="URL goes here..."),
42
  gr.Textbox(label="File name", placeholder="best-vid"),
43
+ gr.Dropdown(["mp3", "mp4", "webm", "webm zip", "transcript"], value="mp4", label="File type")],
44
  gr.outputs.File(label="Download!"),
45
  description="Download web media! Works on most sites like YouTube, Reddit, Twitter, Instagram, etc.",
46
  enable_queue=True