forked from Ninjalama/streamyfin_mirror
chore
This commit is contained in:
@@ -141,8 +141,6 @@ const Page = () => {
|
||||
}): Promise<BaseItemDtoQueryResult | null> => {
|
||||
if (!api || !library) return null;
|
||||
|
||||
console.log("[libraryId] ~", library);
|
||||
|
||||
let itemType: BaseItemKind | undefined;
|
||||
|
||||
// This fix makes sure to only return 1 type of items, if defined.
|
||||
|
||||
@@ -282,13 +282,6 @@ export default function page() {
|
||||
|
||||
if (!item?.Id || !stream) return;
|
||||
|
||||
console.log(
|
||||
"onProgress ~",
|
||||
currentTimeInTicks,
|
||||
isPlaying,
|
||||
`AUDIO index: ${audioIndex} SUB index" ${subtitleIndex}`
|
||||
);
|
||||
|
||||
await getPlaystateApi(api!).onPlaybackProgress({
|
||||
itemId: item.Id,
|
||||
audioStreamIndex: audioIndex ? audioIndex : undefined,
|
||||
|
||||
@@ -68,7 +68,6 @@ export const ItemContent: React.FC<{ item: BaseItemDto }> = React.memo(
|
||||
|
||||
// Needs to automatically change the selected to the default values for default indexes.
|
||||
useEffect(() => {
|
||||
console.log(defaultAudioIndex, defaultSubtitleIndex);
|
||||
setSelectedOptions(() => ({
|
||||
bitrate: defaultBitrate,
|
||||
mediaSource: defaultMediaSource,
|
||||
@@ -220,7 +219,6 @@ export const ItemContent: React.FC<{ item: BaseItemDto }> = React.memo(
|
||||
className="mr-1"
|
||||
source={selectedOptions.mediaSource}
|
||||
onChange={(val) => {
|
||||
console.log(val);
|
||||
setSelectedOptions(
|
||||
(prev) =>
|
||||
prev && {
|
||||
|
||||
@@ -1,33 +1,37 @@
|
||||
import {Text} from "@/components/common/Text";
|
||||
import React, {useCallback, useMemo, useState} from "react";
|
||||
import {Alert, TouchableOpacity, View} from "react-native";
|
||||
import {TvDetails} from "@/utils/jellyseerr/server/models/Tv";
|
||||
import {FlashList} from "@shopify/flash-list";
|
||||
import {orderBy} from "lodash";
|
||||
import {Tags} from "@/components/GenreTags";
|
||||
import { Text } from "@/components/common/Text";
|
||||
import React, { useCallback, useMemo, useState } from "react";
|
||||
import { Alert, TouchableOpacity, View } from "react-native";
|
||||
import { TvDetails } from "@/utils/jellyseerr/server/models/Tv";
|
||||
import { FlashList } from "@shopify/flash-list";
|
||||
import { orderBy } from "lodash";
|
||||
import { Tags } from "@/components/GenreTags";
|
||||
import JellyseerrIconStatus from "@/components/icons/JellyseerrIconStatus";
|
||||
import Season from "@/utils/jellyseerr/server/entity/Season";
|
||||
import {MediaStatus, MediaType} from "@/utils/jellyseerr/server/constants/media";
|
||||
import {Ionicons} from "@expo/vector-icons";
|
||||
import {RoundButton} from "@/components/RoundButton";
|
||||
import {useJellyseerr} from "@/hooks/useJellyseerr";
|
||||
import {TvResult} from "@/utils/jellyseerr/server/models/Search";
|
||||
import {useQuery} from "@tanstack/react-query";
|
||||
import {HorizontalScroll} from "@/components/common/HorrizontalScroll";
|
||||
import {Image} from "expo-image";
|
||||
import {
|
||||
MediaStatus,
|
||||
MediaType,
|
||||
} from "@/utils/jellyseerr/server/constants/media";
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
import { RoundButton } from "@/components/RoundButton";
|
||||
import { useJellyseerr } from "@/hooks/useJellyseerr";
|
||||
import { TvResult } from "@/utils/jellyseerr/server/models/Search";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { HorizontalScroll } from "@/components/common/HorrizontalScroll";
|
||||
import { Image } from "expo-image";
|
||||
import MediaRequest from "@/utils/jellyseerr/server/entity/MediaRequest";
|
||||
import { Loader } from "../Loader";
|
||||
|
||||
const JellyseerrSeasonEpisodes: React.FC<{details: TvDetails, seasonNumber: number}> = ({
|
||||
details,
|
||||
seasonNumber
|
||||
}) => {
|
||||
const {jellyseerrApi} = useJellyseerr();
|
||||
const JellyseerrSeasonEpisodes: React.FC<{
|
||||
details: TvDetails;
|
||||
seasonNumber: number;
|
||||
}> = ({ details, seasonNumber }) => {
|
||||
const { jellyseerrApi } = useJellyseerr();
|
||||
|
||||
const {data: seasonWithEpisodes, isLoading} = useQuery({
|
||||
const { data: seasonWithEpisodes, isLoading } = useQuery({
|
||||
queryKey: ["jellyseerr", details.id, "season", seasonNumber],
|
||||
queryFn: async () => jellyseerrApi?.tvSeason(details.id, seasonNumber),
|
||||
enabled: details.seasons.filter(s => s.seasonNumber !== 0).length > 0
|
||||
})
|
||||
enabled: details.seasons.filter((s) => s.seasonNumber !== 0).length > 0,
|
||||
});
|
||||
|
||||
return (
|
||||
<HorizontalScroll
|
||||
@@ -37,86 +41,102 @@ const JellyseerrSeasonEpisodes: React.FC<{details: TvDetails, seasonNumber: numb
|
||||
estimatedItemSize={50}
|
||||
data={seasonWithEpisodes?.episodes}
|
||||
keyExtractor={(item) => item.id}
|
||||
ItemSeparatorComponent={() => <View className="w-2"/>}
|
||||
renderItem={(item, index) => (
|
||||
<View className="flex flex-col mt-2 w-44">
|
||||
{item.stillPath && (
|
||||
<View
|
||||
className="relative aspect-video rounded-lg overflow-hidden border border-neutral-800"
|
||||
>
|
||||
<Image
|
||||
key={item.id}
|
||||
id={item.id}
|
||||
source={{
|
||||
uri: jellyseerrApi?.tvStillImageProxy(item.stillPath),
|
||||
}}
|
||||
cachePolicy={"memory-disk"}
|
||||
contentFit="cover"
|
||||
className="w-full h-full"
|
||||
/>
|
||||
</View>
|
||||
)}
|
||||
<View className="shrink">
|
||||
<Text numberOfLines={2} className="">
|
||||
{item?.name}
|
||||
</Text>
|
||||
<Text numberOfLines={1} className="text-xs text-neutral-500">
|
||||
{`S${item?.seasonNumber}:E${item?.episodeNumber}`}
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
<Text numberOfLines={3} className="text-xs text-neutral-500 shrink">
|
||||
{item?.overview}
|
||||
</Text>
|
||||
</View>
|
||||
<RenderItem key={index} item={item} index={index} />
|
||||
)}
|
||||
/>
|
||||
)
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
const RenderItem = ({ item, index }: any) => {
|
||||
const { jellyseerrApi } = useJellyseerr();
|
||||
const [imageError, setImageError] = useState(false);
|
||||
|
||||
return (
|
||||
<View className="flex flex-col w-44 mt-2">
|
||||
<View className="relative aspect-video rounded-lg overflow-hidden border border-neutral-800">
|
||||
{!imageError ? (
|
||||
<Image
|
||||
key={item.id}
|
||||
id={item.id}
|
||||
source={{
|
||||
uri: jellyseerrApi?.tvStillImageProxy(item.stillPath),
|
||||
}}
|
||||
cachePolicy={"memory-disk"}
|
||||
contentFit="cover"
|
||||
className="w-full h-full"
|
||||
onError={(e) => {
|
||||
setImageError(true);
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<View className="flex flex-col w-full h-full items-center justify-center border border-neutral-800 bg-neutral-900">
|
||||
<Ionicons
|
||||
name="image-outline"
|
||||
size={24}
|
||||
color="white"
|
||||
style={{ opacity: 0.4 }}
|
||||
/>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
<View className="shrink mt-1">
|
||||
<Text numberOfLines={2} className="">
|
||||
{item.name}
|
||||
</Text>
|
||||
<Text numberOfLines={1} className="text-xs text-neutral-500">
|
||||
{`S${item.seasonNumber}:E${item.episodeNumber}`}
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
<Text numberOfLines={3} className="text-xs text-neutral-500 shrink">
|
||||
{item.overview}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
const JellyseerrSeasons: React.FC<{
|
||||
isLoading: boolean,
|
||||
result?: TvResult,
|
||||
details?: TvDetails
|
||||
}> = ({
|
||||
isLoading,
|
||||
result,
|
||||
details,
|
||||
}) => {
|
||||
if (!details)
|
||||
return null;
|
||||
isLoading: boolean;
|
||||
result?: TvResult;
|
||||
details?: TvDetails;
|
||||
}> = ({ isLoading, result, details }) => {
|
||||
if (!details) return null;
|
||||
|
||||
const {jellyseerrApi, requestMedia} = useJellyseerr();
|
||||
const [seasonStates, setSeasonStates] = useState<{[key: number]: boolean}>();
|
||||
const { jellyseerrApi, requestMedia } = useJellyseerr();
|
||||
const [seasonStates, setSeasonStates] = useState<{
|
||||
[key: number]: boolean;
|
||||
}>();
|
||||
const seasons = useMemo(() => {
|
||||
const mediaInfoSeasons = details?.mediaInfo?.seasons?.filter((s: Season) => s.seasonNumber !== 0)
|
||||
const requestedSeasons = details?.mediaInfo?.requests?.flatMap((r: MediaRequest) => r.seasons)
|
||||
return details.seasons?.map((season) => {
|
||||
return {
|
||||
...season,
|
||||
status:
|
||||
// What our library status is
|
||||
mediaInfoSeasons
|
||||
?.find((mediaSeason: Season) => mediaSeason.seasonNumber === season.seasonNumber)
|
||||
?.status
|
||||
??
|
||||
// What our request status is
|
||||
requestedSeasons
|
||||
?.find((s: Season) => s.seasonNumber === season.seasonNumber)
|
||||
?.status
|
||||
??
|
||||
// Otherwise set it as unknown
|
||||
MediaStatus.UNKNOWN
|
||||
}
|
||||
})
|
||||
},
|
||||
[details]
|
||||
);
|
||||
const mediaInfoSeasons = details?.mediaInfo?.seasons?.filter(
|
||||
(s: Season) => s.seasonNumber !== 0
|
||||
);
|
||||
const requestedSeasons = details?.mediaInfo?.requests?.flatMap(
|
||||
(r: MediaRequest) => r.seasons
|
||||
);
|
||||
return details.seasons?.map((season) => {
|
||||
return {
|
||||
...season,
|
||||
status:
|
||||
// What our library status is
|
||||
mediaInfoSeasons?.find(
|
||||
(mediaSeason: Season) =>
|
||||
mediaSeason.seasonNumber === season.seasonNumber
|
||||
)?.status ??
|
||||
// What our request status is
|
||||
requestedSeasons?.find(
|
||||
(s: Season) => s.seasonNumber === season.seasonNumber
|
||||
)?.status ??
|
||||
// Otherwise set it as unknown
|
||||
MediaStatus.UNKNOWN,
|
||||
};
|
||||
});
|
||||
}, [details]);
|
||||
|
||||
const allSeasonsAvailable = useMemo(() =>
|
||||
seasons?.every(season => season.status === MediaStatus.AVAILABLE),
|
||||
const allSeasonsAvailable = useMemo(
|
||||
() => seasons?.every((season) => season.status === MediaStatus.AVAILABLE),
|
||||
[seasons]
|
||||
)
|
||||
);
|
||||
|
||||
const requestAll = useCallback(() => {
|
||||
if (details && jellyseerrApi) {
|
||||
@@ -125,48 +145,77 @@ const JellyseerrSeasons: React.FC<{
|
||||
mediaType: MediaType.TV,
|
||||
tvdbId: details.externalIds?.tvdbId,
|
||||
seasons: seasons
|
||||
.filter(s => s.status === MediaStatus.UNKNOWN && s.seasonNumber !== 0)
|
||||
.map(s => s.seasonNumber)
|
||||
})
|
||||
.filter(
|
||||
(s) => s.status === MediaStatus.UNKNOWN && s.seasonNumber !== 0
|
||||
)
|
||||
.map((s) => s.seasonNumber),
|
||||
});
|
||||
}
|
||||
}, [jellyseerrApi, seasons, details])
|
||||
}, [jellyseerrApi, seasons, details]);
|
||||
|
||||
const promptRequestAll = useCallback(() => (
|
||||
Alert.alert('Request all?', 'Are you sure you want to request all seasons?', [
|
||||
{
|
||||
text: 'Cancel',
|
||||
style: 'cancel',
|
||||
},
|
||||
{
|
||||
text: 'YES',
|
||||
onPress: requestAll
|
||||
},
|
||||
])), [requestAll]);
|
||||
const promptRequestAll = useCallback(
|
||||
() =>
|
||||
Alert.alert(
|
||||
"Request all?",
|
||||
"Are you sure you want to request all seasons?",
|
||||
[
|
||||
{
|
||||
text: "Cancel",
|
||||
style: "cancel",
|
||||
},
|
||||
{
|
||||
text: "YES",
|
||||
onPress: requestAll,
|
||||
},
|
||||
]
|
||||
),
|
||||
[requestAll]
|
||||
);
|
||||
|
||||
if (isLoading)
|
||||
return (
|
||||
<View>
|
||||
<View className="flex flex-row justify-between items-end px-4">
|
||||
<Text className="text-lg font-bold mb-2">Seasons</Text>
|
||||
{!allSeasonsAvailable && (
|
||||
<RoundButton className="mb-2 pa-2" onPress={promptRequestAll}>
|
||||
<Ionicons name="bag-add" color="white" size={26} />
|
||||
</RoundButton>
|
||||
)}
|
||||
</View>
|
||||
<Loader />
|
||||
</View>
|
||||
);
|
||||
|
||||
return (
|
||||
<FlashList
|
||||
data={orderBy(details.seasons.filter(s => s.seasonNumber !== 0), 'seasonNumber', 'desc')}
|
||||
data={orderBy(
|
||||
details.seasons.filter((s) => s.seasonNumber !== 0),
|
||||
"seasonNumber",
|
||||
"desc"
|
||||
)}
|
||||
ListHeaderComponent={() => (
|
||||
<View className="flex flex-row justify-between items-end">
|
||||
<View className="flex flex-row justify-between items-end px-4">
|
||||
<Text className="text-lg font-bold mb-2">Seasons</Text>
|
||||
{!allSeasonsAvailable && (
|
||||
<RoundButton
|
||||
className="mb-2 pa-2"
|
||||
onPress={promptRequestAll}
|
||||
>
|
||||
<Ionicons name="bag-add" color="white" size={26}/>
|
||||
<RoundButton className="mb-2 pa-2" onPress={promptRequestAll}>
|
||||
<Ionicons name="bag-add" color="white" size={26} />
|
||||
</RoundButton>
|
||||
)}
|
||||
</View>
|
||||
)}
|
||||
ItemSeparatorComponent={() => <View className="h-2" />}
|
||||
estimatedItemSize={250}
|
||||
renderItem={({item: season}) => (
|
||||
renderItem={({ item: season }) => (
|
||||
<>
|
||||
<TouchableOpacity
|
||||
onPress={() => setSeasonStates((prevState) => (
|
||||
{...prevState, [season.seasonNumber]: !prevState?.[season.seasonNumber]}
|
||||
))}
|
||||
onPress={() =>
|
||||
setSeasonStates((prevState) => ({
|
||||
...prevState,
|
||||
[season.seasonNumber]: !prevState?.[season.seasonNumber],
|
||||
}))
|
||||
}
|
||||
className="px-4"
|
||||
>
|
||||
<View
|
||||
className="flex flex-row justify-between items-center bg-gray-100/10 rounded-xl z-20 h-12 w-full px-4"
|
||||
@@ -174,27 +223,43 @@ const JellyseerrSeasons: React.FC<{
|
||||
>
|
||||
<Tags
|
||||
textClass=""
|
||||
tags={[`Season ${season.seasonNumber}`, `${season.episodeCount} Episodes`]}
|
||||
tags={[
|
||||
`Season ${season.seasonNumber}`,
|
||||
`${season.episodeCount} Episodes`,
|
||||
]}
|
||||
/>
|
||||
{[0].map(() => {
|
||||
const canRequest = seasons?.find(s => s.seasonNumber === season.seasonNumber)?.status === MediaStatus.UNKNOWN
|
||||
return <JellyseerrIconStatus
|
||||
key={0}
|
||||
onPress={canRequest ? () =>
|
||||
requestMedia(
|
||||
`${result?.name!!}, Season ${season.seasonNumber}`,
|
||||
{
|
||||
mediaId: details.id,
|
||||
mediaType: MediaType.TV,
|
||||
tvdbId: details.externalIds?.tvdbId,
|
||||
seasons: [season.seasonNumber]
|
||||
}
|
||||
) : undefined
|
||||
}
|
||||
className={canRequest ? 'bg-gray-700/40' : undefined}
|
||||
mediaStatus={seasons?.find(s => s.seasonNumber === season.seasonNumber)?.status}
|
||||
showRequestIcon={canRequest}
|
||||
/>
|
||||
const canRequest =
|
||||
seasons?.find((s) => s.seasonNumber === season.seasonNumber)
|
||||
?.status === MediaStatus.UNKNOWN;
|
||||
return (
|
||||
<JellyseerrIconStatus
|
||||
key={0}
|
||||
onPress={
|
||||
canRequest
|
||||
? () =>
|
||||
requestMedia(
|
||||
`${result?.name!!}, Season ${
|
||||
season.seasonNumber
|
||||
}`,
|
||||
{
|
||||
mediaId: details.id,
|
||||
mediaType: MediaType.TV,
|
||||
tvdbId: details.externalIds?.tvdbId,
|
||||
seasons: [season.seasonNumber],
|
||||
}
|
||||
)
|
||||
: undefined
|
||||
}
|
||||
className={canRequest ? "bg-gray-700/40" : undefined}
|
||||
mediaStatus={
|
||||
seasons?.find(
|
||||
(s) => s.seasonNumber === season.seasonNumber
|
||||
)?.status
|
||||
}
|
||||
showRequestIcon={canRequest}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
@@ -206,10 +271,9 @@ const JellyseerrSeasons: React.FC<{
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
)
|
||||
}
|
||||
)}
|
||||
/>
|
||||
)
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
export default JellyseerrSeasons;
|
||||
export default JellyseerrSeasons;
|
||||
|
||||
@@ -57,8 +57,6 @@ export const MediaProvider = ({ children }: { children: ReactNode }) => {
|
||||
|
||||
updateSettings(update);
|
||||
|
||||
console.log("update", update);
|
||||
|
||||
let updatePayload = {
|
||||
SubtitleMode: update?.subtitleMode ?? settings?.subtitleMode,
|
||||
PlayDefaultAudioTrack:
|
||||
@@ -84,8 +82,6 @@ export const MediaProvider = ({ children }: { children: ReactNode }) => {
|
||||
settings?.defaultSubtitleLanguage?.ThreeLetterISOLanguageName ||
|
||||
"";
|
||||
|
||||
console.log("updatePayload", updatePayload);
|
||||
|
||||
updateUserConfiguration(updatePayload);
|
||||
};
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ const AudioSlider: React.FC<AudioSliderProps> = ({ setVisibility }) => {
|
||||
const fetchInitialVolume = async () => {
|
||||
try {
|
||||
const { volume: initialVolume } = await VolumeManager.getVolume();
|
||||
console.log("initialVolume", initialVolume);
|
||||
volume.value = initialVolume * 100;
|
||||
} catch (error) {
|
||||
console.error("Error fetching initial volume:", error);
|
||||
@@ -39,7 +38,6 @@ const AudioSlider: React.FC<AudioSliderProps> = ({ setVisibility }) => {
|
||||
|
||||
const handleValueChange = async (value: number) => {
|
||||
volume.value = value;
|
||||
console.log("volume through slider", value);
|
||||
await VolumeManager.setVolume(value / 100);
|
||||
|
||||
// Re-call showNativeVolumeUI to ensure the setting is applied on iOS
|
||||
@@ -48,7 +46,6 @@ const AudioSlider: React.FC<AudioSliderProps> = ({ setVisibility }) => {
|
||||
|
||||
useEffect(() => {
|
||||
const volumeListener = VolumeManager.addVolumeListener((result) => {
|
||||
console.log("Volume through device", result.volume);
|
||||
volume.value = result.volume * 100;
|
||||
setVisibility(true);
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ const BrightnessSlider = () => {
|
||||
useEffect(() => {
|
||||
const fetchInitialBrightness = async () => {
|
||||
const initialBrightness = await Brightness.getBrightnessAsync();
|
||||
console.log("initialBrightness", initialBrightness);
|
||||
brightness.value = initialBrightness * 100;
|
||||
};
|
||||
fetchInitialBrightness();
|
||||
|
||||
@@ -240,8 +240,6 @@ export const Controls: React.FC<Props> = ({
|
||||
? maxValue - currentProgress
|
||||
: ticksToSeconds(maxValue - currentProgress);
|
||||
|
||||
console.log("remaining: ", remaining);
|
||||
|
||||
setCurrentTime(current);
|
||||
setRemainingTime(remaining);
|
||||
},
|
||||
@@ -349,7 +347,6 @@ export const Controls: React.FC<Props> = ({
|
||||
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);
|
||||
try {
|
||||
const curr = progress.value;
|
||||
console.log(curr);
|
||||
if (curr !== undefined) {
|
||||
const newTime = isVlc
|
||||
? curr + secondsToMs(settings.forwardSkipTime)
|
||||
@@ -375,8 +372,6 @@ export const Controls: React.FC<Props> = ({
|
||||
const tileWidth = 150;
|
||||
const tileHeight = 150 / trickplayInfo.aspectRatio!;
|
||||
|
||||
console.log("time, ", time);
|
||||
|
||||
return (
|
||||
<View
|
||||
style={{
|
||||
|
||||
@@ -35,7 +35,6 @@ const NextEpisodeCountDownButton: React.FC<NextEpisodeCountDownButtonProps> = ({
|
||||
},
|
||||
(finished) => {
|
||||
if (finished && onFinish) {
|
||||
console.log("finish");
|
||||
runOnJS(onFinish)();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,19 +106,12 @@ const DropdownViewDirect: React.FC<DropdownViewDirectProps> = ({
|
||||
if ("deliveryUrl" in sub && sub.deliveryUrl) {
|
||||
setSubtitleURL &&
|
||||
setSubtitleURL(api?.basePath + sub.deliveryUrl, sub.name);
|
||||
|
||||
console.log(
|
||||
"Set external subtitle: ",
|
||||
api?.basePath + sub.deliveryUrl
|
||||
);
|
||||
} else {
|
||||
console.log("Set sub index: ", sub.index);
|
||||
setSubtitleTrack && setSubtitleTrack(sub.index);
|
||||
}
|
||||
router.setParams({
|
||||
subtitleIndex: sub.index.toString(),
|
||||
});
|
||||
console.log("Subtitle: ", sub);
|
||||
}}
|
||||
>
|
||||
<DropdownMenu.ItemTitle key={`subtitle-item-title-${idx}`}>
|
||||
|
||||
@@ -66,7 +66,6 @@ const DropdownView: React.FC<DropdownViewProps> = ({ showControls }) => {
|
||||
|
||||
const sortedSubtitles = subtitleHelper.getSortedSubtitles(textSubtitles);
|
||||
|
||||
console.log("sortedSubtitles", sortedSubtitles);
|
||||
return [disableSubtitle, ...sortedSubtitles];
|
||||
}
|
||||
|
||||
@@ -104,7 +103,6 @@ const DropdownView: React.FC<DropdownViewProps> = ({ showControls }) => {
|
||||
|
||||
const ChangeTranscodingAudio = useCallback(
|
||||
(audioIndex: number) => {
|
||||
console.log("ChangeTranscodingAudio", subtitleIndex, audioIndex);
|
||||
const queryParams = new URLSearchParams({
|
||||
itemId: item.Id ?? "", // Ensure itemId is a string
|
||||
audioIndex: audioIndex?.toString() ?? "",
|
||||
@@ -167,7 +165,6 @@ const DropdownView: React.FC<DropdownViewProps> = ({ showControls }) => {
|
||||
}
|
||||
key={`subtitle-item-${idx}`}
|
||||
onValueChange={() => {
|
||||
console.log("sub", sub);
|
||||
if (
|
||||
subtitleIndex ===
|
||||
(isOnTextSubtitle && sub.IsTextSubtitleStream
|
||||
@@ -216,7 +213,6 @@ const DropdownView: React.FC<DropdownViewProps> = ({ showControls }) => {
|
||||
value={audioIndex === track.index.toString()}
|
||||
onValueChange={() => {
|
||||
if (audioIndex === track.index.toString()) return;
|
||||
console.log("Setting audio track to: ", track.index);
|
||||
router.setParams({
|
||||
audioIndex: track.index.toString(),
|
||||
});
|
||||
|
||||
@@ -76,7 +76,6 @@ export const useIntroSkipper = (
|
||||
}, [introTimestamps, currentTime]);
|
||||
|
||||
const skipIntro = useCallback(() => {
|
||||
console.log("skipIntro");
|
||||
if (!introTimestamps) return;
|
||||
try {
|
||||
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);
|
||||
|
||||
@@ -1,45 +1,54 @@
|
||||
import axios, {AxiosError, AxiosInstance} from "axios";
|
||||
import {Results} from "@/utils/jellyseerr/server/models/Search";
|
||||
import axios, { AxiosError, AxiosInstance } from "axios";
|
||||
import { Results } from "@/utils/jellyseerr/server/models/Search";
|
||||
import { storage } from "@/utils/mmkv";
|
||||
import {inRange} from "lodash";
|
||||
import {User as JellyseerrUser} from "@/utils/jellyseerr/server/entity/User";
|
||||
import {atom} from "jotai";
|
||||
import {useAtom} from "jotai/index";
|
||||
import { inRange } from "lodash";
|
||||
import { User as JellyseerrUser } from "@/utils/jellyseerr/server/entity/User";
|
||||
import { atom } from "jotai";
|
||||
import { useAtom } from "jotai/index";
|
||||
import "@/augmentations";
|
||||
import {useCallback, useMemo} from "react";
|
||||
import {useSettings} from "@/utils/atoms/settings";
|
||||
import {toast} from "sonner-native";
|
||||
import {MediaRequestStatus, MediaType} from "@/utils/jellyseerr/server/constants/media";
|
||||
import { useCallback, useMemo } from "react";
|
||||
import { useSettings } from "@/utils/atoms/settings";
|
||||
import { toast } from "sonner-native";
|
||||
import {
|
||||
MediaRequestStatus,
|
||||
MediaType,
|
||||
} from "@/utils/jellyseerr/server/constants/media";
|
||||
import MediaRequest from "@/utils/jellyseerr/server/entity/MediaRequest";
|
||||
import {MediaRequestBody} from "@/utils/jellyseerr/server/interfaces/api/requestInterfaces";
|
||||
import {MovieDetails} from "@/utils/jellyseerr/server/models/Movie";
|
||||
import {SeasonWithEpisodes, TvDetails} from "@/utils/jellyseerr/server/models/Tv";
|
||||
import {IssueStatus, IssueType} from "@/utils/jellyseerr/server/constants/issue";
|
||||
import { MediaRequestBody } from "@/utils/jellyseerr/server/interfaces/api/requestInterfaces";
|
||||
import { MovieDetails } from "@/utils/jellyseerr/server/models/Movie";
|
||||
import {
|
||||
SeasonWithEpisodes,
|
||||
TvDetails,
|
||||
} from "@/utils/jellyseerr/server/models/Tv";
|
||||
import {
|
||||
IssueStatus,
|
||||
IssueType,
|
||||
} from "@/utils/jellyseerr/server/constants/issue";
|
||||
import Issue from "@/utils/jellyseerr/server/entity/Issue";
|
||||
import {RTRating} from "@/utils/jellyseerr/server/api/rating/rottentomatoes";
|
||||
import {writeErrorLog} from "@/utils/log";
|
||||
import { RTRating } from "@/utils/jellyseerr/server/api/rating/rottentomatoes";
|
||||
import { writeErrorLog } from "@/utils/log";
|
||||
import DiscoverSlider from "@/utils/jellyseerr/server/entity/DiscoverSlider";
|
||||
|
||||
interface SearchParams {
|
||||
query: string,
|
||||
page: number,
|
||||
query: string;
|
||||
page: number;
|
||||
language: string;
|
||||
}
|
||||
|
||||
interface SearchResults {
|
||||
page: number,
|
||||
totalPages: number,
|
||||
page: number;
|
||||
totalPages: number;
|
||||
totalResults: number;
|
||||
results: Results[];
|
||||
}
|
||||
|
||||
const JELLYSEERR_USER = "JELLYSEERR_USER"
|
||||
const JELLYSEERR_COOKIES = "JELLYSEERR_COOKIES"
|
||||
const JELLYSEERR_USER = "JELLYSEERR_USER";
|
||||
const JELLYSEERR_COOKIES = "JELLYSEERR_COOKIES";
|
||||
|
||||
export const clearJellyseerrStorageData = () => {
|
||||
storage.delete(JELLYSEERR_USER);
|
||||
storage.delete(JELLYSEERR_COOKIES);
|
||||
}
|
||||
};
|
||||
|
||||
export enum Endpoints {
|
||||
STATUS = "/status",
|
||||
@@ -58,24 +67,29 @@ export enum Endpoints {
|
||||
AUTH_JELLYFIN = "/auth/jellyfin",
|
||||
}
|
||||
|
||||
export type DiscoverEndpoint = Endpoints.DISCOVER_TRENDING | Endpoints.DISCOVER_MOVIES | Endpoints.DISCOVER_TV;
|
||||
export type DiscoverEndpoint =
|
||||
| Endpoints.DISCOVER_TRENDING
|
||||
| Endpoints.DISCOVER_MOVIES
|
||||
| Endpoints.DISCOVER_TV;
|
||||
|
||||
export type TestResult = {
|
||||
isValid: true;
|
||||
requiresPass: boolean;
|
||||
} | {
|
||||
isValid: false;
|
||||
};
|
||||
export type TestResult =
|
||||
| {
|
||||
isValid: true;
|
||||
requiresPass: boolean;
|
||||
}
|
||||
| {
|
||||
isValid: false;
|
||||
};
|
||||
|
||||
export class JellyseerrApi {
|
||||
axios: AxiosInstance;
|
||||
|
||||
constructor (baseUrl: string) {
|
||||
constructor(baseUrl: string) {
|
||||
this.axios = axios.create({
|
||||
baseURL: baseUrl,
|
||||
withCredentials: true,
|
||||
withXSRFToken: true,
|
||||
xsrfHeaderName: "XSRF-TOKEN"
|
||||
xsrfHeaderName: "XSRF-TOKEN",
|
||||
});
|
||||
|
||||
this.setInterceptors();
|
||||
@@ -86,132 +100,169 @@ export class JellyseerrApi {
|
||||
const cookies = storage.get<string[]>(JELLYSEERR_COOKIES);
|
||||
|
||||
if (user && cookies) {
|
||||
console.log("User & cookies data exist for jellyseerr")
|
||||
return Promise.resolve({
|
||||
isValid: true,
|
||||
requiresPass: false
|
||||
requiresPass: false,
|
||||
});
|
||||
}
|
||||
|
||||
console.log("Testing jellyseerr connection")
|
||||
return await this.axios.get(Endpoints.API_V1 + Endpoints.STATUS)
|
||||
return await this.axios
|
||||
.get(Endpoints.API_V1 + Endpoints.STATUS)
|
||||
.then((response) => {
|
||||
const {status, headers, data} = response;
|
||||
const { status, headers, data } = response;
|
||||
if (inRange(status, 200, 299)) {
|
||||
if (data.version < "2.0.0") {
|
||||
const error = "Jellyseerr server does not meet minimum version requirements! Please update to at least 2.0.0";
|
||||
const error =
|
||||
"Jellyseerr server does not meet minimum version requirements! Please update to at least 2.0.0";
|
||||
toast.error(error);
|
||||
throw Error(error);
|
||||
}
|
||||
|
||||
console.log("Jellyseerr connecting successfully tested!");
|
||||
storage.setAny(JELLYSEERR_COOKIES, headers["set-cookie"]?.flatMap(c => c.split("; ")) ?? []);
|
||||
storage.setAny(
|
||||
JELLYSEERR_COOKIES,
|
||||
headers["set-cookie"]?.flatMap((c) => c.split("; ")) ?? []
|
||||
);
|
||||
return {
|
||||
isValid: true,
|
||||
requiresPass: true
|
||||
requiresPass: true,
|
||||
};
|
||||
}
|
||||
toast.error(`Jellyseerr test failed. Please try again.`);
|
||||
writeErrorLog(
|
||||
`Jellyseerr returned a ${status} for url:\n` +
|
||||
response.config.url + '\n' +
|
||||
JSON.stringify(response.data)
|
||||
response.config.url +
|
||||
"\n" +
|
||||
JSON.stringify(response.data)
|
||||
);
|
||||
return {
|
||||
isValid: false,
|
||||
requiresPass: false
|
||||
requiresPass: false,
|
||||
};
|
||||
})
|
||||
.catch((e) => {
|
||||
const msg = "Failed to test jellyseerr server url";
|
||||
toast.error(msg)
|
||||
console.error(msg, e)
|
||||
toast.error(msg);
|
||||
console.error(msg, e);
|
||||
return {
|
||||
isValid: false,
|
||||
requiresPass: false
|
||||
requiresPass: false,
|
||||
};
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
async login(username: string, password: string): Promise<JellyseerrUser> {
|
||||
return this.axios?.post<JellyseerrUser>(Endpoints.API_V1 + Endpoints.AUTH_JELLYFIN, {
|
||||
username,
|
||||
password,
|
||||
email: username
|
||||
}).then(response => {
|
||||
const user = response?.data;
|
||||
if (!user)
|
||||
throw Error("Login failed")
|
||||
storage.setAny(JELLYSEERR_USER, user);
|
||||
return user
|
||||
})
|
||||
return this.axios
|
||||
?.post<JellyseerrUser>(Endpoints.API_V1 + Endpoints.AUTH_JELLYFIN, {
|
||||
username,
|
||||
password,
|
||||
email: username,
|
||||
})
|
||||
.then((response) => {
|
||||
const user = response?.data;
|
||||
if (!user) throw Error("Login failed");
|
||||
storage.setAny(JELLYSEERR_USER, user);
|
||||
return user;
|
||||
});
|
||||
}
|
||||
|
||||
async discoverSettings(): Promise<DiscoverSlider[]> {
|
||||
return this.axios?.get<DiscoverSlider[]>(Endpoints.API_V1 + Endpoints.SETTINGS + Endpoints.DISCOVER)
|
||||
.then(({data}) => data)
|
||||
return this.axios
|
||||
?.get<DiscoverSlider[]>(
|
||||
Endpoints.API_V1 + Endpoints.SETTINGS + Endpoints.DISCOVER
|
||||
)
|
||||
.then(({ data }) => data);
|
||||
}
|
||||
|
||||
async discover(endpoint: DiscoverEndpoint, params: any): Promise<SearchResults> {
|
||||
return this.axios?.get<SearchResults>(Endpoints.API_V1 + endpoint, { params })
|
||||
.then(({data}) => data)
|
||||
async discover(
|
||||
endpoint: DiscoverEndpoint,
|
||||
params: any
|
||||
): Promise<SearchResults> {
|
||||
return this.axios
|
||||
?.get<SearchResults>(Endpoints.API_V1 + endpoint, { params })
|
||||
.then(({ data }) => data);
|
||||
}
|
||||
|
||||
async search(params: SearchParams): Promise<SearchResults> {
|
||||
const response = await this.axios?.get<SearchResults>(Endpoints.API_V1 + Endpoints.SEARCH, {params})
|
||||
return response?.data
|
||||
const response = await this.axios?.get<SearchResults>(
|
||||
Endpoints.API_V1 + Endpoints.SEARCH,
|
||||
{ params }
|
||||
);
|
||||
return response?.data;
|
||||
}
|
||||
|
||||
async request(request: MediaRequestBody): Promise<MediaRequest> {
|
||||
return this.axios?.post<MediaRequest>(Endpoints.API_V1 + Endpoints.REQUEST, request)
|
||||
.then(({data}) => data)
|
||||
return this.axios
|
||||
?.post<MediaRequest>(Endpoints.API_V1 + Endpoints.REQUEST, request)
|
||||
.then(({ data }) => data);
|
||||
}
|
||||
|
||||
async movieDetails(id: number) {
|
||||
return this.axios?.get<MovieDetails>(Endpoints.API_V1 + Endpoints.MOVIE + `/${id}`).then(response => {
|
||||
return response?.data
|
||||
})
|
||||
return this.axios
|
||||
?.get<MovieDetails>(Endpoints.API_V1 + Endpoints.MOVIE + `/${id}`)
|
||||
.then((response) => {
|
||||
return response?.data;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
async movieRatings(id: number) {
|
||||
return this.axios?.get<RTRating>(`${Endpoints.API_V1}${Endpoints.MOVIE}/${id}${Endpoints.RATINGS}`)
|
||||
.then(({data}) => data)
|
||||
return this.axios
|
||||
?.get<RTRating>(
|
||||
`${Endpoints.API_V1}${Endpoints.MOVIE}/${id}${Endpoints.RATINGS}`
|
||||
)
|
||||
.then(({ data }) => data);
|
||||
}
|
||||
|
||||
async tvDetails(id: number) {
|
||||
return this.axios?.get<TvDetails>(`${Endpoints.API_V1}${Endpoints.TV}/${id}`).then(response => {
|
||||
return response?.data
|
||||
})
|
||||
return this.axios
|
||||
?.get<TvDetails>(`${Endpoints.API_V1}${Endpoints.TV}/${id}`)
|
||||
.then((response) => {
|
||||
return response?.data;
|
||||
});
|
||||
}
|
||||
|
||||
async tvRatings(id: number) {
|
||||
return this.axios?.get<RTRating>(`${Endpoints.API_V1}${Endpoints.TV}/${id}${Endpoints.RATINGS}`)
|
||||
.then(({data}) => data)
|
||||
return this.axios
|
||||
?.get<RTRating>(
|
||||
`${Endpoints.API_V1}${Endpoints.TV}/${id}${Endpoints.RATINGS}`
|
||||
)
|
||||
.then(({ data }) => data);
|
||||
}
|
||||
|
||||
async tvSeason(id: number, seasonId: number) {
|
||||
return this.axios?.get<SeasonWithEpisodes>(`${Endpoints.API_V1}${Endpoints.TV}/${id}/season/${seasonId}`).then(response => {
|
||||
console.log(response.data.episodes)
|
||||
return response?.data
|
||||
})
|
||||
return this.axios
|
||||
?.get<SeasonWithEpisodes>(
|
||||
`${Endpoints.API_V1}${Endpoints.TV}/${id}/season/${seasonId}`
|
||||
)
|
||||
.then((response) => {
|
||||
return response?.data;
|
||||
});
|
||||
}
|
||||
|
||||
tvStillImageProxy(path: string, width: number = 1920, quality: number = 75) {
|
||||
return this.axios.defaults.baseURL + `/_next/image?` + new URLSearchParams(`url=https://image.tmdb.org/t/p/original/${path}&w=${width}&q=${quality}`).toString()
|
||||
return (
|
||||
this.axios.defaults.baseURL +
|
||||
`/_next/image?` +
|
||||
new URLSearchParams(
|
||||
`url=https://image.tmdb.org/t/p/original/${path}&w=${width}&q=${quality}`
|
||||
).toString()
|
||||
);
|
||||
}
|
||||
|
||||
async submitIssue(mediaId: number, issueType: IssueType, message: string) {
|
||||
return this.axios?.post<Issue>(Endpoints.API_V1 + Endpoints.ISSUE, {
|
||||
mediaId, issueType, message
|
||||
}).then((response) => {
|
||||
const issue = response.data
|
||||
return this.axios
|
||||
?.post<Issue>(Endpoints.API_V1 + Endpoints.ISSUE, {
|
||||
mediaId,
|
||||
issueType,
|
||||
message,
|
||||
})
|
||||
.then((response) => {
|
||||
const issue = response.data;
|
||||
|
||||
if (issue.status === IssueStatus.OPEN) {
|
||||
toast.success("Issue submitted!")
|
||||
}
|
||||
return issue
|
||||
})
|
||||
if (issue.status === IssueStatus.OPEN) {
|
||||
toast.success("Issue submitted!");
|
||||
}
|
||||
return issue;
|
||||
});
|
||||
}
|
||||
|
||||
private setInterceptors() {
|
||||
@@ -219,7 +270,10 @@ export class JellyseerrApi {
|
||||
async (response) => {
|
||||
const cookies = response.headers["set-cookie"];
|
||||
if (cookies) {
|
||||
storage.setAny(JELLYSEERR_COOKIES, response.headers["set-cookie"]?.flatMap(c => c.split("; ")));
|
||||
storage.setAny(
|
||||
JELLYSEERR_COOKIES,
|
||||
response.headers["set-cookie"]?.flatMap((c) => c.split("; "))
|
||||
);
|
||||
}
|
||||
return response;
|
||||
},
|
||||
@@ -227,16 +281,17 @@ export class JellyseerrApi {
|
||||
const errorMsg = "Jellyseerr response error";
|
||||
console.error(errorMsg, error, error.response?.data);
|
||||
writeErrorLog(
|
||||
errorMsg + `\n` +
|
||||
`error: ${error.toString()}\n` +
|
||||
`url: ${error?.config?.url}\n` +
|
||||
`data:\n` +
|
||||
JSON.stringify(error.response?.data)
|
||||
errorMsg +
|
||||
`\n` +
|
||||
`error: ${error.toString()}\n` +
|
||||
`url: ${error?.config?.url}\n` +
|
||||
`data:\n` +
|
||||
JSON.stringify(error.response?.data)
|
||||
);
|
||||
if (error.status === 403) {
|
||||
clearJellyseerrStorageData()
|
||||
clearJellyseerrStorageData();
|
||||
}
|
||||
return Promise.reject(error)
|
||||
return Promise.reject(error);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -246,22 +301,22 @@ export class JellyseerrApi {
|
||||
if (cookies) {
|
||||
const headerName = this.axios.defaults.xsrfHeaderName!!;
|
||||
const xsrfToken = cookies
|
||||
.find(c => c.includes(headerName))
|
||||
?.split(headerName + "=")?.[1]
|
||||
.find((c) => c.includes(headerName))
|
||||
?.split(headerName + "=")?.[1];
|
||||
if (xsrfToken) {
|
||||
config.headers[headerName] = xsrfToken;
|
||||
}
|
||||
}
|
||||
return config
|
||||
return config;
|
||||
},
|
||||
(error) => {
|
||||
console.error("Jellyseerr request error", error)
|
||||
console.error("Jellyseerr request error", error);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const jellyseerrUserAtom = atom(storage.get<JellyseerrUser>(JELLYSEERR_USER))
|
||||
const jellyseerrUserAtom = atom(storage.get<JellyseerrUser>(JELLYSEERR_USER));
|
||||
|
||||
export const useJellyseerr = () => {
|
||||
const [jellyseerrUser, setJellyseerrUser] = useAtom(jellyseerrUserAtom);
|
||||
@@ -270,43 +325,47 @@ export const useJellyseerr = () => {
|
||||
const jellyseerrApi = useMemo(() => {
|
||||
const cookies = storage.get<string[]>(JELLYSEERR_COOKIES);
|
||||
if (settings?.jellyseerrServerUrl && cookies && jellyseerrUser) {
|
||||
return new JellyseerrApi(settings?.jellyseerrServerUrl)
|
||||
return new JellyseerrApi(settings?.jellyseerrServerUrl);
|
||||
}
|
||||
return undefined
|
||||
}, [settings?.jellyseerrServerUrl, jellyseerrUser])
|
||||
return undefined;
|
||||
}, [settings?.jellyseerrServerUrl, jellyseerrUser]);
|
||||
|
||||
const clearAllJellyseerData = useCallback(async () => {
|
||||
clearJellyseerrStorageData()
|
||||
clearJellyseerrStorageData();
|
||||
setJellyseerrUser(undefined);
|
||||
updateSettings({jellyseerrServerUrl: undefined})
|
||||
updateSettings({ jellyseerrServerUrl: undefined });
|
||||
}, []);
|
||||
|
||||
const requestMedia = useCallback((
|
||||
title: string,
|
||||
request: MediaRequestBody,
|
||||
) => {
|
||||
jellyseerrApi?.request?.(request)?.then((mediaRequest) => {
|
||||
switch (mediaRequest.status) {
|
||||
case MediaRequestStatus.PENDING:
|
||||
case MediaRequestStatus.APPROVED:
|
||||
toast.success(`Requested ${title}!`)
|
||||
break;
|
||||
case MediaRequestStatus.DECLINED:
|
||||
toast.error(`You don't have permission to request!`)
|
||||
break;
|
||||
case MediaRequestStatus.FAILED:
|
||||
toast.error(`Something went wrong requesting media!`)
|
||||
break;
|
||||
}
|
||||
})
|
||||
}, [jellyseerrApi])
|
||||
const requestMedia = useCallback(
|
||||
(title: string, request: MediaRequestBody) => {
|
||||
jellyseerrApi?.request?.(request)?.then((mediaRequest) => {
|
||||
switch (mediaRequest.status) {
|
||||
case MediaRequestStatus.PENDING:
|
||||
case MediaRequestStatus.APPROVED:
|
||||
toast.success(`Requested ${title}!`);
|
||||
break;
|
||||
case MediaRequestStatus.DECLINED:
|
||||
toast.error(`You don't have permission to request!`);
|
||||
break;
|
||||
case MediaRequestStatus.FAILED:
|
||||
toast.error(`Something went wrong requesting media!`);
|
||||
break;
|
||||
}
|
||||
});
|
||||
},
|
||||
[jellyseerrApi]
|
||||
);
|
||||
|
||||
const isJellyseerrResult = (items: any[] | null | undefined): items is Results[] => {
|
||||
const isJellyseerrResult = (
|
||||
items: any[] | null | undefined
|
||||
): items is Results[] => {
|
||||
return (
|
||||
!items ||
|
||||
items.length >= 0 && Object.hasOwn(items[0], "mediaType") && Object.values(MediaType).includes(items[0]['mediaType'])
|
||||
)
|
||||
}
|
||||
(items.length >= 0 &&
|
||||
Object.hasOwn(items[0], "mediaType") &&
|
||||
Object.values(MediaType).includes(items[0]["mediaType"]))
|
||||
);
|
||||
};
|
||||
|
||||
return {
|
||||
jellyseerrApi,
|
||||
@@ -314,6 +373,6 @@ export const useJellyseerr = () => {
|
||||
setJellyseerrUser,
|
||||
clearAllJellyseerData,
|
||||
isJellyseerrResult,
|
||||
requestMedia
|
||||
}
|
||||
requestMedia,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user