some news for podcats mostly calling telegram directly
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import requests
|
||||
import xmltodict
|
||||
from urllib import request as urlrequest
|
||||
|
||||
from apps.telegram_communication.utils import telegramUtils
|
||||
|
||||
|
||||
def rss_to_dict(url):
|
||||
@@ -23,7 +23,7 @@ def rss_to_dict(url):
|
||||
return title,today_title,today_podcast_url
|
||||
|
||||
def download_news_mp3(url_mp3, filename):
|
||||
print("Downloading again: " + filename +" -- " + url_mp3)
|
||||
print("Downloading : " + filename +" -- " + url_mp3)
|
||||
try:
|
||||
urlrequest.urlretrieve(url_mp3, filename)
|
||||
except:
|
||||
@@ -38,9 +38,12 @@ def pretty_filename(filename,extension=''):
|
||||
return pretty_filename+extension
|
||||
|
||||
def main():
|
||||
telegram = telegramUtils()
|
||||
url = "https://feeds.audiomeans.fr/feed/44f6a116-20a6-44c4-98c4-b3e1bdd46dce.xml"
|
||||
today_podcast = rss_to_dict(url)
|
||||
print(today_podcast)
|
||||
download_news_mp3(today_podcast[2],pretty_filename(today_podcast[1],'mp3'))
|
||||
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]))
|
||||
|
||||
main()
|
||||
Reference in New Issue
Block a user