From cf65097eb1b5ecd25fe05416be24c196868f15e8 Mon Sep 17 00:00:00 2001 From: ulrich Date: Wed, 07 Apr 2021 11:25:19 +0000 Subject: [PATCH] Einstellungen --- src/de/uhilger/mediaz/api/ListFileHandler.java | 33 +++++++++++++++++++++++++-------- 1 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/de/uhilger/mediaz/api/ListFileHandler.java b/src/de/uhilger/mediaz/api/ListFileHandler.java index 5be132b..cda66b7 100644 --- a/src/de/uhilger/mediaz/api/ListFileHandler.java +++ b/src/de/uhilger/mediaz/api/ListFileHandler.java @@ -1,7 +1,19 @@ /* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. + Mediazentrale - Personal Media Center + Copyright (C) 2021 Ulrich Hilger + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. */ package de.uhilger.mediaz.api; @@ -42,17 +54,22 @@ if(files != null) { for(File file : files) { StorageFile sf = new StorageFile(); - sf.setName(file.getName()); + String fname = file.getName(); + sf.setName(fname); if(file.isDirectory()) { - sf.setTyp("folder"); + sf.setTyp(StorageFile.TYP_FOLDER); } else { - sf.setTyp("file"); + if(fname.endsWith(".mp3")) { + sf.setTyp(StorageFile.TYP_AUDIO); + } else if(fname.endsWith(".mp4") || fname.endsWith(".m4v")) { + sf.setTyp(StorageFile.TYP_VIDEO); + } else { + sf.setTyp(StorageFile.TYP_FILE); + } } list.add(sf); } } - //Gson gson = new Gson(); - //String json = gson.toJson(fileNames); String json = jsonWithCustomType(list, "Medialiste"); logger.fine(json); e.sendResponseHeaders(200, json.length()); -- Gitblit v1.9.3