35 lines
875 B
Python
35 lines
875 B
Python
|
from supabase import create_client, Client
|
||
|
|
||
|
# RLS policy permissions required:
|
||
|
# buckets table permissions: select
|
||
|
# objects table permissions: none
|
||
|
|
||
|
url: str = ""
|
||
|
key: str = ""
|
||
|
supabase: Client = create_client(url, key)
|
||
|
|
||
|
|
||
|
# List all objects in the 'video' bucket
|
||
|
# .from("bucket_name")
|
||
|
# .list("folder_name")
|
||
|
response = supabase.storage.from_("video").list("",{"limit": 1000})
|
||
|
|
||
|
|
||
|
for video in response:
|
||
|
video_name = video['name'].replace('.mp4', '')
|
||
|
video_url = f"{url}/storage/v1/object/public/video/{video_name}.mp4"
|
||
|
|
||
|
# print the video name and url with tabs
|
||
|
print(video_name, video_url, sep="\t")
|
||
|
|
||
|
response = (
|
||
|
# .table("table_name")
|
||
|
# .insert({"column_name": value})
|
||
|
# .execute SQL query
|
||
|
supabase.table("Videa")
|
||
|
.insert({"label": video_name, "video_url": video_url})
|
||
|
.execute()
|
||
|
)
|
||
|
# print(response)
|
||
|
|