mirror of
https://github.com/R0m1k3/podcastic.git
synced 2026-10-23 15:08:04 +02:00
feat: implement RSS parsing service and podcast controller for feed ingestion and episode synchronization
This commit is contained in:
1 parent
ba376930b0
commit
e075434dd7
5 files changed
+102
-16
No files matched your search
@@ -65,6 +65,20 @@ export default function Library() {
|
||||
},
|
||||
});
|
||||
|
||||
const syncMutation = useMutation({
|
||||
mutationFn: (podcastId: string) => podcastService.syncPodcast(podcastId),
|
||||
onSuccess: (data, podcastId) => {
|
||||
console.log(`[Sync SUCCESS] Podcast ID: ${podcastId}`, data);
|
||||
queryClient.invalidateQueries({ queryKey: ['podcasts', 'subscriptions'] });
|
||||
queryClient.invalidateQueries({ queryKey: ['episodes', 'latest'] });
|
||||
},
|
||||
onError: (error: any, podcastId) => {
|
||||
console.error(`[Sync FAILED] Podcast ID: ${podcastId}`, error);
|
||||
const errorMessage = error.response?.data?.message || 'Erreur de synchronisation';
|
||||
alert(`Erreur : ${errorMessage}`);
|
||||
},
|
||||
});
|
||||
|
||||
const handleLogout = async () => {
|
||||
try {
|
||||
await authService.logout();
|
||||
@@ -233,10 +247,33 @@ export default function Library() {
|
||||
) : (
|
||||
<div className="mt-auto">
|
||||
{podcast.episodeCount === 0 && (
|
||||
<p className="text-[10px] text-orange-500 font-medium mb-3 flex items-center gap-1">
|
||||
<Loader className="w-3 h-3 animate-spin" />
|
||||
Episodes en cours de synchronisation...
|
||||
</p>
|
||||
<div className="mb-4">
|
||||
<p className="text-[10px] text-orange-500 font-semibold mb-2 flex items-center gap-1 uppercase tracking-wider">
|
||||
{syncMutation.isPending && syncMutation.variables === (podcast.subscriptionId || podcast._id) ? (
|
||||
<Loader className="w-3 h-3 animate-spin" />
|
||||
) : (
|
||||
<span className="w-1.5 h-1.5 rounded-full bg-orange-500 animate-pulse" />
|
||||
)}
|
||||
Aucun épisode trouvé
|
||||
</p>
|
||||
<button
|
||||
onClick={() => syncMutation.mutate(podcast.subscriptionId || podcast._id)}
|
||||
disabled={syncMutation.isPending}
|
||||
className="w-full py-2 rounded-xl bg-orange-50 text-orange-600 hover:bg-orange-100 transition-all text-xs font-bold flex items-center justify-center gap-2 border border-orange-200/50"
|
||||
>
|
||||
{syncMutation.isPending && syncMutation.variables === (podcast.subscriptionId || podcast._id) ? (
|
||||
<>
|
||||
<Loader className="w-3 h-3 animate-spin" />
|
||||
Synchronisation...
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Loader className="w-3 h-3" />
|
||||
Synchroniser maintenant
|
||||
</>
|
||||
)}
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
<button
|
||||
onClick={() => handleUnsubscribeRequest(podcast.subscriptionId || podcast._id)}
|
||||
|
||||
@@ -37,6 +37,11 @@ export const podcastService = {
|
||||
return response.data;
|
||||
},
|
||||
|
||||
syncPodcast: async (podcastId: string): Promise<any> => {
|
||||
const response = await api.post(`/podcasts/${podcastId}/sync`);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
searchPodcasts: async (
|
||||
query: string,
|
||||
limit: number = 20,
|
||||
|
||||
Reference in new issue
Block a user