diff --git a/database.sql b/database.mysql.sql similarity index 100% rename from database.sql rename to database.mysql.sql diff --git a/database.postgre.sql b/database.postgre.sql new file mode 100644 index 0000000..74226b7 --- /dev/null +++ b/database.postgre.sql @@ -0,0 +1,25 @@ + +-- you can migrate from mysql to postgresql by doing this: +-- podman run --rm -it -v /run/postgresql:/run/postgresql ghcr.io/dimitri/pgloader:latest pgloader mysql://rcrdit:rcrdit@10.16.19.1:3306/rcrdit postgresql://rcrdit:rcrdit@unix:/run/postgresql:5432/rcrdit + + +CREATE TABLE "profile" ( + "profile_id" SERIAL PRIMARY KEY, + "name" character varying(64) NOT NULL, + "folder" character varying(64) NOT NULL, + "run_at_recording_start" character varying(64), + "run_at_recording_finish" character varying(64) +); + +CREATE TABLE "autorecs" ( + "autorec_id" SERIAL PRIMARY KEY, + "profile_id" int NOT NULL, + "priority" int DEFAULT '5' NOT NULL, + "title" character varying(256), + "channel_name" character varying(64), + "days_of_week" character varying(64), + "between_time_start" time without time zone, + "between_time_end" time without time zone, + "time_min" timestamptz, + "time_max" timestamptz +); diff --git a/pom.xml b/pom.xml index f44e8e0..9fbc204 100755 --- a/pom.xml +++ b/pom.xml @@ -95,6 +95,20 @@ 6.0.5 runtime + + org.postgresql + postgresql + 42.6.0 + runtime + + + + com.kohlschutter.junixsocket + junixsocket-core + 2.5.1 + pom + runtime + diff --git a/rcrdit.cfg.example.xml b/rcrdit.cfg.example.xml index 9c2e962..0a91794 100644 --- a/rcrdit.cfg.example.xml +++ b/rcrdit.cfg.example.xml @@ -18,7 +18,10 @@ - + jdbc:mysql://localhost:3306/rcrdit?user=rcrdit&password=rcrdit&serverTimezone=America/New_York http://localhost:8080/rcrdit/ diff --git a/readme.md b/readme.md index f4e9235..2415de5 100644 --- a/readme.md +++ b/readme.md @@ -13,6 +13,7 @@ Configure your TV tuner(s) by editing rcrdit.cfg.example.xml, compile the projec project with `java -jar target/rcrdit.jar` rcrdit.ics is generated on every schedule import which when imported to a calendar program like thunderbird can easily -show which shows will be recorded when and which will be skipped depeding on priority. +show which shows will be recorded when and which will be skipped depending on priority. -A web interface is coming soon. \ No newline at end of file +A web interface is included which shows the schedule and allows you to schedule recordings. Profiles are still set up +manually in the database. diff --git a/src/main/java/com/moparisthebest/rcrdit/RcrdIt.java b/src/main/java/com/moparisthebest/rcrdit/RcrdIt.java index 84dc60d..e5bca1a 100644 --- a/src/main/java/com/moparisthebest/rcrdit/RcrdIt.java +++ b/src/main/java/com/moparisthebest/rcrdit/RcrdIt.java @@ -581,12 +581,12 @@ public class RcrdIt extends ResourceConfig implements AutoCloseable { try (Connection conn = DriverManager.getConnection(databaseUrl); QueryMapper qm = new QueryMapper(conn)) { - String sql = "INSERT INTO autorecs (autorec_id, profile_id, priority, title, channel_name, days_of_week, between_time_start, between_time_end, time_min, time_max) " - + "VALUES (NULL, ?, ?, ?, ?, NULL, ?,?, from_unixtime(?), from_unixtime(?))"; - Long startDate = null; - Long endDate = null; - if(recordingRequest.getStartDateEpochSeconds() != null)startDate = recordingRequest.getStartDateEpochSeconds(); - if(recordingRequest.getEndDateEpochSeconds() != null)endDate = recordingRequest.getEndDateEpochSeconds(); + String sql = "INSERT INTO autorecs (profile_id, priority, title, channel_name, days_of_week, between_time_start, between_time_end, time_min, time_max) " + + "VALUES (?, ?, ?, ?, NULL, ?, ?, ?, ?)"; + java.sql.Timestamp startDate = null; + java.sql.Timestamp endDate = null; + if(recordingRequest.getStartDateEpochSeconds() != null)startDate = new Timestamp(recordingRequest.getStartDateEpochSeconds() * 1000); + if(recordingRequest.getEndDateEpochSeconds() != null)endDate = new Timestamp(recordingRequest.getEndDateEpochSeconds() * 1000); String startTime = null; String endTime = null; if(recordingRequest.getStartTime() != null)startTime = recordingRequest.getStartTime().trim(); diff --git a/src/main/resources/META-INF/services/java.sql.Driver b/src/main/resources/META-INF/services/java.sql.Driver new file mode 100644 index 0000000..c0e3c86 --- /dev/null +++ b/src/main/resources/META-INF/services/java.sql.Driver @@ -0,0 +1,2 @@ +org.postgresql.Driver +com.mysql.cj.jdbc.Driver