Skip to content

Commit

Permalink
fixed streams
Browse files Browse the repository at this point in the history
  • Loading branch information
AltuisticIsopod committed Sep 26, 2024
1 parent f6210b6 commit c0e2a6c
Show file tree
Hide file tree
Showing 18 changed files with 266 additions and 621 deletions.
47 changes: 35 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
"@headlessui/react": "^1.7.17",
"@next/bundle-analyzer": "^14.1.0",
"@nextui-org/react": "^2.2.10",
"@vidstack/react": "^1.11.21",
"@vidstack/react": "^1.12.11",
"axios": "^1.6.5",
"disqus-react": "^1.1.5",
"framer-motion": "^10.18.0",
"hls.js": "^1.5.8",
"hls.js": "^1.5.15",
"ioredis": "^5.3.2",
"media-icons": "^1.1.4",
"mongoose": "^8.1.1",
Expand Down
18 changes: 17 additions & 1 deletion src/actions/episode.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,13 @@ const fetchAndCacheData = async (id, meta, redis, cacheTime, refresh) => {
);
}
if (subEpisodes?.length > 0) {
const transformedEpisodes = subEpisodes.map(episode => ({
...episode,
id: transformEpisodeId(episode.id)
}));

allepisodes.push({
episodes: subEpisodes,
episodes: transformedEpisodes,
providerId: "zoro",
});
}
Expand Down Expand Up @@ -214,3 +219,14 @@ export const getEpisodes = async (id, status, refresh = false) => {
return fetchdata;
}
};


function transformEpisodeId(episodeId) {
const regex = /^([^$]*)\$episode\$([^$]*)/;
const match = episodeId.match(regex);

if (match && match[1] && match[2]) {
return `${match[1]}?ep=${match[2]}`; // Construct the desired output with the episode number
}
return episodeId; // Return original ID if no match is found
}
65 changes: 65 additions & 0 deletions src/actions/feedback.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
"use server"
import { connectMongo } from "@/mongodb/db";
import Feedback from "@/mongodb/models/feedback";

export const getFeedbacks = async (req) => {
try {
await connectMongo();

const reports = await Feedback.find();
if (!reports || reports.length === 0) {
return { message: "No feedback reports found" };
}

return reports;
} catch (error) {
console.error("Error fetching feedback reports:", error);
return { message: "Failed to retrieve feedback reports. Please try again later." , status: 500};
}
};


export const createFeedback = async (data) => {
const { title, description, type, severity } = data;

try {
await connectMongo();

const newReport = await Feedback.create({
title: title,
description: description,
type: type,
severity: severity
});

return { message: "Feedback report saved successfully" , status: 201};

} catch (error) {
console.error("Error saving feedback report:", error);
return { message: "Failed to save feedback report. Please try again later." , status: 500 };
}
};


export const deletFeedback = async (id) => {
try {
await connectMongo();

if (id) {
const deletedReport = await Feedback.findByIdAndDelete(id);
if (!deletedReport) {
return { message: `Feedback report with ID ${id} not found` };
}
return { message: `Feedback report with ID ${id} deleted successfully` };
} else {
// If no ID is provided, delete all feedback reports
const deletedCount = await Feedback.deleteMany({});
return { message: `Deleted ${deletedCount.deletedCount} feedback reports` };
}
} catch (error) {
console.error(`Error deleting feedback report${id ? ` with ID ${id}` : 's'}:`, error);
return { message: "Failed to delete feedback report(s). Please try again later." };
}
};


70 changes: 41 additions & 29 deletions src/actions/source.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,53 @@
"use server"
import { ANIME } from "@consumet/extensions";

const gogo = new ANIME.Gogoanime();

export async function getGogoSources(id) {
try {
const data = await gogo.fetchEpisodeSources(id);
try {
const data = await gogo.fetchEpisodeSources(id);

if (!data) return null;
if (!data) return null;

return data;
} catch (error) {
console.log(error);
return null;
}
return data;
} catch (error) {
console.log(error);
return null;
}
}

export async function getZoroSources(id) {
try {
const data = await fetch(`${process.env.ZORO_API}/`);

if (!data) return null;

return data;
} catch (error) {
console.log(error);
return null;
}
export async function getZoroSources(id, provider, episodeid, epnum, subtype) {
try {
let data;
const API = process.env.ZORO_API;
if (API) {
const res = await fetch(`${API}/anime/episode-srcs?id=${episodeid}&server=vidstreaming&category=${subtype}`);
data = await res.json();
} else {
console.log(episodeid)
const resp = await fetch(`https://anify.eltik.cc/sources?providerId=${provider}&watchId=${encodeURIComponent(episodeid)}&episodeNumber=${epnum}&id=${id}&subType=${subtype}`);
data = await resp.json();
}
if (!data) return null;

return data;
} catch (error) {
console.log(error);
return null;
}
}

export async function getAnimeSources(id, provider, epid, epnum, subdub) {
try {
if (provider === "gogoanime") {
const data = await getGogoSources(epid);
return data;
export async function getAnimeSources(id, provider, epid, epnum, subtype) {
try {
if (provider === "gogoanime") {
const data = await getGogoSources(epid);
return data;
}
if (provider === "zoro") {
const data = await getZoroSources(id, provider, epid, epnum, subtype)
return data;
}
} catch (error) {
console.log(error);
return null;
}
} catch (error) {
console.log(error);
return null;
}
}
70 changes: 0 additions & 70 deletions src/app/api/admin/feedback-report/route.js

This file was deleted.

Loading

0 comments on commit c0e2a6c

Please sign in to comment.