main
Thomas Hintz 2 years ago
parent 2282b844b1
commit 7b2f5d0228

@ -84,13 +84,14 @@ export const EpisodeShow = (props) => (
<TextField source="title" /> <TextField source="title" />
<NumberField source="season" /> <NumberField source="season" />
<NumberField source="episode" /> <NumberField source="episode" />
<NumberField source="duration" />
<TextField source="slug" /> <TextField source="slug" />
<TextField source="episode_type" /> <TextField source="episode_type" />
<TextField source="buzzsprout_id" /> <TextField source="buzzsprout_id" />
<UrlField source="buzzsprout_url" /> <UrlField source="buzzsprout_url" />
<UrlField source="youtube_url" /> <UrlField source="youtube_url" />
<UrlField source="audio_url" /> <UrlField source="audio_url" />
<NumberField source="duration" label="Duration (seconds)" />
<NumberField source="audio_size" label="Size (bytes)" />
<FileField source="transcript_filename" title="transcript_filename" /> <FileField source="transcript_filename" title="transcript_filename" />
<DateField source="pub_date" showTime={true} /> <DateField source="pub_date" showTime={true} />
<RichTextField source="content" /> <RichTextField source="content" />
@ -100,26 +101,44 @@ export const EpisodeShow = (props) => (
); );
export const EpisodeEdit = () => { export const EpisodeEdit = () => {
return ( const { data: transcriptFiles } = useGetList(
<Edit> 'transcript_files'
<SimpleForm>
<TextInput source="number" />
<TextInput source="title" />
<NumberInput source="season" />
<NumberInput source="episode" />
<TextInput source="slug" />
<TextInput source="episode_type" />
<TextInput source="buzzsprout_id" />
<TextInput source="buzzsprout_url" />
<TextInput source="youtube_url" />
<TextInput source="audio_url" />
<TextInput source="transcript_filename" />
<DateTimeInput source="pub_date" />
<RichTextInput source="content" />
<TextInput source="summary" />
</SimpleForm>
</Edit>
); );
if (transcriptFiles) {
return (
<Edit>
<SimpleForm>
<TextInput source="number" />
<TextInput source="title" fullWidth />
<NumberInput source="season" />
<NumberInput source="episode" />
<TextInput source="slug" fullWidth />
<RadioButtonGroupInput
source="episode_type"
choices={[
{ id: 'full', name: 'full' },
{ id: 'bonus', name: 'bonus' }
]}
/>
<TextInput source="buzzsprout_id" />
<TextInput source="buzzsprout_url" fullWidth />
<TextInput source="youtube_url" fullWidth />
<TextInput source="audio_url" fullWidth />
<NumberInput source="duration" label="Duration (seconds)" />
<NumberInput source="audio_size" label="Size (bytes)" />
<SelectInput
source="transcript_filename"
choices={transcriptFiles.map(x => { return { id: x.filename, name: x.filename } })}
/>
<DateTimeInput source="pub_date" />
<RichTextInput source="content" />
<TextInput source="summary" fullWidth />
</SimpleForm>
</Edit>
);
} else {
return null;
}
}; };
function listElement(arr, proc) { function listElement(arr, proc) {
@ -171,6 +190,8 @@ export const EpisodeCreate = () => {
<TextInput source="buzzsprout_url" fullWidth /> <TextInput source="buzzsprout_url" fullWidth />
<TextInput source="youtube_url" fullWidth /> <TextInput source="youtube_url" fullWidth />
<TextInput source="audio_url" fullWidth /> <TextInput source="audio_url" fullWidth />
<NumberInput source="audio_size" label="Size (bytes)" />
<NumberInput source="duration" label="Duration (seconds)" />
<SelectInput <SelectInput
source="transcript_filename" source="transcript_filename"
choices={transcriptFiles.map(x => { return { id: x.filename, name: x.filename } })} choices={transcriptFiles.map(x => { return { id: x.filename, name: x.filename } })}

@ -73,6 +73,11 @@ foreign key (user_id) references users (id)
key: 8, key: 8,
name: 'add audio url column', name: 'add audio url column',
sql: [`alter table episodes add column audio_url text;`] sql: [`alter table episodes add column audio_url text;`]
},
{
key: 9,
name: 'add audio size column',
sql: [`alter table episodes add column audio_size integer;`]
} }
]; ];
@ -117,9 +122,9 @@ const createMigrationTable = `create table migrations (
run boolean not null run boolean not null
)`; )`;
let db = new sqlite3.Database('/db/db.sqlite3', sqlite3.OPEN_READWRITE, async (err) => { let db = new sqlite3.Database(`${process.env.DB_PATH}db.sqlite3`, sqlite3.OPEN_READWRITE, async (err) => {
if (err && err.code == "SQLITE_CANTOPEN") { if (err && err.code == "SQLITE_CANTOPEN") {
db = new sqlite3.Database('./db.sqlite3', async (err) => { db = new sqlite3.Database(`${process.env.DB_PATH}db.sqlite3`, async (err) => {
if (err) { if (err) {
console.log("Getting error " + err); console.log("Getting error " + err);
} }

@ -2,7 +2,7 @@ import db from '@/db';
const COLS = {}; const COLS = {};
const COLS_PREFIXED = {}; const COLS_PREFIXED = {};
const COLS_LIST = ['id', 'number', 'content', 'summary', 'slug', 'season', 'episode', 'duration', 'filename', 'title', 'episode_type', 'buzzsprout_id', 'buzzsprout_url', 'pub_date', 'youtube_url', 'transcript_filename', 'audio_url']; const COLS_LIST = ['id', 'number', 'content', 'summary', 'slug', 'season', 'episode', 'duration', 'filename', 'title', 'episode_type', 'buzzsprout_id', 'buzzsprout_url', 'pub_date', 'youtube_url', 'transcript_filename', 'audio_url', 'audio_size'];
COLS_LIST.forEach((k) => COLS[k] = k) COLS_LIST.forEach((k) => COLS[k] = k)
COLS_LIST.forEach((k) => COLS_PREFIXED[k] = `$${k}`) COLS_LIST.forEach((k) => COLS_PREFIXED[k] = `$${k}`)

@ -11,7 +11,7 @@ const COLUMN_MAP = {
'episode': 'episode' 'episode': 'episode'
}; };
const COLS_LIST = ['number', 'content', 'summary', 'slug', 'season', 'episode', 'duration', 'filename', 'title', 'episode_type', 'buzzsprout_id', 'buzzsprout_url', 'pub_date', 'youtube_url', 'transcript_filename', 'audio_url']; const COLS_LIST = ['number', 'content', 'summary', 'slug', 'season', 'episode', 'duration', 'filename', 'title', 'episode_type', 'buzzsprout_id', 'buzzsprout_url', 'pub_date', 'youtube_url', 'transcript_filename', 'audio_url', 'audio_size'];
export default async function handler(req, res) { export default async function handler(req, res) {
const sessionId = req.cookies?.session; const sessionId = req.cookies?.session;

@ -50,7 +50,7 @@ async function syncEpisodes() {
export default async function handler(req, res) { export default async function handler(req, res) {
if (req.method === 'GET') { if (req.method === 'GET') {
await syncEpisodes(); // await syncEpisodes();
const { uuid: uuidRaw } = req.query; const { uuid: uuidRaw } = req.query;
const uuid = uuidRaw.split('.rss')[0]; const uuid = uuidRaw.split('.rss')[0];
const subExists = await db.get('select id from subscriptions where uuid=?', uuid); const subExists = await db.get('select id from subscriptions where uuid=?', uuid);

Loading…
Cancel
Save