YUTV / app.py
yuyutsu07's picture
Update app.py
efd9131 verified
import streamlit as st
import requests
def main():
st.title("JioCinema M3U8 Generator")
# Fetch data from the JSON link
data_url = "https://popoproxy.yuyutsu.workers.dev"
try:
response = requests.get(data_url)
response.raise_for_status() # Raise an exception for bad status codes
data = response.json()
except requests.exceptions.RequestException as e:
st.error(f"Error fetching data: {e}")
return
# Find the relevant API data
jiocinema_data = None
for api_data in data:
if api_data.get("Api_name") == "RJIL_JioCinema":
jiocinema_data = api_data
break
if jiocinema_data:
# Generate M3U content
m3u_content = "#EXTM3U\n"
for channel in jiocinema_data["channels"]:
m3u_content += f'#EXTINF:-1 tvg-id="{channel["channel_id"]}" tvg-logo="{channel["logo"]}" group-title="{channel["category"]}", {channel["name"]}\n'
m3u_content += f'{channel["link"]}\n'
# Display other details
st.write("**API Details:**")
st.write(f"API Name: {jiocinema_data['Api_name']}")
st.write(f"Total Channels: {jiocinema_data['total_channels']}")
st.write(f"Developer: {jiocinema_data['developer']}")
st.write(f"Last Update: {jiocinema_data['last_update']}")
st.write(f"Cookie Expire: {jiocinema_data['cookie_expire']}")
# Download button for M3U file
st.download_button(
label="Download JioCinema.m3u",
data=m3u_content,
file_name="JioCinema.m3u",
mime="audio/x-mpegurl",
)
else:
st.error("JioCinema data not found in the JSON response.")
if __name__ == "__main__":
main()