mirror of
https://github.com/movie-web/movie-web.git
synced 2024-11-13 09:05:08 +01:00
human readable urls
This commit is contained in:
parent
430b9564ab
commit
7ee1c13760
@ -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,
|
||||
})}`;
|
||||
}
|
||||
}
|
||||
|
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user