Spaces:
Sleeping
Sleeping
File size: 1,983 Bytes
bd65e34 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
import json
from pathlib import Path
import subprocess
import streamlit as st
import ingest
from utils import kick_dl
def download_convert_persist():
service = st.radio("Streaming service", ["Twitch", "Kick"])
if service == "Twitch":
twitch_id = st.text_input("Enter Twitch ID")
st.write(f"You Selected {twitch_id}")
if st.button("Download"):
with st.spinner():
st.write("Downloading...")
ingest.download_twitch_stream(twitch_id)
st.write("Converting...")
ingest.vid_to_frames(twitch_id, use_cuda=False)
st.success("Downloaded!")
elif service == "Kick":
kick_id = st.text_input("Enter Kick ID")
name = st.text_input("Nickname of video")
kick_id = Path(kick_id).name
API_PATH = "https://kick.com/api/v1/video/"
st.write(f"Open [this]({API_PATH}{kick_id}) and copy text into the box below.")
json_data = st.text_input("Copy and paste here.")
if len(json_data):
json_data = json.loads(json_data)["source"]
if st.button("Download"):
with st.spinner():
st.write("Downloading...")
if not Path(f"converted/{name}").exists():
subprocess.Popen(
[
"ffmpeg",
"-i",
json_data,
"-vcodec",
"copy",
"-acodec",
"copy",
f"downloaded/{name}.mp4",
]
)
st.write("Converting...")
ingest.vid_to_frames(name, use_cuda=False)
Path(f"downloaded/{name}.mp4").unlink()
st.success("Downloaded!")
|