commit | author | age
|
2dd7a5
|
1 |
package de.uhilger.avdirektor.handler; |
U |
2 |
|
|
3 |
import com.sun.net.httpserver.HttpExchange; |
|
4 |
import com.sun.net.httpserver.HttpHandler; |
|
5 |
import de.uhilger.avdirektor.App; |
|
6 |
import de.uhilger.avdirektor.OMXLogLeser; |
|
7 |
import java.io.File; |
|
8 |
import java.io.FileNotFoundException; |
|
9 |
import java.io.IOException; |
|
10 |
import java.text.ParseException; |
|
11 |
import java.text.SimpleDateFormat; |
|
12 |
import java.util.Date; |
|
13 |
import java.util.logging.Level; |
|
14 |
import java.util.logging.Logger; |
|
15 |
import org.apache.commons.io.FileUtils; |
|
16 |
|
|
17 |
/** |
|
18 |
* z.B. |
|
19 |
* http://rpi4-az:9090/avd/playon?th=1&ti=240&o=local&log=true&titel=http://amd-srv:9090/srv/Filme/C/casino_royale.m4v |
|
20 |
* @author ulrich |
|
21 |
*/ |
|
22 |
public class PlayOnHandler extends PlayHandler { |
|
23 |
|
|
24 |
private static final Logger logger = Logger.getLogger(PlayOnHandler.class.getName()); |
|
25 |
|
|
26 |
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd-hh-MM-ss"); |
|
27 |
|
|
28 |
public PlayOnHandler(String cmd) { |
|
29 |
super(cmd); |
|
30 |
} |
|
31 |
|
|
32 |
/* |
|
33 |
1. buildParams |
|
34 |
2. process |
|
35 |
*/ |
|
36 |
|
|
37 |
@Override |
|
38 |
protected StringBuilder buildParams(HttpExchange t) { |
|
39 |
String wd = System.getProperty("omx.wd"); |
|
40 |
File targetDir = new File(wd, "omx-logs"); |
|
41 |
try { |
|
42 |
File logFile = new File(wd, "omxplayer.log"); |
|
43 |
Date date = new Date(logFile.lastModified()); |
|
44 |
File srcFile = new File(wd, "omxplayer-" + sdf.format(date) + ".log"); |
|
45 |
logFile.renameTo(srcFile); |
|
46 |
targetDir.mkdirs(); |
|
47 |
FileUtils.moveFileToDirectory(srcFile, targetDir, false); |
|
48 |
} catch (IOException ex) { |
|
49 |
Logger.getLogger(PlayOnHandler.class.getName()).log(Level.SEVERE, null, ex); |
|
50 |
} |
|
51 |
StringBuilder params = super.buildParams(t); |
|
52 |
params.append(" --pos "); |
|
53 |
try { |
|
54 |
// hier das Ergebnis der Log-Auswertung angeben |
|
55 |
params.append(logsLesen(targetDir)); |
|
56 |
} catch (IOException ex) { |
|
57 |
Logger.getLogger(PlayOnHandler.class.getName()).log(Level.SEVERE, null, ex); |
|
58 |
} catch (ParseException ex) { |
|
59 |
Logger.getLogger(PlayOnHandler.class.getName()).log(Level.SEVERE, null, ex); |
|
60 |
} |
|
61 |
return params; |
|
62 |
} |
|
63 |
|
|
64 |
private String logsLesen(File logDir) throws IOException, FileNotFoundException, ParseException { |
|
65 |
OMXLogLeser leser = new OMXLogLeser(); |
|
66 |
return leser.logDirLesen(logDir); |
|
67 |
} |
|
68 |
|
|
69 |
} |