Add support for Itunes

This commit is contained in:
Joakim Hellsén 2024-02-18 05:07:30 +01:00
commit f73a36c1c8
15 changed files with 883 additions and 51 deletions

View file

@ -449,3 +449,157 @@ LIMIT
$2
OFFSET
$3;
-- name: CreateFeedItunes :one
INSERT INTO
feed_itunes (
created_at,
updated_at,
deleted_at,
author,
"block",
"explicit",
keywords,
subtitle,
summary,
"image",
complete,
new_feed_url,
"type",
feed_id
)
VALUES
(
$1,
$2,
$3,
$4,
$5,
$6,
$7,
$8,
$9,
$10,
$11,
$12,
$13,
$14
)
RETURNING
*;
-- name: CreateItemItunes :one
INSERT INTO
item_itunes (
created_at,
updated_at,
deleted_at,
author,
"block",
"explicit",
keywords,
subtitle,
summary,
"image",
is_closed_captioned,
episode,
season,
"order",
episode_type,
item_id
)
VALUES
(
$1,
$2,
$3,
$4,
$5,
$6,
$7,
$8,
$9,
$10,
$11,
$12,
$13,
$14,
$15,
$16
)
RETURNING
*;
-- name: GetFeedItunes :one
SELECT
*
FROM
feed_itunes
WHERE
feed_id = $1;
-- name: GetItemItunes :one
SELECT
*
FROM
item_itunes
WHERE
item_id = $1;
-- name: CreateFeedItunesCategory :one
INSERT INTO
feed_itunes_categories (
created_at,
updated_at,
deleted_at,
"text",
subcategory,
itunes_id
)
VALUES
($1, $2, $3, $4, $5, $6)
RETURNING
*;
-- name: CreateFeedItunesOwner :one
INSERT INTO
feed_itunes_owners (
created_at,
updated_at,
deleted_at,
email,
"name",
itunes_id
)
VALUES
($1, $2, $3, $4, $5, $6)
RETURNING
*;
-- name: GetFeedItunesCategories :many
SELECT
*
FROM
feed_itunes_categories
WHERE
itunes_id = $1
ORDER BY
created_at DESC
LIMIT
$2
OFFSET
$3;
-- name: GetFeedItunesOwners :many
SELECT
*
FROM
feed_itunes_owners
WHERE
itunes_id = $1
ORDER BY
created_at DESC
LIMIT
$2
OFFSET
$3;

View file

@ -66,8 +66,8 @@ CREATE TABLE IF NOT EXISTS items (
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
DROP TABLE IF EXISTS feeds;
DROP TABLE IF EXISTS feeds CASCADE;
DROP TABLE IF EXISTS items;
DROP TABLE IF EXISTS items CASCADE;
-- +goose StatementEnd

View file

@ -37,8 +37,8 @@ CREATE TABLE IF NOT EXISTS item_extensions (
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
DROP TABLE IF EXISTS feed_extensions;
DROP TABLE IF EXISTS feed_extensions CASCADE;
DROP TABLE IF EXISTS item_extensions;
DROP TABLE IF EXISTS item_extensions CASCADE;
-- +goose StatementEnd

View file

@ -33,8 +33,8 @@ CREATE TABLE IF NOT EXISTS item_authors (
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
DROP TABLE IF EXISTS feed_authors;
DROP TABLE IF EXISTS feed_authors CASCADE;
DROP TABLE IF EXISTS item_authors;
DROP TABLE IF EXISTS item_authors CASCADE;
-- +goose StatementEnd

View file

@ -33,8 +33,8 @@ CREATE TABLE IF NOT EXISTS item_images (
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
DROP TABLE IF EXISTS feed_images;
DROP TABLE IF EXISTS feed_images CASCADE;
DROP TABLE IF EXISTS item_images;
DROP TABLE IF EXISTS item_images CASCADE;
-- +goose StatementEnd

View file

@ -61,8 +61,8 @@ CREATE TABLE IF NOT EXISTS item_dublin_cores (
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
DROP TABLE IF EXISTS feed_dublin_cores;
DROP TABLE IF EXISTS feed_dublin_cores CASCADE;
DROP TABLE IF EXISTS item_dublin_cores;
DROP TABLE IF EXISTS item_dublin_cores CASCADE;
-- +goose StatementEnd

View file

@ -10,9 +10,10 @@ CREATE TABLE IF NOT EXISTS feed_itunes (
-- From gofeed:
author TEXT,
"block" TEXT,
-- Categories - See feed_itunes_categories
"explicit" TEXT,
keywords TEXT,
-- Owner
-- Owner - See feed_itunes_owners
subtitle TEXT,
summary TEXT,
"image" TEXT,
@ -50,24 +51,25 @@ CREATE TABLE IF NOT EXISTS item_itunes (
CONSTRAINT fk_item_id FOREIGN KEY (item_id) REFERENCES items (id) ON DELETE CASCADE
);
-- Itunes categories
-- Itunes categories for feeds
-- https://github.com/mmcdole/gofeed/blob/master/extensions/itunes.go#L39
CREATE TABLE IF NOT EXISTS itunes_categories (
CREATE TABLE IF NOT EXISTS feed_itunes_categories (
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
deleted_at TIMESTAMPTZ DEFAULT NULL,
-- From gofeed:
"text" TEXT,
subcategory TEXT,
subcategory BIGINT,
-- Link to itunes
itunes_id BIGINT NOT NULL,
CONSTRAINT fk_itunes_id FOREIGN KEY (itunes_id) REFERENCES feed_itunes (id) ON DELETE CASCADE
CONSTRAINT fk_itunes_id FOREIGN KEY (itunes_id) REFERENCES feed_itunes (id) ON DELETE CASCADE,
CONSTRAINT fk_subcategory_id FOREIGN KEY (subcategory) REFERENCES feed_itunes_categories (id) ON DELETE SET NULL
);
-- Itunes owners
-- https://github.com/mmcdole/gofeed/blob/master/extensions/itunes.go#L45
CREATE TABLE IF NOT EXISTS itunes_owners (
CREATE TABLE IF NOT EXISTS feed_itunes_owners (
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
@ -83,12 +85,12 @@ CREATE TABLE IF NOT EXISTS itunes_owners (
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
DROP TABLE IF EXISTS feed_itunes;
DROP TABLE IF EXISTS feed_itunes CASCADE;
DROP TABLE IF EXISTS item_itunes;
DROP TABLE IF EXISTS item_itunes CASCADE;
DROP TABLE IF EXISTS itunes_categories;
DROP TABLE IF EXISTS feed_itunes_categories CASCADE;
DROP TABLE IF EXISTS itunes_owners;
DROP TABLE IF EXISTS feed_itunes_owners CASCADE;
-- +goose StatementEnd

View file

@ -1,6 +1,6 @@
-- +goose Up
-- +goose StatementBegin
-- Enclosures
-- Enclosures - Only for items
-- https://github.com/mmcdole/gofeed/blob/master/feed.go#L86
CREATE TABLE IF NOT EXISTS enclosures (
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
@ -19,6 +19,6 @@ CREATE TABLE IF NOT EXISTS enclosures (
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
DROP TABLE IF EXISTS enclosures;
DROP TABLE IF EXISTS enclosures CASCADE;
-- +goose StatementEnd