testing #16

Merged
pi-ux-ce merged 34 commits from testing into main 2026-07-04 17:40:00 +00:00
9 changed files with 60 additions and 0 deletions
Showing only changes of commit 15994f11b1 - Show all commits
@@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.
@@ -0,0 +1,6 @@
from django.apps import AppConfig
class PodcastAggregatorConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'podcast_aggregator'
@@ -0,0 +1,3 @@
from django.db import models
# Create your models here.
@@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.
@@ -0,0 +1,42 @@
import requests
import xmltodict
import urllib.request
from urllib import request as urlrequest
from urllib import parse as urlparse
from django.template.loader_tags import ExtendsNode
def rss_to_dict(url):
response = requests.get(url)
data = xmltodict.parse(response.content)
#print(data['rss'])
title = data['rss']['channel']['title']
#use first object as it's ordered in a chronological order
today_object = data['rss']['channel']['item'][0]
today_title = today_object['title']
today_podcast_url = data['rss']['channel']['item'][0]['enclosure']['@url']
return title,today_title,today_podcast_url
def download_news_mp3(url_mp3, filename):
print("Downloading again: " + filename +" -- " + url_mp3)
try:
urlrequest.urlretrieve(url_mp3, filename)
except:
print("Can't download " + filename +" -- " + url_mp3 + " == Cancelling")
return 0
def pretty_filename(filename,extension=''):
filename = filename.replace(' ', '_')
pretty_filename = filename.replace('/', '_')
if extension != '':
extension = str('.'+extension)
return pretty_filename+extension
def main():
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'))
main()
@@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.