1
0
Fork 0
mirror of https://github.com/sussy-code/smov.git synced 2024-12-29 16:07:40 +01:00

human readable urls

This commit is contained in:
adrifcastr 2023-06-23 10:23:46 +02:00
parent 430b9564ab
commit 7ee1c13760
2 changed files with 18 additions and 3 deletions

View file

@ -1,4 +1,5 @@
import { FetchError } from "ofetch";
import slugify from "slugify";
import { formatJWMeta, mediaTypeToJW } from "./justwatch";
import {
@ -203,10 +204,17 @@ export async function convertLegacyUrl(
// movies always have an imdb id on tmdb
if (imdbId && mediaType === MWMediaType.MOVIE) {
const movieId = await getMovieFromExternalId(imdbId);
if (movieId) return `/media/tmdb-movie-${movieId}`;
if (movieId)
return `/media/tmdb-movie-${movieId}-${slugify(meta.meta.title, {
lower: true,
strict: true,
})}`;
}
if (tmdbId) {
return `/media/tmdb-${type}-${tmdbId}`;
return `/media/tmdb-${type}-${tmdbId}-${slugify(meta.meta.title, {
lower: true,
strict: true,
})}`;
}
}

View file

@ -1,3 +1,5 @@
import slugify from "slugify";
import { conf } from "@/setup/config";
import { MWMediaMeta, MWMediaType, MWSeasonMeta } from "./types/mw";
@ -75,7 +77,12 @@ export function formatTMDBMeta(
}
export function TMDBMediaToId(media: MWMediaMeta): string {
return ["tmdb", mediaTypeToTMDB(media.type), media.id].join("-");
return [
"tmdb",
mediaTypeToTMDB(media.type),
media.id,
slugify(media.title, { lower: true, strict: true }),
].join("-");
}
export function decodeTMDBId(