Spaces:
Sleeping
Sleeping
Update player.py
Browse files
player.py
CHANGED
@@ -5,6 +5,7 @@ import json
|
|
5 |
token = ""
|
6 |
source_dataset = "jbilcke-hf/ai-tube-index"
|
7 |
api = HfApi(token=token)
|
|
|
8 |
def find_dataset(author=""):
|
9 |
s_ist = (api.list_datasets(author=author,search="ai-tube"))
|
10 |
#print(api.whoami())
|
@@ -12,65 +13,51 @@ def find_dataset(author=""):
|
|
12 |
videos=[]
|
13 |
out_html=""
|
14 |
for space in s_ist:
|
15 |
-
#for i,space in enumerate(s_ist):
|
16 |
try:
|
17 |
-
#space_loc=space.id
|
18 |
-
#space_auth=space_loc.split("/",1)[0]
|
19 |
-
#space_name=space_loc.split("/",1)[0]
|
20 |
-
#space_ea = space.id.split("/",1)[1]
|
21 |
channels.append(space.id)
|
22 |
except Exception:
|
23 |
pass
|
24 |
return (gr.Dropdown(label="Channels", choices=[s for s in channels],interactive=True))
|
25 |
|
26 |
-
def
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
45 |
try:
|
46 |
-
vid_slug
|
47 |
-
|
48 |
-
|
49 |
-
if vid_file.endswith(".json"):
|
50 |
-
r = requests.get(f'https://huggingface.co/datasets/jbilcke-hf/ai-tube-index/raw/main/videos/{vid_slug}.json')
|
51 |
-
#r = requests.get(f'https://huggingface.co/datasets/jbilcke-hf/ai-tube-index/blob/main/videos/00b4bcda-7b4a-40f8-9833-e490425a7b91.mp4')
|
52 |
-
print (r.content)
|
53 |
-
#uid = uuid.uuid4()
|
54 |
-
#file = open(f'{name}/{f_name}','wb')
|
55 |
-
#file.write(r.content)
|
56 |
-
except Exception as e:
|
57 |
-
print (f'error:: {e}')
|
58 |
-
pass
|
59 |
-
try:
|
60 |
-
if vid_slug == prompt_slug:
|
61 |
-
out_html=f'{out_html}<pre> + {vid_file}</pre>'
|
62 |
-
|
63 |
-
except Exception:
|
64 |
-
pass
|
65 |
except Exception:
|
66 |
pass
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
|
|
|
|
74 |
print(spaces)
|
75 |
return(out_html)
|
76 |
with gr.Blocks() as app:
|
@@ -78,5 +65,5 @@ with gr.Blocks() as app:
|
|
78 |
button = gr.Button()
|
79 |
output = gr.HTML()
|
80 |
app.load(find_dataset,None,author)
|
81 |
-
|
82 |
app.launch(show_api=False,share=False)
|
|
|
5 |
token = ""
|
6 |
source_dataset = "jbilcke-hf/ai-tube-index"
|
7 |
api = HfApi(token=token)
|
8 |
+
|
9 |
def find_dataset(author=""):
|
10 |
s_ist = (api.list_datasets(author=author,search="ai-tube"))
|
11 |
#print(api.whoami())
|
|
|
13 |
videos=[]
|
14 |
out_html=""
|
15 |
for space in s_ist:
|
|
|
16 |
try:
|
|
|
|
|
|
|
|
|
17 |
channels.append(space.id)
|
18 |
except Exception:
|
19 |
pass
|
20 |
return (gr.Dropdown(label="Channels", choices=[s for s in channels],interactive=True))
|
21 |
|
22 |
+
def load_vid(channel):
|
23 |
+
try:
|
24 |
+
file_box = [info.path for info in list_files_info(f'{channel}', repo_type="dataset")]
|
25 |
+
ai_tube_box = [info.path for info in list_files_info(f'{source_dataset}', repo_type="dataset")]
|
26 |
+
for file in file_box:
|
27 |
+
if file.startswith("prompt_"):
|
28 |
+
prompt_slug = file.split("prompt_",1)[1].split(".",1)[0]
|
29 |
+
out_html=f'{out_html}<pre> • {file}</pre>'
|
30 |
+
print(prompt_slug)
|
31 |
+
for vid_file in ai_tube_box:
|
32 |
+
try:
|
33 |
+
vid_slug=vid_file.split("videos/",1)[1].split(".",1)[0]
|
34 |
+
print(vid_slug)
|
35 |
+
try:
|
36 |
+
if vid_file.endswith(".json"):
|
37 |
+
r = requests.get(f'https://huggingface.co/datasets/jbilcke-hf/ai-tube-index/raw/main/videos/{vid_slug}.json')
|
38 |
+
#r = requests.get(f'https://huggingface.co/datasets/jbilcke-hf/ai-tube-index/blob/main/videos/00b4bcda-7b4a-40f8-9833-e490425a7b91.mp4')
|
39 |
+
print (r.content)
|
40 |
+
#uid = uuid.uuid4()
|
41 |
+
#file = open(f'{name}/{f_name}','wb')
|
42 |
+
#file.write(r.content)
|
43 |
+
except Exception as e:
|
44 |
+
print (f'error:: {e}')
|
45 |
+
pass
|
46 |
try:
|
47 |
+
if vid_slug == prompt_slug:
|
48 |
+
out_html=f'{out_html}<pre> + {vid_file}</pre>'
|
49 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
except Exception:
|
51 |
pass
|
52 |
+
except Exception:
|
53 |
+
pass
|
54 |
+
|
55 |
+
#print([info.path for info in list_files_info(f'{space.id}', repo_type="dataset")])
|
56 |
+
#print(space.id)
|
57 |
+
except Exception as e:
|
58 |
+
print(e)
|
59 |
+
#s_info=api.space_info(f'{name}/{space}',files_metadata=True)
|
60 |
+
#print(s_info)
|
61 |
print(spaces)
|
62 |
return(out_html)
|
63 |
with gr.Blocks() as app:
|
|
|
65 |
button = gr.Button()
|
66 |
output = gr.HTML()
|
67 |
app.load(find_dataset,None,author)
|
68 |
+
author.change(load_vid,author,output)
|
69 |
app.launch(show_api=False,share=False)
|