|
|
|
|
@ -2,16 +2,6 @@ import streamlit as st |
|
|
|
|
import requests |
|
|
|
|
from bs4 import BeautifulSoup |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def download_content(url): |
|
|
|
|
response = requests.get(url) |
|
|
|
|
if response.status_code == 200: |
|
|
|
|
with open("downloaded_content.txt", "wb") as file: |
|
|
|
|
file.write(response.content) |
|
|
|
|
st.success("Content downloaded successfully!") |
|
|
|
|
else: |
|
|
|
|
st.error("Failed to download content. Please check the URL.") |
|
|
|
|
|
|
|
|
|
def main(): |
|
|
|
|
url_article = st.text_input('Adress till artikeln').strip() |
|
|
|
|
if url_article == '': |
|
|
|
|
@ -29,8 +19,6 @@ def main(): |
|
|
|
|
|
|
|
|
|
d = requests.get(url, headers={'Accept': 'application/json'}).json() |
|
|
|
|
|
|
|
|
|
comment = d["metadata"]["items"][0]["description"] + f' \n{url_article}' |
|
|
|
|
|
|
|
|
|
title = d["metadata"]["items"][0]["subtitle"] |
|
|
|
|
filename = title + ".m4a" |
|
|
|
|
|
|
|
|
|
@ -38,11 +26,6 @@ def main(): |
|
|
|
|
url |
|
|
|
|
# Spara ljudet till en fil |
|
|
|
|
r = requests.get(url) |
|
|
|
|
# with open(file, "wb") as f: |
|
|
|
|
# f.write(r.content) |
|
|
|
|
|
|
|
|
|
with open(filename, "wb") as f: |
|
|
|
|
f.write(r.content) |
|
|
|
|
|
|
|
|
|
with open(filename, 'rb') as f: |
|
|
|
|
st.download_button('Ladda ned ljudet', r.content, mime="audio/mpeg", file_name= filename) |
|
|
|
|
|