Enable saving/loading of all autorec fields
This commit is contained in:
parent
d40dd9e253
commit
ce4481f60c
|
@ -24,6 +24,7 @@ import com.moparisthebest.jdbc.QueryMapper;
|
||||||
import com.moparisthebest.rcrdit.autorec.AutoRec;
|
import com.moparisthebest.rcrdit.autorec.AutoRec;
|
||||||
import com.moparisthebest.rcrdit.autorec.Profile;
|
import com.moparisthebest.rcrdit.autorec.Profile;
|
||||||
import com.moparisthebest.rcrdit.autorec.ProgramAutoRec;
|
import com.moparisthebest.rcrdit.autorec.ProgramAutoRec;
|
||||||
|
import com.moparisthebest.rcrdit.tuner.DummyTuner;
|
||||||
import com.moparisthebest.rcrdit.tuner.HDHomerun;
|
import com.moparisthebest.rcrdit.tuner.HDHomerun;
|
||||||
import com.moparisthebest.rcrdit.tuner.Tuner;
|
import com.moparisthebest.rcrdit.tuner.Tuner;
|
||||||
import com.moparisthebest.rcrdit.tuner.Tuners;
|
import com.moparisthebest.rcrdit.tuner.Tuners;
|
||||||
|
@ -67,9 +68,7 @@ import java.sql.DriverManager;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
@ -124,6 +123,9 @@ public class RcrdIt extends ResourceConfig implements AutoCloseable {
|
||||||
case "HDHomeRun":
|
case "HDHomeRun":
|
||||||
tuners.add(new HDHomerun(tuner.getAttribute("url")));
|
tuners.add(new HDHomerun(tuner.getAttribute("url")));
|
||||||
break;
|
break;
|
||||||
|
case "Dummy":
|
||||||
|
tuners.add(new DummyTuner());
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("unknown tuner type");
|
throw new IllegalArgumentException("unknown tuner type");
|
||||||
}
|
}
|
||||||
|
@ -362,6 +364,14 @@ public class RcrdIt extends ResourceConfig implements AutoCloseable {
|
||||||
log.debug("Database connected!");
|
log.debug("Database connected!");
|
||||||
final Map<Integer, Profile> profileMap = qm.toMap("SELECT profile_id, name, folder, run_at_recording_start, run_at_recording_finish FROM profile", new HashMap<>(), Integer.class, Profile.class);
|
final Map<Integer, Profile> profileMap = qm.toMap("SELECT profile_id, name, folder, run_at_recording_start, run_at_recording_finish FROM profile", new HashMap<>(), Integer.class, Profile.class);
|
||||||
//System.out.println(profileMap);
|
//System.out.println(profileMap);
|
||||||
|
/*
|
||||||
|
try(java.sql.ResultSet rs = qm.toResultSet("SELECT profile_id, priority, title, channel_name, days_of_week AS daysOfWeekString, between_time_start AS betweenTimeStartTime, between_time_end AS betweenTimeEndTime, time_min AS timeMinDate, time_max AS timeMaxDate FROM autorecs")) {
|
||||||
|
for(int x = 1; x <= rs.getMetaData().getColumnCount(); ++x) {
|
||||||
|
System.out.println(rs.getMetaData().getColumnName(x));
|
||||||
|
System.out.println(rs.getMetaData().getColumnLabel(x));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
autoRecs.clear();
|
autoRecs.clear();
|
||||||
qm.toCollection("SELECT profile_id, priority, title, channel_name, days_of_week, between_time_start, between_time_end, time_min, time_max FROM autorecs", autoRecs, AutoRec.class);
|
qm.toCollection("SELECT profile_id, priority, title, channel_name, days_of_week, between_time_start, between_time_end, time_min, time_max FROM autorecs", autoRecs, AutoRec.class);
|
||||||
autoRecs.forEach(a -> a.setProfile(profileMap.get(a.getProfileId())));
|
autoRecs.forEach(a -> a.setProfile(profileMap.get(a.getProfileId())));
|
||||||
|
@ -505,12 +515,12 @@ public class RcrdIt extends ResourceConfig implements AutoCloseable {
|
||||||
+ "VALUES (NULL, ?, ?, ?, ?, NULL, ?,?, from_unixtime(?), from_unixtime(?))";
|
+ "VALUES (NULL, ?, ?, ?, ?, NULL, ?,?, from_unixtime(?), from_unixtime(?))";
|
||||||
Long startDate = null;
|
Long startDate = null;
|
||||||
Long endDate = null;
|
Long endDate = null;
|
||||||
//if(recordingRequest.getStartDateEpochSeconds() != null)startDate = recordingRequest.getStartDateEpochSeconds();
|
if(recordingRequest.getStartDateEpochSeconds() != null)startDate = recordingRequest.getStartDateEpochSeconds();
|
||||||
//if(recordingRequest.getEndDateEpochSeconds() != null)endDate = recordingRequest.getEndDateEpochSeconds();
|
if(recordingRequest.getEndDateEpochSeconds() != null)endDate = recordingRequest.getEndDateEpochSeconds();
|
||||||
String startTime = null;
|
String startTime = null;
|
||||||
String endTime = null;
|
String endTime = null;
|
||||||
//if(recordingRequest.getStartTime() != null)startTime = recordingRequest.getStartTime().trim();
|
if(recordingRequest.getStartTime() != null)startTime = recordingRequest.getStartTime().trim();
|
||||||
//if(recordingRequest.getStopTime()!= null)endTime = recordingRequest.getStopTime().trim();
|
if(recordingRequest.getStopTime()!= null)endTime = recordingRequest.getStopTime().trim();
|
||||||
qm.executeUpdate(sql, recordingRequest.getProfileNo(),recordingRequest.getPriority(),recordingRequest.getTitle(),recordingRequest.getChannelName(),startTime,endTime,startDate,endDate);
|
qm.executeUpdate(sql, recordingRequest.getProfileNo(),recordingRequest.getPriority(),recordingRequest.getTitle(),recordingRequest.getChannelName(),startTime,endTime,startDate,endDate);
|
||||||
timer.schedule(new AutoRecTask(), 0);
|
timer.schedule(new AutoRecTask(), 0);
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
|
|
|
@ -27,10 +27,7 @@ import java.time.DayOfWeek;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.util.Arrays;
|
import java.util.*;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@ -42,10 +39,9 @@ public class AutoRec implements Comparable<AutoRec>, Finishable {
|
||||||
private final int profileId, priority;
|
private final int profileId, priority;
|
||||||
private Pattern titlePattern;
|
private Pattern titlePattern;
|
||||||
private final String title, channelName;
|
private final String title, channelName;
|
||||||
private String daysOfWeekString;
|
|
||||||
private Set<DayOfWeek> daysOfWeek;
|
private Set<DayOfWeek> daysOfWeek;
|
||||||
private final LocalTime betweenTimeStart, betweenTimeEnd;
|
private LocalTime betweenTimeStart, betweenTimeEnd;
|
||||||
private final Instant timeMin, timeMax;
|
private Instant timeMin, timeMax;
|
||||||
|
|
||||||
public AutoRec(final int profileId, final int priority, final String title, final String channelName, final Set<DayOfWeek> daysOfWeek, final LocalTime betweenTimeStart, final LocalTime betweenTimeEnd, final Instant timeMin, final Instant timeMax) {
|
public AutoRec(final int profileId, final int priority, final String title, final String channelName, final Set<DayOfWeek> daysOfWeek, final LocalTime betweenTimeStart, final LocalTime betweenTimeEnd, final Instant timeMin, final Instant timeMax) {
|
||||||
this.profileId = profileId;
|
this.profileId = profileId;
|
||||||
|
@ -67,8 +63,6 @@ public class AutoRec implements Comparable<AutoRec>, Finishable {
|
||||||
@Override
|
@Override
|
||||||
public void finish(final ResultSet rs) throws SQLException {
|
public void finish(final ResultSet rs) throws SQLException {
|
||||||
this.titlePattern = this.title == null ? null : Pattern.compile(this.title);
|
this.titlePattern = this.title == null ? null : Pattern.compile(this.title);
|
||||||
this.daysOfWeek = daysOfWeekString == null || daysOfWeekString.trim().isEmpty() ? null : Arrays.stream(daysOfWeekString.split(",")).map(s -> DayOfWeek.of(Integer.parseInt(s))).collect(Collectors.toSet());
|
|
||||||
this.daysOfWeekString = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean matches(final Program program) {
|
public boolean matches(final Program program) {
|
||||||
|
@ -105,6 +99,26 @@ public class AutoRec implements Comparable<AutoRec>, Finishable {
|
||||||
return Integer.compare(o.priority, this.priority);
|
return Integer.compare(o.priority, this.priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setDaysOfWeek(final String daysOfWeek) {
|
||||||
|
this.daysOfWeek = daysOfWeek == null || daysOfWeek.trim().isEmpty() ? null : Arrays.stream(daysOfWeek.split(",")).map(s -> DayOfWeek.of(Integer.parseInt(s))).collect(Collectors.toSet());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBetweenTimeStart(final java.sql.Time betweenTimeStart) {
|
||||||
|
this.betweenTimeStart = betweenTimeStart == null ? null : betweenTimeStart.toLocalTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBetweenTimeEnd(final java.sql.Time betweenTimeEnd) {
|
||||||
|
this.betweenTimeEnd = betweenTimeEnd == null ? null : betweenTimeEnd.toLocalTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimeMin(final Date timeMin) {
|
||||||
|
this.timeMin = timeMin == null ? null : timeMin.toInstant();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimeMax(final Date timeMax) {
|
||||||
|
this.timeMax = timeMax == null ? null : timeMax.toInstant();
|
||||||
|
}
|
||||||
|
|
||||||
public Profile getProfile() {
|
public Profile getProfile() {
|
||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
/*
|
||||||
|
* rcrdit records TV programs from TV tuners
|
||||||
|
* Copyright (C) 2017 Travis Burtrum
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.moparisthebest.rcrdit.tuner;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mainly used for debugging what would record
|
||||||
|
*/
|
||||||
|
public class DummyTuner extends AbstractTuner {
|
||||||
|
}
|
Loading…
Reference in New Issue