mirror of
https://github.com/R0m1k3/Socialflow.git
synced 2026-10-11 17:26:45 +02:00
refactor: Switch reels music service from Jamendo to Freesound
This commit is contained in:
1 parent
a401aee213
commit
8b62be83a0
1 file changed
+10
-9
+10
-9
@@ -5,7 +5,7 @@
|
||||
import { Router, Request, Response } from 'express';
|
||||
import type { User, Media, SocialPage } from '@shared/schema';
|
||||
import { storage } from '../storage';
|
||||
import { jamendoService, type MusicTrack } from '../services/jamendo';
|
||||
import { freeSoundService, type MusicTrack } from '../services/freesound';
|
||||
import { ffmpegService } from '../services/ffmpeg';
|
||||
import { facebookService } from '../services/facebook';
|
||||
import { cloudinaryService } from '../services/cloudinary';
|
||||
@@ -32,7 +32,7 @@ reelsRouter.get('/music/search', async (req: Request, res: Response) => {
|
||||
search,
|
||||
} = req.query;
|
||||
|
||||
const tracks = await jamendoService.searchMusicByDuration({
|
||||
const tracks = await freeSoundService.searchMusicByDuration({
|
||||
minDuration: parseInt(minDuration as string),
|
||||
maxDuration: parseInt(maxDuration as string),
|
||||
genre: genre as string | undefined,
|
||||
@@ -70,7 +70,7 @@ reelsRouter.get('/music/more', async (req: Request, res: Response) => {
|
||||
search,
|
||||
} = req.query;
|
||||
|
||||
const tracks = await jamendoService.searchMusicByDuration({
|
||||
const tracks = await freeSoundService.searchMusicByDuration({
|
||||
minDuration: parseInt(minDuration as string),
|
||||
maxDuration: parseInt(maxDuration as string),
|
||||
genre: genre as string | undefined,
|
||||
@@ -100,7 +100,7 @@ reelsRouter.get('/music/more', async (req: Request, res: Response) => {
|
||||
reelsRouter.get('/music/popular', async (req: Request, res: Response) => {
|
||||
try {
|
||||
const limit = parseInt(req.query.limit as string) || 10;
|
||||
const tracks = await jamendoService.getPopularTracks(limit);
|
||||
const tracks = await freeSoundService.getPopularTracks(limit);
|
||||
res.json({ tracks });
|
||||
} catch (error) {
|
||||
console.error('❌ Error fetching popular music:', error);
|
||||
@@ -225,7 +225,7 @@ reelsRouter.delete('/music/favorites/:trackId', async (req: Request, res: Respon
|
||||
reelsRouter.get('/music/:trackId', async (req: Request, res: Response) => {
|
||||
try {
|
||||
const { trackId } = req.params;
|
||||
const track = await jamendoService.getMusicDetails(trackId);
|
||||
const track = await freeSoundService.getMusicDetails(trackId);
|
||||
|
||||
if (!track) {
|
||||
return res.status(404).json({ error: 'Musique non trouvée' });
|
||||
@@ -314,7 +314,7 @@ reelsRouter.post('/reels/preview', async (req: Request, res: Response) => {
|
||||
// Récupérer l'URL de la musique si trackId fourni
|
||||
let finalMusicUrl = musicUrl;
|
||||
if (musicTrackId && !musicUrl) {
|
||||
const track = await jamendoService.getMusicDetails(musicTrackId);
|
||||
const track = await freeSoundService.getMusicDetails(musicTrackId);
|
||||
if (track) {
|
||||
finalMusicUrl = track.downloadUrl;
|
||||
}
|
||||
@@ -419,7 +419,7 @@ reelsRouter.post('/reels', async (req: Request, res: Response) => {
|
||||
// Récupérer l'URL de la musique si trackId fourni
|
||||
let finalMusicUrl = musicUrl;
|
||||
if (musicTrackId && !musicUrl) {
|
||||
const track = await jamendoService.getMusicDetails(musicTrackId);
|
||||
const track = await freeSoundService.getMusicDetails(musicTrackId);
|
||||
if (track) {
|
||||
finalMusicUrl = track.downloadUrl;
|
||||
}
|
||||
@@ -570,11 +570,12 @@ reelsRouter.post('/reels', async (req: Request, res: Response) => {
|
||||
*/
|
||||
reelsRouter.get('/reels/config', async (req: Request, res: Response) => {
|
||||
try {
|
||||
const jamendoConfigured = await jamendoService.testConnection().catch(() => false);
|
||||
const freesoundConfigured = await freeSoundService.testConnection().catch(() => false);
|
||||
const ffmpegConfigured = await ffmpegService.healthCheck().catch(() => false);
|
||||
|
||||
res.json({
|
||||
jamendo: { configured: jamendoConfigured },
|
||||
jamendo: { configured: freesoundConfigured }, // Keep legacy key for frontend compatibility
|
||||
freesound: { configured: freesoundConfigured },
|
||||
ffmpeg: { configured: ffmpegConfigured },
|
||||
});
|
||||
} catch (error) {
|
||||
|
||||
Reference in new issue
Block a user