c1c31d7685
Major improvements: - Series TV support via FS7 provider with dedicated search endpoint - Vidzy downloader now uses Playwright for JS obfuscation and ffmpeg for HLS streams - Episode filenames properly named (Series Title - Episode X) instead of master.m3u8.mp4 - Duplicate download prevention: checks existing tasks before creating new ones - Removed host preference system in favor of intelligent URL-based detection Technical changes: - Vidzy: Added Playwright extraction and M3U8→MP4 conversion with ffmpeg - FS7: Episodes now use pipe format (video_url|series_url|episode_title) - DownloadManager: Extract target_filename from pipe URL and prevent duplicates - UI: New Series tab with search, recommendations, and releases sections - Anime-Sama: Removed hardcoded host preferences, uses site's URL order Generated with [Claude Code](https://claude.com/claude-code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <[email protected]> Co-Authored-By: Happy <[email protected]>
164 lines
3.9 KiB
JavaScript
164 lines
3.9 KiB
JavaScript
// API Base configuration
|
|
const API_BASE = '/api';
|
|
|
|
// Cache for providers info
|
|
let searchResultsCache = {};
|
|
|
|
/**
|
|
* Get providers information
|
|
*/
|
|
async function getProvidersInfo() {
|
|
if (!searchResultsCache.providers) {
|
|
const response = await fetch(`${API_BASE}/providers`);
|
|
searchResultsCache.providers = await response.json();
|
|
}
|
|
return searchResultsCache.providers;
|
|
}
|
|
|
|
/**
|
|
* Search anime across all providers
|
|
*/
|
|
async function searchAnime(query, lang, includeMetadata) {
|
|
if (!query) {
|
|
throw new Error('Veuillez entrer un nom d\'anime');
|
|
}
|
|
|
|
const response = await fetch(
|
|
`${API_BASE}/anime/search?q=${encodeURIComponent(query)}&lang=${lang}&include_metadata=${includeMetadata}`
|
|
);
|
|
|
|
if (!response.ok) {
|
|
throw new Error('Erreur lors de la recherche');
|
|
}
|
|
|
|
return await response.json();
|
|
}
|
|
|
|
/**
|
|
* Load episodes for an anime
|
|
*/
|
|
async function loadEpisodes(animeUrl, lang) {
|
|
const response = await fetch(
|
|
`${API_BASE}/anime/episodes?url=${encodeURIComponent(animeUrl)}&lang=${lang}`
|
|
);
|
|
|
|
if (!response.ok) {
|
|
throw new Error('Erreur lors du chargement des épisodes');
|
|
}
|
|
|
|
return await response.json();
|
|
}
|
|
|
|
/**
|
|
* Download an anime episode
|
|
*/
|
|
async function downloadEpisode(episodeUrl) {
|
|
const response = await fetch(`${API_BASE}/anime/download?url=${encodeURIComponent(episodeUrl)}`, {
|
|
method: 'POST'
|
|
});
|
|
|
|
if (!response.ok) {
|
|
throw new Error('Erreur lors du démarrage du téléchargement');
|
|
}
|
|
|
|
return await response.json();
|
|
}
|
|
|
|
/**
|
|
* Download entire season
|
|
*/
|
|
async function downloadSeason(animeUrl, lang) {
|
|
const response = await fetch(
|
|
`${API_BASE}/anime/download-season?url=${encodeURIComponent(animeUrl)}&lang=${lang}`,
|
|
{ method: 'POST' }
|
|
);
|
|
|
|
if (!response.ok) {
|
|
const error = await response.json();
|
|
throw new Error(error.detail || 'Impossible de démarrer le téléchargement de la saison');
|
|
}
|
|
|
|
return await response.json();
|
|
}
|
|
|
|
/**
|
|
* Start a direct download
|
|
*/
|
|
async function startDownload(url) {
|
|
const response = await fetch(`${API_BASE}/download`, {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ url })
|
|
});
|
|
|
|
if (!response.ok) {
|
|
throw new Error('Erreur lors du démarrage du téléchargement');
|
|
}
|
|
|
|
return await response.json();
|
|
}
|
|
|
|
/**
|
|
* Get all downloads
|
|
*/
|
|
async function getDownloads() {
|
|
const response = await fetch(`${API_BASE}/downloads`);
|
|
|
|
if (!response.ok) {
|
|
throw new Error('Erreur lors du chargement des téléchargements');
|
|
}
|
|
|
|
return await response.json();
|
|
}
|
|
|
|
/**
|
|
* Pause a download
|
|
*/
|
|
async function pauseDownload(id) {
|
|
const response = await fetch(`${API_BASE}/download/${id}/pause`, { method: 'POST' });
|
|
|
|
if (!response.ok) {
|
|
throw new Error('Erreur lors de la mise en pause');
|
|
}
|
|
|
|
return await response.json();
|
|
}
|
|
|
|
/**
|
|
* Resume a download
|
|
*/
|
|
async function resumeDownload(id) {
|
|
const response = await fetch(`${API_BASE}/download/${id}/resume`, { method: 'POST' });
|
|
|
|
if (!response.ok) {
|
|
throw new Error('Erreur lors de la reprise');
|
|
}
|
|
|
|
return await response.json();
|
|
}
|
|
|
|
/**
|
|
* Cancel/delete a download
|
|
*/
|
|
async function cancelDownload(id) {
|
|
const response = await fetch(`${API_BASE}/download/${id}`, { method: 'DELETE' });
|
|
|
|
if (!response.ok) {
|
|
throw new Error('Erreur lors de la suppression');
|
|
}
|
|
|
|
return await response.json();
|
|
}
|
|
|
|
// Make functions available globally
|
|
window.getProvidersInfo = getProvidersInfo;
|
|
window.searchAnime = searchAnime;
|
|
window.loadEpisodes = loadEpisodes;
|
|
window.downloadEpisode = downloadEpisode;
|
|
window.downloadSeason = downloadSeason;
|
|
window.startDownload = startDownload;
|
|
window.getDownloads = getDownloads;
|
|
window.pauseDownload = pauseDownload;
|
|
window.resumeDownload = resumeDownload;
|
|
window.cancelDownload = cancelDownload;
|