testing #22
@@ -3,6 +3,8 @@ import xmltodict
|
|||||||
from urllib import request as urlrequest
|
from urllib import request as urlrequest
|
||||||
from apps.telegram_communication.utils import telegramUtils
|
from apps.telegram_communication.utils import telegramUtils
|
||||||
from .models import podcastData
|
from .models import podcastData
|
||||||
|
import tempfile
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
proxy_url = 'http://gluetun-svc.gluetun.svc:8888'
|
proxy_url = 'http://gluetun-svc.gluetun.svc:8888'
|
||||||
@@ -47,7 +49,9 @@ def download_news_mp3(url_mp3, filename):
|
|||||||
|
|
||||||
print("Downloading : " + filename +" -- " + url_mp3)
|
print("Downloading : " + filename +" -- " + url_mp3)
|
||||||
try:
|
try:
|
||||||
|
|
||||||
urlrequest.urlretrieve(url_mp3, filename)
|
urlrequest.urlretrieve(url_mp3, filename)
|
||||||
|
|
||||||
except:
|
except:
|
||||||
print("Can't download " + filename +" -- " + url_mp3 + " == Cancelling")
|
print("Can't download " + filename +" -- " + url_mp3 + " == Cancelling")
|
||||||
return 0
|
return 0
|
||||||
@@ -71,8 +75,13 @@ def podcasts():
|
|||||||
|
|
||||||
today_podcast = rss_to_dict(url)
|
today_podcast = rss_to_dict(url)
|
||||||
print(today_podcast)
|
print(today_podcast)
|
||||||
file= pretty_filename(today_podcast[1],'mp3')
|
pretty_file_name = 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]))
|
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()
|
#main()
|
||||||
|
|||||||
Reference in New Issue
Block a user