1
0
mirror of https://github.com/moparisthebest/rcrdit synced 2024-12-22 07:18:56 -05:00

Now works on postgresql and mysql/mariadb

This commit is contained in:
Travis Burtrum 2023-03-31 00:27:11 -04:00
parent bcbca03ffb
commit 111b7e255b
7 changed files with 54 additions and 9 deletions

25
database.postgre.sql Normal file
View File

@ -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
);

14
pom.xml
View File

@ -95,6 +95,20 @@
<version>6.0.5</version> <version>6.0.5</version>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.6.0</version>
<scope>runtime</scope>
</dependency>
<!-- needed for postgres unix socket -->
<dependency>
<groupId>com.kohlschutter.junixsocket</groupId>
<artifactId>junixsocket-core</artifactId>
<version>2.5.1</version>
<type>pom</type>
<scope>runtime</scope>
</dependency>
<!-- logging --> <!-- logging -->
<dependency> <dependency>

View File

@ -18,7 +18,10 @@
<!-- rename this to rcrdit.cfg.xml and pass it's path in as an argument --> <!-- rename this to rcrdit.cfg.xml and pass it's path in as an argument -->
<rcrdit> <rcrdit>
<!-- jdbc database path, sqlite/postgresql/oracle/anything jdbc should work too if proper libraries are available --> <!-- jdbc database path, sqlite/postgresql/oracle/anything jdbc should work too if proper libraries are available
postgres connecting to unix socket looks like:
<databaseUrl>jdbc:postgresql://localhost/rcrdit?user=rcrdit&amp;password=rcrdit&amp;serverTimezone=America/New_York&amp;socketFactory=org.newsclub.net.unix.AFUNIXSocketFactory$FactoryArg&amp;socketFactoryArg=/run/postgresql/.s.PGSQL.5432</databaseUrl>
-->
<databaseUrl>jdbc:mysql://localhost:3306/rcrdit?user=rcrdit&amp;password=rcrdit&amp;serverTimezone=America/New_York</databaseUrl> <databaseUrl>jdbc:mysql://localhost:3306/rcrdit?user=rcrdit&amp;password=rcrdit&amp;serverTimezone=America/New_York</databaseUrl>
<!-- server uri (context path and port) for web application --> <!-- server uri (context path and port) for web application -->
<serverUri>http://localhost:8080/rcrdit/</serverUri> <serverUri>http://localhost:8080/rcrdit/</serverUri>

View File

@ -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` 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 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. A web interface is included which shows the schedule and allows you to schedule recordings. Profiles are still set up
manually in the database.

View File

@ -581,12 +581,12 @@ public class RcrdIt extends ResourceConfig implements AutoCloseable {
try (Connection conn = DriverManager.getConnection(databaseUrl); try (Connection conn = DriverManager.getConnection(databaseUrl);
QueryMapper qm = new QueryMapper(conn)) { 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) " 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, ?, ?, ?, ?, NULL, ?,?, from_unixtime(?), from_unixtime(?))"; + "VALUES (?, ?, ?, ?, NULL, ?, ?, ?, ?)";
Long startDate = null; java.sql.Timestamp startDate = null;
Long endDate = null; java.sql.Timestamp endDate = null;
if(recordingRequest.getStartDateEpochSeconds() != null)startDate = recordingRequest.getStartDateEpochSeconds(); if(recordingRequest.getStartDateEpochSeconds() != null)startDate = new Timestamp(recordingRequest.getStartDateEpochSeconds() * 1000);
if(recordingRequest.getEndDateEpochSeconds() != null)endDate = recordingRequest.getEndDateEpochSeconds(); if(recordingRequest.getEndDateEpochSeconds() != null)endDate = new Timestamp(recordingRequest.getEndDateEpochSeconds() * 1000);
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();

View File

@ -0,0 +1,2 @@
org.postgresql.Driver
com.mysql.cj.jdbc.Driver