Skip to content

Commit

Permalink
Merge pull request #714 from podverse/develop
Browse files Browse the repository at this point in the history
Release v4.15.17
  • Loading branch information
mitchdowney authored Dec 5, 2023
2 parents 33a281c + eac729b commit 01a11cb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
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.15.16",
"version": "4.15.17",
"description": "Data API, database migration scripts, and backend services for all Podverse models.",
"contributors": [
"Mitch Downey"
Expand Down
12 changes: 12 additions & 0 deletions src/routes/podcastIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as Router from 'koa-router'
import { config } from '~/config'
import { emitRouterError } from '~/lib/errors'
import {
getEpisodeByGuid,
getPodcastFromPodcastIndexById,
getValueTagForChannelFromPodcastIndexByGuids,
getValueTagForItemFromPodcastIndexByGuids
Expand Down Expand Up @@ -52,4 +53,15 @@ router.get('/value/by-guids', async (ctx) => {
}
})

// Get episode from Podcast Index by podcastIndexId and episodeGuid
router.get('/episode/byguid', podcastByIdLimiter, async (ctx) => {
try {
const { episodeGuid, podcastIndexId } = ctx.query as any
const data = await getEpisodeByGuid(podcastIndexId, episodeGuid)
ctx.body = data
} catch (error) {
emitRouterError(error, ctx)
}
})

export const podcastIndexRouter = router
10 changes: 10 additions & 0 deletions src/services/podcastIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -611,3 +611,13 @@ export const hideDeadPodcasts = async (fileUrl?: string) => {

console.log('hideDeadPodcasts finished')
}

export const getEpisodeByGuid = async (podcastIndexId: string, episodeGuid: string) => {
if (episodeGuid.indexOf('http') === 0) {
episodeGuid = episodeGuid.replace(/#/g, '%23')
episodeGuid = episodeGuid.replace(/\?/g, '%3F')
}
const url = `${podcastIndexConfig.baseUrl}/episodes/byguid?feedid=${podcastIndexId}&guid=${episodeGuid}`
const response = await axiosRequest(url)
return response && response.data
}

0 comments on commit 01a11cb

Please sign in to comment.