Fix Podcast.js indentation

This commit is contained in:
Marcos Carvalho 2023-10-03 22:42:34 +01:00 committed by GitHub
parent 309f5ef5e3
commit 56ff12eaaf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,171 +1,171 @@
const {DataTypes, Model} = require('sequelize') const { DataTypes, Model } = require('sequelize')
class Podcast extends Model { class Podcast extends Model {
constructor(values, options) { constructor(values, options) {
super(values, options) super(values, options)
/** @type {string} */ /** @type {string} */
this.id this.id
/** @type {string} */ /** @type {string} */
this.title this.title
/** @type {string} */ /** @type {string} */
this.titleIgnorePrefix this.titleIgnorePrefix
/** @type {string} */ /** @type {string} */
this.author this.author
/** @type {string} */ /** @type {string} */
this.releaseDate this.releaseDate
/** @type {string} */ /** @type {string} */
this.feedURL this.feedURL
/** @type {string} */ /** @type {string} */
this.imageURL this.imageURL
/** @type {string} */ /** @type {string} */
this.description this.description
/** @type {string} */ /** @type {string} */
this.itunesPageURL this.itunesPageURL
/** @type {string} */ /** @type {string} */
this.itunesId this.itunesId
/** @type {string} */ /** @type {string} */
this.itunesArtistId this.itunesArtistId
/** @type {string} */ /** @type {string} */
this.language this.language
/** @type {string} */ /** @type {string} */
this.podcastType this.podcastType
/** @type {boolean} */ /** @type {boolean} */
this.explicit this.explicit
/** @type {boolean} */ /** @type {boolean} */
this.autoDownloadEpisodes this.autoDownloadEpisodes
/** @type {string} */ /** @type {string} */
this.autoDownloadSchedule this.autoDownloadSchedule
/** @type {Date} */ /** @type {Date} */
this.lastEpisodeCheck this.lastEpisodeCheck
/** @type {number} */ /** @type {number} */
this.maxEpisodesToKeep this.maxEpisodesToKeep
/** @type {string} */ /** @type {string} */
this.coverPath this.coverPath
/** @type {string[]} */ /** @type {string[]} */
this.tags this.tags
/** @type {string[]} */ /** @type {string[]} */
this.genres this.genres
/** @type {Date} */ /** @type {Date} */
this.createdAt this.createdAt
/** @type {Date} */ /** @type {Date} */
this.updatedAt this.updatedAt
/** @type {Date} */ /** @type {Date} */
this.lastSuccessfulFetchAt this.lastSuccessfulFetchAt
/** @type {boolean} */ /** @type {boolean} */
this.feedHealthy this.feedHealthy
}
static getOldPodcast(libraryItemExpanded) {
const podcastExpanded = libraryItemExpanded.media
const podcastEpisodes = podcastExpanded.podcastEpisodes?.map(ep => ep.getOldPodcastEpisode(libraryItemExpanded.id).toJSON()).sort((a, b) => a.index - b.index)
return {
id: podcastExpanded.id,
libraryItemId: libraryItemExpanded.id,
metadata: {
title: podcastExpanded.title,
author: podcastExpanded.author,
description: podcastExpanded.description,
releaseDate: podcastExpanded.releaseDate,
genres: podcastExpanded.genres,
feedUrl: podcastExpanded.feedURL,
imageUrl: podcastExpanded.imageURL,
itunesPageUrl: podcastExpanded.itunesPageURL,
itunesId: podcastExpanded.itunesId,
itunesArtistId: podcastExpanded.itunesArtistId,
explicit: podcastExpanded.explicit,
language: podcastExpanded.language,
type: podcastExpanded.podcastType,
lastSuccessfulFetchAt: podcastExpanded.lastSuccessfulFetchAt?.valueOf() || null,
feedHealthy: !!podcastExpanded.feedHealthy
},
coverPath: podcastExpanded.coverPath,
tags: podcastExpanded.tags,
episodes: podcastEpisodes || [],
autoDownloadEpisodes: podcastExpanded.autoDownloadEpisodes,
autoDownloadSchedule: podcastExpanded.autoDownloadSchedule,
lastEpisodeCheck: podcastExpanded.lastEpisodeCheck?.valueOf() || null,
maxEpisodesToKeep: podcastExpanded.maxEpisodesToKeep,
maxNewEpisodesToDownload: podcastExpanded.maxNewEpisodesToDownload
} }
}
static getOldPodcast(libraryItemExpanded) { static getFromOld(oldPodcast) {
const podcastExpanded = libraryItemExpanded.media const oldPodcastMetadata = oldPodcast.metadata
const podcastEpisodes = podcastExpanded.podcastEpisodes?.map(ep => ep.getOldPodcastEpisode(libraryItemExpanded.id).toJSON()).sort((a, b) => a.index - b.index) return {
return { id: oldPodcast.id,
id: podcastExpanded.id, title: oldPodcastMetadata.title,
libraryItemId: libraryItemExpanded.id, titleIgnorePrefix: oldPodcastMetadata.titleIgnorePrefix,
metadata: { author: oldPodcastMetadata.author,
title: podcastExpanded.title, releaseDate: oldPodcastMetadata.releaseDate,
author: podcastExpanded.author, feedURL: oldPodcastMetadata.feedUrl,
description: podcastExpanded.description, imageURL: oldPodcastMetadata.imageUrl,
releaseDate: podcastExpanded.releaseDate, description: oldPodcastMetadata.description,
genres: podcastExpanded.genres, itunesPageURL: oldPodcastMetadata.itunesPageUrl,
feedUrl: podcastExpanded.feedURL, itunesId: oldPodcastMetadata.itunesId,
imageUrl: podcastExpanded.imageURL, itunesArtistId: oldPodcastMetadata.itunesArtistId,
itunesPageUrl: podcastExpanded.itunesPageURL, language: oldPodcastMetadata.language,
itunesId: podcastExpanded.itunesId, podcastType: oldPodcastMetadata.type,
itunesArtistId: podcastExpanded.itunesArtistId, explicit: !!oldPodcastMetadata.explicit,
explicit: podcastExpanded.explicit, autoDownloadEpisodes: !!oldPodcast.autoDownloadEpisodes,
language: podcastExpanded.language, autoDownloadSchedule: oldPodcast.autoDownloadSchedule,
type: podcastExpanded.podcastType, lastEpisodeCheck: oldPodcast.lastEpisodeCheck,
lastSuccessfulFetchAt: podcastExpanded.lastSuccessfulFetchAt?.valueOf() || null, maxEpisodesToKeep: oldPodcast.maxEpisodesToKeep,
feedHealthy: !!podcastExpanded.feedHealthy maxNewEpisodesToDownload: oldPodcast.maxNewEpisodesToDownload,
}, coverPath: oldPodcast.coverPath,
coverPath: podcastExpanded.coverPath, tags: oldPodcast.tags,
tags: podcastExpanded.tags, genres: oldPodcastMetadata.genres,
episodes: podcastEpisodes || [], lastSuccessfulFetchAt: oldPodcastMetadata.lastSuccessfulFetchAt,
autoDownloadEpisodes: podcastExpanded.autoDownloadEpisodes, feedHealthy: !!oldPodcastMetadata.feedHealthy
autoDownloadSchedule: podcastExpanded.autoDownloadSchedule,
lastEpisodeCheck: podcastExpanded.lastEpisodeCheck?.valueOf() || null,
maxEpisodesToKeep: podcastExpanded.maxEpisodesToKeep,
maxNewEpisodesToDownload: podcastExpanded.maxNewEpisodesToDownload
}
} }
}
static getFromOld(oldPodcast) { static async getAllIncomingFeeds() {
const oldPodcastMetadata = oldPodcast.metadata const podcasts = await this.findAll()
return { const podcastsFiltered = podcasts.filter(p => p.dataValues.feedURL !== null);
id: oldPodcast.id, return podcastsFiltered.map(p => this.getOldPodcast({media: p.dataValues}))
title: oldPodcastMetadata.title, }
titleIgnorePrefix: oldPodcastMetadata.titleIgnorePrefix,
author: oldPodcastMetadata.author,
releaseDate: oldPodcastMetadata.releaseDate,
feedURL: oldPodcastMetadata.feedUrl,
imageURL: oldPodcastMetadata.imageUrl,
description: oldPodcastMetadata.description,
itunesPageURL: oldPodcastMetadata.itunesPageUrl,
itunesId: oldPodcastMetadata.itunesId,
itunesArtistId: oldPodcastMetadata.itunesArtistId,
language: oldPodcastMetadata.language,
podcastType: oldPodcastMetadata.type,
explicit: !!oldPodcastMetadata.explicit,
autoDownloadEpisodes: !!oldPodcast.autoDownloadEpisodes,
autoDownloadSchedule: oldPodcast.autoDownloadSchedule,
lastEpisodeCheck: oldPodcast.lastEpisodeCheck,
maxEpisodesToKeep: oldPodcast.maxEpisodesToKeep,
maxNewEpisodesToDownload: oldPodcast.maxNewEpisodesToDownload,
coverPath: oldPodcast.coverPath,
tags: oldPodcast.tags,
genres: oldPodcastMetadata.genres,
lastSuccessfulFetchAt: oldPodcastMetadata.lastSuccessfulFetchAt,
feedHealthy: !!oldPodcastMetadata.feedHealthy
}
}
static async getAllIncomingFeeds() { /**
const podcasts = await this.findAll() * Initialize model
const podcastsFiltered = podcasts.filter(p => p.dataValues.feedURL !== null); * @param {import('../Database').sequelize} sequelize
return podcastsFiltered.map(p => this.getOldPodcast({media: p.dataValues})) */
} static init(sequelize) {
super.init({
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true
},
title: DataTypes.STRING,
titleIgnorePrefix: DataTypes.STRING,
author: DataTypes.STRING,
releaseDate: DataTypes.STRING,
feedURL: DataTypes.STRING,
imageURL: DataTypes.STRING,
description: DataTypes.TEXT,
itunesPageURL: DataTypes.STRING,
itunesId: DataTypes.STRING,
itunesArtistId: DataTypes.STRING,
language: DataTypes.STRING,
podcastType: DataTypes.STRING,
explicit: DataTypes.BOOLEAN,
/** autoDownloadEpisodes: DataTypes.BOOLEAN,
* Initialize model autoDownloadSchedule: DataTypes.STRING,
* @param {import('../Database').sequelize} sequelize lastEpisodeCheck: DataTypes.DATE,
*/ maxEpisodesToKeep: DataTypes.INTEGER,
static init(sequelize) { maxNewEpisodesToDownload: DataTypes.INTEGER,
super.init({ coverPath: DataTypes.STRING,
id: { tags: DataTypes.JSON,
type: DataTypes.UUID, genres: DataTypes.JSON,
defaultValue: DataTypes.UUIDV4, lastSuccessfulFetchAt: DataTypes.DATE,
primaryKey: true feedHealthy: DataTypes.BOOLEAN
}, }, {
title: DataTypes.STRING, sequelize,
titleIgnorePrefix: DataTypes.STRING, modelName: 'podcast'
author: DataTypes.STRING, })
releaseDate: DataTypes.STRING, }
feedURL: DataTypes.STRING,
imageURL: DataTypes.STRING,
description: DataTypes.TEXT,
itunesPageURL: DataTypes.STRING,
itunesId: DataTypes.STRING,
itunesArtistId: DataTypes.STRING,
language: DataTypes.STRING,
podcastType: DataTypes.STRING,
explicit: DataTypes.BOOLEAN,
autoDownloadEpisodes: DataTypes.BOOLEAN,
autoDownloadSchedule: DataTypes.STRING,
lastEpisodeCheck: DataTypes.DATE,
maxEpisodesToKeep: DataTypes.INTEGER,
maxNewEpisodesToDownload: DataTypes.INTEGER,
coverPath: DataTypes.STRING,
tags: DataTypes.JSON,
genres: DataTypes.JSON,
lastSuccessfulFetchAt: DataTypes.DATE,
feedHealthy: DataTypes.BOOLEAN
}, {
sequelize,
modelName: 'podcast'
})
}
} }
module.exports = Podcast module.exports = Podcast