mirror of
https://github.com/p-stream/p-stream.git
synced 2026-03-11 17:55:33 +00:00
use locale for get meta
This commit is contained in:
parent
a82797a34f
commit
06229983f5
1 changed files with 8 additions and 2 deletions
|
|
@ -1,5 +1,8 @@
|
|||
import { FetchError } from "ofetch";
|
||||
|
||||
import { useLanguageStore } from "@/stores/language";
|
||||
import { getTmdbLanguageCode } from "@/utils/language";
|
||||
|
||||
import { formatJWMeta, mediaTypeToJW } from "./justwatch";
|
||||
import {
|
||||
TMDBIdToUrlId,
|
||||
|
|
@ -119,10 +122,13 @@ export async function getLegacyMetaFromId(
|
|||
seasonId?: string,
|
||||
): Promise<DetailedMeta | null> {
|
||||
const queryType = mediaTypeToJW(type);
|
||||
const userLanguage = useLanguageStore.getState().language;
|
||||
const formattedLanguage = getTmdbLanguageCode(userLanguage);
|
||||
const locale = formattedLanguage.replace("-", "_");
|
||||
|
||||
let data: JWDetailedMeta;
|
||||
try {
|
||||
const url = makeUrl("/content/titles/{type}/{id}/locale/en_US", {
|
||||
const url = makeUrl(`/content/titles/{type}/{id}/locale/${locale}`, {
|
||||
type: queryType,
|
||||
id,
|
||||
});
|
||||
|
|
@ -150,7 +156,7 @@ export async function getLegacyMetaFromId(
|
|||
let seasonData: JWSeasonMetaResult | undefined;
|
||||
if (data.object_type === "show") {
|
||||
const seasonToScrape = seasonId ?? data.seasons?.[0].id.toString() ?? "";
|
||||
const url = makeUrl("/content/titles/show_season/{id}/locale/en_US", {
|
||||
const url = makeUrl(`/content/titles/show_season/{id}/locale/${locale}`, {
|
||||
id: seasonToScrape,
|
||||
});
|
||||
seasonData = await proxiedFetch<any>(url, { baseURL: JW_API_BASE });
|
||||
|
|
|
|||
Loading…
Reference in a new issue