mirror of
https://github.com/shafat-96/anicrush-api.git
synced 2026-04-17 15:51:44 +00:00
Add files via upload
This commit is contained in:
43
hls.js
Normal file
43
hls.js
Normal file
@@ -0,0 +1,43 @@
|
||||
const axios = require('axios');
|
||||
const { getCommonHeaders } = require('./mapper');
|
||||
const { handleEmbed } = require('./embedHandler');
|
||||
|
||||
// Function to get HLS link
|
||||
async function getHlsLink(embedUrl) {
|
||||
try {
|
||||
if (!embedUrl) {
|
||||
throw new Error('Embed URL is required');
|
||||
}
|
||||
|
||||
// Use rabbit.js to decode the embed URL and get sources
|
||||
const embedSources = await handleEmbed(embedUrl, 'https://anicrush.to');
|
||||
|
||||
if (!embedSources || !embedSources.sources || !embedSources.sources.length) {
|
||||
throw new Error('No sources found');
|
||||
}
|
||||
|
||||
// Return the complete response
|
||||
return {
|
||||
status: true,
|
||||
result: {
|
||||
sources: embedSources.sources,
|
||||
tracks: embedSources.tracks,
|
||||
t: embedSources.t,
|
||||
intro: embedSources.intro,
|
||||
outro: embedSources.outro,
|
||||
server: embedSources.server
|
||||
}
|
||||
};
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error getting HLS link:', error);
|
||||
return {
|
||||
status: false,
|
||||
error: error.message || 'Failed to get HLS link'
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getHlsLink
|
||||
};
|
||||
Reference in New Issue
Block a user