use temporary folder to avoid downloading into disk
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4s

This commit is contained in:
2026-07-09 09:13:36 +01:00
parent 0aebb19650
commit e7b72b1754
+12 -3
View File
@@ -3,6 +3,8 @@ import xmltodict
from urllib import request as urlrequest
from apps.telegram_communication.utils import telegramUtils
from .models import podcastData
import tempfile
import time
proxy_url = 'http://gluetun-svc.gluetun.svc:8888'
@@ -47,7 +49,9 @@ def download_news_mp3(url_mp3, filename):
print("Downloading : " + filename +" -- " + url_mp3)
try:
urlrequest.urlretrieve(url_mp3, filename)
except:
print("Can't download " + filename +" -- " + url_mp3 + " == Cancelling")
return 0
@@ -71,8 +75,13 @@ def podcasts():
today_podcast = rss_to_dict(url)
print(today_podcast)
file= pretty_filename(today_podcast[1],'mp3')
download_news_mp3(today_podcast[2],file)
telegram.send_document(file,str(today_podcast[0])+" "+str(today_podcast[1]))
pretty_file_name = pretty_filename(today_podcast[1],'mp3')
temp = tempfile.TemporaryDirectory()
temp_path = temp.name.replace("\\", "/")
file_path = temp_path+"/"+pretty_file_name
download_news_mp3(today_podcast[2],file_path)
print(file_path)
telegram.send_document(file_path,str(today_podcast[0])+" "+str(today_podcast[1]))
#main()