mirror of
https://github.com/maxdorninger/MediaManager.git
synced 2026-04-21 00:05:36 +02:00
fix invalid URL error
This commit is contained in:
@@ -16,10 +16,12 @@
|
||||
|
||||
async function addMedia() {
|
||||
loading = true;
|
||||
let url = isShow ? new URL(apiUrl + '/tv/shows') : new URL(apiUrl + '/movies');
|
||||
url.searchParams.append(isShow ? 'show_id' : 'movie_id', String(result.external_id));
|
||||
url.searchParams.append('metadata_provider', result.metadata_provider);
|
||||
const response = await fetch(url, {
|
||||
const endpoint = isShow ? '/tv/shows' : '/movies';
|
||||
const urlParams = new URLSearchParams();
|
||||
urlParams.append(isShow ? 'show_id' : 'movie_id', String(result.external_id));
|
||||
urlParams.append('metadata_provider', result.metadata_provider);
|
||||
const urlString = `${apiUrl}${endpoint}?${urlParams.toString()}`;
|
||||
const response = await fetch(urlString, {
|
||||
method: 'POST',
|
||||
credentials: 'include'
|
||||
});
|
||||
|
||||
@@ -24,13 +24,14 @@
|
||||
let filePathSuffix: string = $state('');
|
||||
|
||||
async function downloadTorrent(result_id: string) {
|
||||
let url = new URL(apiUrl + `/movies/${movie.id}/torrents`);
|
||||
url.searchParams.append('public_indexer_result_id', result_id);
|
||||
const urlParams = new URLSearchParams();
|
||||
urlParams.append('public_indexer_result_id', result_id);
|
||||
if (filePathSuffix !== '') {
|
||||
url.searchParams.append('override_file_path_suffix', filePathSuffix);
|
||||
urlParams.append('override_file_path_suffix', filePathSuffix);
|
||||
}
|
||||
const urlString = `${apiUrl}/movies/${movie.id}/torrents?${urlParams.toString()}`;
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
const response = await fetch(urlString, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
@@ -64,13 +65,14 @@
|
||||
torrentsError = null;
|
||||
torrents = [];
|
||||
|
||||
let url = new URL(apiUrl + `/movies/${movie.id}/torrents`);
|
||||
const urlParams = new URLSearchParams();
|
||||
if (override) {
|
||||
url.searchParams.append('search_query_override', queryOverride);
|
||||
urlParams.append('search_query_override', queryOverride);
|
||||
}
|
||||
const urlString = `${apiUrl}/movies/${movie.id}/torrents?${urlParams.toString()}`;
|
||||
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
const response = await fetch(urlString, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
|
||||
@@ -29,14 +29,15 @@
|
||||
let filePathSuffix: string = $state('');
|
||||
|
||||
async function downloadTorrent(result_id: string) {
|
||||
let url = new URL(apiUrl + '/tv/torrents');
|
||||
url.searchParams.append('public_indexer_result_id', result_id);
|
||||
url.searchParams.append('show_id', show.id);
|
||||
const urlParams = new URLSearchParams();
|
||||
urlParams.append('public_indexer_result_id', result_id);
|
||||
urlParams.append('show_id', show.id);
|
||||
if (filePathSuffix !== '') {
|
||||
url.searchParams.append('override_file_path_suffix', filePathSuffix);
|
||||
urlParams.append('override_file_path_suffix', filePathSuffix);
|
||||
}
|
||||
const urlString = `${apiUrl}/tv/torrents?${urlParams.toString()}`;
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
const response = await fetch(urlString, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
@@ -73,20 +74,18 @@
|
||||
torrentsError = null;
|
||||
torrents = [];
|
||||
|
||||
let url = new URL(apiUrl + '/tv/torrents');
|
||||
url.searchParams.append('show_id', show.id);
|
||||
const urlParams = new URLSearchParams();
|
||||
urlParams.append('show_id', show.id);
|
||||
if (override) {
|
||||
url.searchParams.append('search_query_override', queryOverride);
|
||||
urlParams.append('search_query_override', queryOverride);
|
||||
} else {
|
||||
url.searchParams.append('season_number', season_number.toString());
|
||||
urlParams.append('season_number', season_number.toString());
|
||||
}
|
||||
const urlString = `${apiUrl}/tv/torrents?${urlParams.toString()}`;
|
||||
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
const response = await fetch(urlString, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
credentials: 'include'
|
||||
});
|
||||
|
||||
|
||||
@@ -58,10 +58,11 @@
|
||||
|
||||
const endpoint =
|
||||
mediaType === 'tv' ? `/tv/shows/${media.id}/library` : `/movies/${media.id}/library`;
|
||||
let url = new URL(apiUrl + endpoint);
|
||||
url.searchParams.append('library', selectedLabel);
|
||||
const urlParams = new URLSearchParams();
|
||||
urlParams.append('library', selectedLabel);
|
||||
const urlString = `${apiUrl}${endpoint}?${urlParams.toString()}`;
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
const response = await fetch(urlString, {
|
||||
method: 'POST',
|
||||
credentials: 'include'
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user