Spaces:
Build error
Build error
Alex Volkov
commited on
Commit
·
4d8662a
1
Parent(s):
d70c7fd
Added an option for a public share via CLI
Browse files- app.py +12 -2
- utils/utils.py +7 -0
app.py
CHANGED
@@ -1,19 +1,29 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
from download import check_download, download, download_generator
|
4 |
-
|
5 |
import anvil.media
|
6 |
import os
|
7 |
import pathlib
|
8 |
from pathlib import Path
|
9 |
from shutil import rmtree
|
10 |
import dotenv
|
|
|
11 |
|
12 |
dotenv.load_dotenv()
|
13 |
|
14 |
anvil.server.connect(os.environ.get('ANVIL_UPLINK_KEY'))
|
15 |
queue_placeholder = None
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
url_input = gr.Textbox(label="Youtube/Twitter/etc video URL (supports many services)", value='https://twitter.com/starsonxh/status/1552945347194142720', lines=1, elem_id="url_input")
|
18 |
download_status = gr.Textbox(label="Status:", value='', lines=1, elem_id="download_status")
|
19 |
init_video = gr.Video(label="Downloaded video", visible=False)
|
@@ -123,4 +133,4 @@ with gr.Blocks(css=css+"") as demo:
|
|
123 |
queue_placeholder = demo.queue()
|
124 |
|
125 |
if __name__ == "__main__":
|
126 |
-
demo.launch(show_error=True, debug=True)
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
from download import check_download, download, download_generator
|
4 |
+
import argparse
|
5 |
import anvil.media
|
6 |
import os
|
7 |
import pathlib
|
8 |
from pathlib import Path
|
9 |
from shutil import rmtree
|
10 |
import dotenv
|
11 |
+
from utils.utils import str2bool
|
12 |
|
13 |
dotenv.load_dotenv()
|
14 |
|
15 |
anvil.server.connect(os.environ.get('ANVIL_UPLINK_KEY'))
|
16 |
queue_placeholder = None
|
17 |
|
18 |
+
parser = argparse.ArgumentParser(
|
19 |
+
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
20 |
+
parser.add_argument("--public", type=str2bool, default=False,
|
21 |
+
help="Wether to share with gradio public or not")
|
22 |
+
|
23 |
+
|
24 |
+
args = parser.parse_args().__dict__
|
25 |
+
gradio_share: str = args.pop("public")
|
26 |
+
|
27 |
url_input = gr.Textbox(label="Youtube/Twitter/etc video URL (supports many services)", value='https://twitter.com/starsonxh/status/1552945347194142720', lines=1, elem_id="url_input")
|
28 |
download_status = gr.Textbox(label="Status:", value='', lines=1, elem_id="download_status")
|
29 |
init_video = gr.Video(label="Downloaded video", visible=False)
|
|
|
133 |
queue_placeholder = demo.queue()
|
134 |
|
135 |
if __name__ == "__main__":
|
136 |
+
demo.launch(show_error=True, debug=True, share=gradio_share)
|
utils/utils.py
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
def str2bool(string):
|
2 |
+
str2val = {"True": True, "False": False}
|
3 |
+
if string in str2val:
|
4 |
+
return str2val[string]
|
5 |
+
else:
|
6 |
+
raise ValueError(
|
7 |
+
f"Expected one of {set(str2val.keys())}, got {string}")
|