Ajout de la route de copie
This commit is contained in:
		| @@ -1,6 +1,8 @@ | ||||
| const { PrismaClient } = require('@prisma/client') | ||||
| const fs = require('fs') | ||||
|  | ||||
| const prisma = new PrismaClient() | ||||
| const usbLightshow = process.env.LIGHTSHOW_DIR || ''; | ||||
| class LigthshowService{ | ||||
|  | ||||
|  | ||||
| @@ -22,6 +24,42 @@ class LigthshowService{ | ||||
|     //         }, | ||||
|     //     }) | ||||
|     // } | ||||
|  | ||||
|     isExistLightshowOnServer(ligthshowName){ | ||||
|         let audio = this.getAudioFileName(ligthshowName) !== null; | ||||
|         let fseq = this.getFseqLigthshow(ligthshowName) !== null; | ||||
|         return audio && fseq; | ||||
|     } | ||||
|  | ||||
|     #getBaseFile(ligthshowName){ | ||||
|         return usbLightshow + '/' + ligthshowName | ||||
|     } | ||||
|  | ||||
|     getAudioFileName(ligthshowName){ | ||||
|         let base = this.#getBaseFile(ligthshowName) | ||||
|         let extensions = [ 'mp3', 'wav'] | ||||
|         let filename = null; | ||||
|         extensions.forEach((ext) => { | ||||
|             let tmpfileName = base + '.' + ext | ||||
|             if (fs.existsSync(tmpfileName) && filename === null){ | ||||
|                 filename = tmpfileName; | ||||
|             }else if (fs.existsSync(tmpfileName) && filename !== null){ | ||||
|                 throw new Error('Multiple audio file for the same Lightshow') | ||||
|             } | ||||
|         }) | ||||
|         return filename; | ||||
|  | ||||
|     } | ||||
|  | ||||
|     getFseqLigthshow(ligthshowName){ | ||||
|         let filename = null; | ||||
|         let base2 = usbLightshow + '/' + ligthshowName | ||||
|         let tmp = base2 + '.fseq' | ||||
|         if (fs.existsSync(tmp)){ | ||||
|             filename = tmp; | ||||
|         } | ||||
|         return filename; | ||||
|     } | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user