Skip to content

Commit

Permalink
Merge pull request #744 from podverse/develop
Browse files Browse the repository at this point in the history
Release v4.16.13
  • Loading branch information
mitchdowney authored Apr 26, 2024
2 parents fab7977 + ebc4bef commit 02f8458
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 62 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "podverse-api",
"version": "4.16.12",
"version": "4.16.13",
"description": "Data API, database migration scripts, and backend services for all Podverse models.",
"contributors": [
"Mitch Downey"
Expand Down
18 changes: 0 additions & 18 deletions src/controllers/episode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,23 +80,6 @@ const getEpisodeByPodcastIdAndGuid = async (podcastId: string, guid: string) =>
return episode
}

const getEpisodeByPodcastIdAndMediaUrl = async (podcastId: string, mediaUrl: string) => {
const repository = getRepository(Episode)
const episode = await repository.findOne(
{
mediaUrl,
podcastId
},
{ relations }
)

if (!episode || !episode.podcast.isPublic) {
throw new createError.NotFound('Episode not found')
}

return episode
}

// Use where clause to reduce the size of very large data sets and speed up queries
// const limitEpisodesQuerySize = (qb: any, shouldLimit: boolean, sort: string) => {
// if (shouldLimit) {
Expand Down Expand Up @@ -1011,7 +994,6 @@ export {
dropAndRecreateEpisodesMostRecentMaterializedView,
getEpisode,
getEpisodeByPodcastIdAndGuid,
getEpisodeByPodcastIdAndMediaUrl,
getEpisodes,
getEpisodesByCategoryIds,
getEpisodesByPodcastIds,
Expand Down
15 changes: 0 additions & 15 deletions src/controllers/mediaRef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,6 @@ const getMediaRef = async (id) => {
return mediaRef
}

const getPublicMediaRefsByEpisodeMediaUrl = (mediaUrl) => {
return getRepository(MediaRef)
.createQueryBuilder('mediaRef')
.select('mediaRef.id')
.addSelect('mediaRef.startTime')
.addSelect('mediaRef.endTime')
.addSelect('mediaRef.title')
.innerJoin('mediaRef.episode', 'episode')
.where('episode.mediaUrl = :mediaUrl', { mediaUrl })
.andWhere('mediaRef.isPublic = TRUE')
.orderBy('mediaRef.startTime', 'ASC')
.getManyAndCount()
}

const getPublicMediaRefsByEpisodeGuid = (episodeGuid, podcastId) => {
return getRepository(MediaRef)
.createQueryBuilder('mediaRef')
Expand Down Expand Up @@ -392,7 +378,6 @@ export {
getMediaRef,
getMediaRefs,
getMediaRefsFromSearchEngine,
getPublicMediaRefsByEpisodeMediaUrl,
getPublicMediaRefsByEpisodeGuid,
refreshMediaRefsVideosMaterializedView,
removeDeadChapters,
Expand Down
16 changes: 1 addition & 15 deletions src/routes/clips.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,14 @@ import * as Router from 'koa-router'
import { config } from '~/config'
import { emitRouterError } from '~/lib/errors'
import { convertToChaptersFile } from '~/lib/podcastIndex'
import { getPublicMediaRefsByEpisodeGuid, getPublicMediaRefsByEpisodeMediaUrl } from '~/controllers/mediaRef'
import { getPublicMediaRefsByEpisodeGuid } from '~/controllers/mediaRef'
import { parseNSFWHeader } from '~/middleware/parseNSFWHeader'
const json = require('koa-json')

const router = new Router({ prefix: `${config.apiPrefix}${config.apiVersion}/clips` })

router.use(bodyParser())

// Get public mediaRefs by episode mediaUrl
router.get('/', parseNSFWHeader, json(), async (ctx) => {
try {
const { mediaUrl } = ctx.query
const mediaRefsResult = await getPublicMediaRefsByEpisodeMediaUrl(mediaUrl)
const mediaRefs = mediaRefsResult[0]
const chaptersFile = convertToChaptersFile(mediaRefs)
const prettyChaptersFileString = JSON.stringify(chaptersFile, null, 4)
ctx.body = JSON.parse(prettyChaptersFileString)
} catch (error) {
emitRouterError(error, ctx)
}
})

// Get public mediaRefs by episode guid
router.get('/', parseNSFWHeader, json(), async (ctx) => {
try {
Expand Down
13 changes: 0 additions & 13 deletions src/routes/episode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { delimitQueryValues } from '~/lib/utility'
import {
getEpisode,
getEpisodeByPodcastIdAndGuid,
getEpisodeByPodcastIdAndMediaUrl,
getEpisodes,
getEpisodesByCategoryIds,
getEpisodesByPodcastIds,
Expand Down Expand Up @@ -238,18 +237,6 @@ router.post('/get-by-guid', parseNSFWHeader, async (ctx) => {
}
})

// Get Episode by mediaUrl
router.post('/get-by-media-url', parseNSFWHeader, async (ctx) => {
try {
const body: any = ctx.request.body
const { episodeMediaUrl, podcastId } = body
const results = await getEpisodeByPodcastIdAndMediaUrl(podcastId, episodeMediaUrl)
ctx.body = results
} catch (error) {
emitRouterError(error, ctx)
}
})

// Get Episode by guid
router.post('/get-by-guid', parseNSFWHeader, async (ctx) => {
try {
Expand Down

0 comments on commit 02f8458

Please sign in to comment.