Skip to content

Commit 759a86a

Browse files
Merge pull request OwnTube-tv#371 from mykhailodanilenko/feature/premium-content-disabling
Restrict access to premium videos
2 parents fc3de0c + 852b6d5 commit 759a86a

5 files changed

Lines changed: 33 additions & 5 deletions

File tree

OwnTube.tv/locales/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,5 +147,6 @@
147147
"liveStreamOffline": "Live stream is currently offline",
148148
"streamingNow": "Streaming now",
149149
"offline": "Offline",
150-
"privacyPolicy": "Privacy policy"
150+
"privacyPolicy": "Privacy policy",
151+
"premiumVideoUnavailable": "Den här videon är inte tillgänglig för tillfället på grund av begränsningar för premiuminnehåll"
151152
}

OwnTube.tv/locales/ru.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,5 +146,6 @@
146146
"liveStreamOffline": "Трансляция сейчас не в эфире",
147147
"streamingNow": "Сейчас в эфире",
148148
"offline": "Не в эфире",
149-
"privacyPolicy": "Политика конфиденциальности"
149+
"privacyPolicy": "Политика конфиденциальности",
150+
"premiumVideoUnavailable": "Это видео сейчас недоступно из-за ограничений премиум-контента"
150151
}

OwnTube.tv/locales/sv.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,5 +147,6 @@
147147
"liveStreamOffline": "Direktsändningen är för närvarande offline",
148148
"streamingNow": "Direktsändning pågår",
149149
"offline": "Offline",
150-
"privacyPolicy": "Integritetspolicy"
150+
"privacyPolicy": "Integritetspolicy",
151+
"premiumVideoUnavailable": "Це відео зараз недоступне через обмеження преміум-контенту"
151152
}

OwnTube.tv/locales/uk.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,5 +146,6 @@
146146
"liveStreamOffline": "Трансляція зараз не в етері",
147147
"streamingNow": "Зараз в етері",
148148
"offline": "Не в етері",
149-
"privacyPolicy": "Політика конфіденційності"
149+
"privacyPolicy": "Політика конфіденційності",
150+
"premiumVideoUnavailable": "Це відео зараз недоступне через обмеження преміум-контенту"
150151
}

OwnTube.tv/screens/VideoScreen/index.tsx

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { RootStackParams } from "../../app/_layout";
44
import { ROUTES } from "../../types";
55
import { useGetVideoCaptionsQuery, useGetVideoQuery } from "../../api";
66
import { useCallback, useEffect, useMemo, useState } from "react";
7-
import { Loader, FocusWrapper, FullScreenModal, ErrorTextWithRetry, Button } from "../../components";
7+
import { Loader, FocusWrapper, FullScreenModal, ErrorTextWithRetry, Button, Typography } from "../../components";
88
import { useViewHistory } from "../../hooks";
99
import { StatusBar } from "expo-status-bar";
1010
import { Settings } from "../../components/VideoControlsOverlay/components/modals";
@@ -15,6 +15,8 @@ import useFullScreenVideoPlayback from "../../hooks/useFullScreenVideoPlayback";
1515
import Share from "../../components/VideoControlsOverlay/components/modals/Share";
1616
import VideoDetails from "../../components/VideoControlsOverlay/components/modals/VideoDetails";
1717
import { colorSchemes, spacing } from "../../theme";
18+
import { useTheme } from "@react-navigation/native";
19+
import { ErrorUnavailableLogo } from "../../components/Svg";
1820

1921
export const VideoScreen = () => {
2022
const { t } = useTranslation();
@@ -26,8 +28,10 @@ export const VideoScreen = () => {
2628
const { isFullscreen, toggleFullscreen } = useFullScreenVideoPlayback();
2729
const { top } = useSafeAreaInsets();
2830
const [quality, setQuality] = useState("auto");
31+
const { colors } = useTheme();
2932

3033
const isWaitingForLive = data?.state?.id === 4;
34+
const isPremiumVideo = [true, "true"].includes(data?.pluginData?.["is-premium-content"]);
3135

3236
useEffect(() => {
3337
if (data && params?.backend) {
@@ -116,6 +120,18 @@ export const VideoScreen = () => {
116120
);
117121
}
118122

123+
if (isPremiumVideo) {
124+
return (
125+
<View style={[{ paddingTop: top, backgroundColor: colors.theme50 }, styles.flex1]}>
126+
<Button onPress={handleBackButtonPress} contrast="low" icon="Arrow-Left" style={styles.backButton} />
127+
<View style={styles.premiumRestrictionContainer}>
128+
<ErrorUnavailableLogo />
129+
<Typography style={styles.premiumRestrictionText}>{t("premiumVideoUnavailable")}</Typography>
130+
</View>
131+
</View>
132+
);
133+
}
134+
119135
if (!uri && !isWaitingForLive) {
120136
return null;
121137
}
@@ -176,6 +192,14 @@ const styles = StyleSheet.create({
176192
backButton: { alignSelf: "flex-start", height: 48, margin: spacing.sm, width: 48 },
177193
errorContainer: { alignItems: "center", flex: 1, height: "100%", justifyContent: "center", width: "100%" },
178194
flex1: { flex: 1 },
195+
premiumRestrictionContainer: {
196+
alignItems: "center",
197+
flex: 1,
198+
gap: spacing.xl,
199+
justifyContent: "center",
200+
paddingHorizontal: spacing.xl,
201+
},
202+
premiumRestrictionText: { textAlign: "center" },
179203
statusBarUnderlay: { backgroundColor: colorSchemes.dark.colors.black100, width: "100%" },
180204
videoContainer: { minHeight: "100%", minWidth: "100%" },
181205
});

0 commit comments

Comments
 (0)