Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7492061f58 | ||
|
|
a44ca7e825 | ||
|
|
f68b0ad00f |
@@ -1,3 +1,9 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
from import_export.admin import ImportExportModelAdmin
|
||||||
|
from import_export import resources
|
||||||
|
from .models import podcastData
|
||||||
|
|
||||||
# Register your models here.
|
# Register your models here.
|
||||||
|
@admin.register(podcastData)
|
||||||
|
class JobAdmin(ImportExportModelAdmin):
|
||||||
|
list_display = ('podcast_name','podcast_url','enabled')
|
||||||
|
|||||||
@@ -3,4 +3,5 @@ from django.apps import AppConfig
|
|||||||
|
|
||||||
class PodcastAggregatorConfig(AppConfig):
|
class PodcastAggregatorConfig(AppConfig):
|
||||||
default_auto_field = 'django.db.models.BigAutoField'
|
default_auto_field = 'django.db.models.BigAutoField'
|
||||||
name = 'podcast_aggregator'
|
name = 'apps.podcast_aggregator'
|
||||||
|
label = 'podcast'
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
# Generated by Django 4.2.29 on 2026-06-30 22:05
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='podcastData',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('podcast_name', models.CharField(max_length=100, null=True)),
|
||||||
|
('podcast_url', models.CharField(max_length=100, null=True)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'db_table': 'podcasts',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 4.2.29 on 2026-06-30 22:08
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('podcast', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='podcastdata',
|
||||||
|
name='enabled',
|
||||||
|
field=models.BooleanField(default=True),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -1,3 +1,8 @@
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
# Create your models here.
|
class podcastData(models.Model):
|
||||||
|
podcast_name = models.CharField(max_length=100, null=True)
|
||||||
|
podcast_url = models.CharField(max_length=100, null=True)
|
||||||
|
enabled = models.BooleanField(default=True)
|
||||||
|
class Meta:
|
||||||
|
db_table = 'podcasts'
|
||||||
@@ -8,7 +8,7 @@ def rss_to_dict(url):
|
|||||||
response = requests.get(url)
|
response = requests.get(url)
|
||||||
data = xmltodict.parse(response.content)
|
data = xmltodict.parse(response.content)
|
||||||
|
|
||||||
#print(data['rss'])
|
print(data['rss'])
|
||||||
|
|
||||||
title = data['rss']['channel']['title']
|
title = data['rss']['channel']['title']
|
||||||
|
|
||||||
@@ -16,7 +16,12 @@ def rss_to_dict(url):
|
|||||||
#print(data['rss'].keys())
|
#print(data['rss'].keys())
|
||||||
|
|
||||||
#use first object as it's ordered in a chronological order
|
#use first object as it's ordered in a chronological order
|
||||||
today_object = data['rss']['channel']['item'][0]
|
|
||||||
|
|
||||||
|
today_object = data['rss']['channel']['item']
|
||||||
|
if isinstance(today_object, list):
|
||||||
|
today_object = data['rss']['channel']['item'][0]
|
||||||
|
|
||||||
today_title = today_object['title']
|
today_title = today_object['title']
|
||||||
today_podcast_url = data['rss']['channel']['item'][0]['enclosure']['@url']
|
today_podcast_url = data['rss']['channel']['item'][0]['enclosure']['@url']
|
||||||
|
|
||||||
@@ -44,6 +49,7 @@ def podcasts():
|
|||||||
telegram.clear_expired_messages()
|
telegram.clear_expired_messages()
|
||||||
|
|
||||||
url = "https://feeds.audiomeans.fr/feed/44f6a116-20a6-44c4-98c4-b3e1bdd46dce.xml"
|
url = "https://feeds.audiomeans.fr/feed/44f6a116-20a6-44c4-98c4-b3e1bdd46dce.xml"
|
||||||
|
url_bbc = "https://podcast.voice.api.bbci.co.uk/rss/audio/p002vsmz?api_key=Wbek5zSqxz0Hk1blo5IBqbd9SCWIfNbT"
|
||||||
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')
|
file= pretty_filename(today_podcast[1],'mp3')
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ class ProjectDatabaseRouter:
|
|||||||
return 'cloudmanager_db'
|
return 'cloudmanager_db'
|
||||||
if model._meta.app_label == 'telegram':
|
if model._meta.app_label == 'telegram':
|
||||||
return 'telegram_db'
|
return 'telegram_db'
|
||||||
|
if model._meta.app_label == 'podcast':
|
||||||
|
return 'podcast_db'
|
||||||
return 'default'
|
return 'default'
|
||||||
|
|
||||||
def db_for_write(self, model, **hints):
|
def db_for_write(self, model, **hints):
|
||||||
@@ -32,14 +34,16 @@ class ProjectDatabaseRouter:
|
|||||||
return 'redirect_db'
|
return 'redirect_db'
|
||||||
if model._meta.app_label == 'telegram':
|
if model._meta.app_label == 'telegram':
|
||||||
return 'telegram_db'
|
return 'telegram_db'
|
||||||
|
if model._meta.app_label == 'podcast':
|
||||||
|
return 'podcast_db'
|
||||||
return 'default'
|
return 'default'
|
||||||
|
|
||||||
def allow_relation(self, obj1, obj2, **hints):
|
def allow_relation(self, obj1, obj2, **hints):
|
||||||
"""Allow relations if both models are in the same database."""
|
"""Allow relations if both models are in the same database."""
|
||||||
# Prevents accidental foreign key relationships across different physical DBs
|
# Prevents accidental foreign key relationships across different physical DBs
|
||||||
if (
|
if (
|
||||||
obj1._meta.app_label in ['simpsons', 'cloudmanager','redirect','job','telegram'] or
|
obj1._meta.app_label in ['simpsons', 'cloudmanager','redirect','job','telegram','podcast'] or
|
||||||
obj2._meta.app_label in ['simpsons', 'cloudmanager','redirect','job','telegram']
|
obj2._meta.app_label in ['simpsons', 'cloudmanager','redirect','job','telegram','podcast']
|
||||||
):
|
):
|
||||||
return obj1._meta.app_label == obj2._meta.app_label
|
return obj1._meta.app_label == obj2._meta.app_label
|
||||||
return None
|
return None
|
||||||
@@ -56,8 +60,10 @@ class ProjectDatabaseRouter:
|
|||||||
return db == 'redirect_db'
|
return db == 'redirect_db'
|
||||||
if app_label == 'telegram':
|
if app_label == 'telegram':
|
||||||
return db == 'telegram_db'
|
return db == 'telegram_db'
|
||||||
|
if app_label == 'podcast':
|
||||||
|
return db == 'podcast_db'
|
||||||
# Ensure default Django apps (auth, sessions, etc.) don't migrate into simpsons/cloudmanager
|
# Ensure default Django apps (auth, sessions, etc.) don't migrate into simpsons/cloudmanager
|
||||||
if db in ['simpsons_db', 'cloudmanager_db','redirect_db','job_db','telegram_db']:
|
if db in ['simpsons_db', 'cloudmanager_db','redirect_db','job_db','telegram_db','podcast_db']:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return None
|
return None
|
||||||
@@ -48,6 +48,7 @@ INSTALLED_APPS = [
|
|||||||
'apps.website_redirection.apps.redirectConfig',
|
'apps.website_redirection.apps.redirectConfig',
|
||||||
'apps.job_dashboard.apps.JobDashboardConfig',
|
'apps.job_dashboard.apps.JobDashboardConfig',
|
||||||
'apps.telegram_communication.apps.TelegramCommunicationConfig',
|
'apps.telegram_communication.apps.TelegramCommunicationConfig',
|
||||||
|
'apps.podcast_aggregator.apps.PodcastAggregatorConfig',
|
||||||
'import_export',
|
'import_export',
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -142,6 +143,14 @@ DATABASES = {
|
|||||||
'HOST': os.environ.get('DB_HOST'),
|
'HOST': os.environ.get('DB_HOST'),
|
||||||
'PORT': os.environ.get('DB_PORT'),
|
'PORT': os.environ.get('DB_PORT'),
|
||||||
},
|
},
|
||||||
|
'podcast_db': {
|
||||||
|
'ENGINE': 'django.db.backends.postgresql',
|
||||||
|
'NAME': 'podcast',
|
||||||
|
'USER': os.environ.get('DB_USERNAME'),
|
||||||
|
'PASSWORD': os.environ.get('DB_PASSWORD'),
|
||||||
|
'HOST': os.environ.get('DB_HOST'),
|
||||||
|
'PORT': os.environ.get('DB_PORT'),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
DATABASE_ROUTERS = ['core.routers.ProjectDatabaseRouter']
|
DATABASE_ROUTERS = ['core.routers.ProjectDatabaseRouter']
|
||||||
#DATABASE_ROUTERS = []
|
#DATABASE_ROUTERS = []
|
||||||
|
|||||||
Reference in New Issue
Block a user