feat: create route to fetch stream URL from provider
Summary: Test Plan:
This commit is contained in:
53
src/controllers/episodes/getEpisodeUrl/index.spec.ts
Normal file
53
src/controllers/episodes/getEpisodeUrl/index.spec.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
import { describe, expect, it } from "bun:test";
|
||||
|
||||
import app from "~/index";
|
||||
import { server } from "~/mocks";
|
||||
import { mockConsumet } from "~/mocks/consumet";
|
||||
|
||||
server.listen();
|
||||
mockConsumet();
|
||||
|
||||
describe('requests the "/episodes/:id/url" route', () => {
|
||||
it("with sources from Anify", async () => {
|
||||
const response = await app.request(
|
||||
"/episodes/1/url",
|
||||
{
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
provider: "anify",
|
||||
id: "/ore-dake-level-up-na-ken-episode-2",
|
||||
}),
|
||||
headers: { "Content-Type": "application/json" },
|
||||
},
|
||||
{
|
||||
ENABLE_ANIFY: "true",
|
||||
},
|
||||
);
|
||||
|
||||
expect(response.json()).resolves.toEqual({
|
||||
success: true,
|
||||
result: {
|
||||
source:
|
||||
"https://proxy.anify.tv/video/8CLGIJg8G3k%252BH%252BYV9xyOYVGZ8al8uZqqtbXk44wKRco%252BGATkCrqlkgdRiam3owmOU4f2MAB89GOblOuZbxifwbGsjvp32uxhRC4kZVYrWnZmP%252FrLxtqwi0n6zY%252BvrffUh6dbg6DADSLCWhd2bNUUIg%253D%253D/%7B%7D/.m3u8",
|
||||
subtitles: [],
|
||||
audio: [],
|
||||
intro: [0, 0],
|
||||
outro: [0, 0],
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("with no URL from Anify source", async () => {
|
||||
const response = await app.request("/episodes/-1/url", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
provider: "anify",
|
||||
id: "/ore-dake-level-up-na-ken-episode-2",
|
||||
}),
|
||||
headers: { "Content-Type": "application/json" },
|
||||
});
|
||||
|
||||
expect(response.json()).resolves.toEqual({ success: false });
|
||||
expect(response.status).toBe(404);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user