diff --git a/tubearchivist/www/src/components/Nav.tsx b/tubearchivist/www/src/components/Nav.tsx index 9767aeb..16558bd 100644 --- a/tubearchivist/www/src/components/Nav.tsx +++ b/tubearchivist/www/src/components/Nav.tsx @@ -9,6 +9,14 @@ import { signIn, signOut, useSession } from "next-auth/react"; /** TODO: Fix these nav links */ export const Nav = () => { const { data: session } = useSession(); + + const handleSigninSignout = () => { + if (!session) { + signIn(); + } + signOut(); + }; + return (
@@ -40,9 +48,11 @@ export const Nav = () => {
channels
- -
playlists
-
+ + +
playlists
+
+
downloads
@@ -66,10 +76,7 @@ export const Nav = () => { title="Settings" /> - signOut() : () => signIn()} - > + { +const VideoList = () => { const [selectedVideoUrl, setSelectedVideoUrl] = useState(); const [viewStyle, setViewStyle] = useState("grid"); const { data: session } = useSession(); const { data, error, isLoading } = useQuery( - ["videos", session?.ta_token?.token], + ["videos", session.ta_token.token], () => getVideos(session.ta_token.token), { enabled: !!session?.ta_token?.token, @@ -134,13 +134,13 @@ export const VideoList = () => { >
- video-thumb {/* {% if video.source.player.progress %} */}
{ ); }; + +export default VideoList; diff --git a/tubearchivist/www/src/components/VideoList/index.ts b/tubearchivist/www/src/components/VideoList/index.ts new file mode 100644 index 0000000..3d65821 --- /dev/null +++ b/tubearchivist/www/src/components/VideoList/index.ts @@ -0,0 +1,4 @@ +import dynamic from "next/dynamic"; + +const DynamicVideoList = dynamic(() => import("./VideoList")); +export default DynamicVideoList; diff --git a/tubearchivist/www/src/components/VideoPlayer.tsx b/tubearchivist/www/src/components/VideoPlayer/VideoPlayer.tsx similarity index 88% rename from tubearchivist/www/src/components/VideoPlayer.tsx rename to tubearchivist/www/src/components/VideoPlayer/VideoPlayer.tsx index e51047b..fe4ae8a 100644 --- a/tubearchivist/www/src/components/VideoPlayer.tsx +++ b/tubearchivist/www/src/components/VideoPlayer/VideoPlayer.tsx @@ -1,10 +1,10 @@ import NextImage from "next/image"; import ReactPlayer from "react-player"; -import IconClose from "../images/icon-close.svg"; -import { TA_BASE_URL } from "../lib/constants"; -import { formatNumbers } from "../lib/utils"; +import { TA_BASE_URL } from "../../lib/constants"; +import { formatNumbers } from "../../lib/utils"; +import IconClose from "../../images/icon-close.svg"; -export const VideoPlayer = ({ selectedVideoUrl, handleRemoveVideoPlayer }) => { +const VideoPlayer = ({ selectedVideoUrl, handleRemoveVideoPlayer }) => { if (!selectedVideoUrl) return; return ( <> @@ -62,3 +62,5 @@ export const VideoPlayer = ({ selectedVideoUrl, handleRemoveVideoPlayer }) => { ); }; + +export default VideoPlayer; diff --git a/tubearchivist/www/src/components/VideoPlayer/index.tsx b/tubearchivist/www/src/components/VideoPlayer/index.tsx new file mode 100644 index 0000000..42248ec --- /dev/null +++ b/tubearchivist/www/src/components/VideoPlayer/index.tsx @@ -0,0 +1,4 @@ +import dynamic from "next/dynamic"; + +const DynamicVideoPlayer = dynamic(() => import("./VideoPlayer")); +export default DynamicVideoPlayer; diff --git a/tubearchivist/www/src/pages/channel.tsx b/tubearchivist/www/src/pages/channel.tsx index 8cc36ef..da09c2b 100644 --- a/tubearchivist/www/src/pages/channel.tsx +++ b/tubearchivist/www/src/pages/channel.tsx @@ -22,7 +22,7 @@ export const getServerSideProps: GetServerSideProps = async (context) => { }; } - await queryClient.prefetchQuery("channels", () => + await queryClient.prefetchQuery(["channels", session.ta_token.token], () => getChannels(session.ta_token.token) ); @@ -40,9 +40,13 @@ const Channel: NextPage = () => { data: channels, error, isLoading, - } = useQuery("channels", () => getChannels(session.ta_token.token), { - enabled: !!session?.ta_token?.token, - }); + } = useQuery( + ["channels", session.ta_token.token], + () => getChannels(session.ta_token.token), + { + enabled: !!session?.ta_token?.token, + } + ); const [viewStyle, setViewStyle] = useState("grid"); diff --git a/tubearchivist/www/src/pages/index.tsx b/tubearchivist/www/src/pages/index.tsx index 20dd7da..9eb5d17 100644 --- a/tubearchivist/www/src/pages/index.tsx +++ b/tubearchivist/www/src/pages/index.tsx @@ -3,15 +3,10 @@ import { getSession } from "next-auth/react"; import { dehydrate, QueryClient } from "react-query"; import { CustomHead } from "../components/CustomHead"; import { Layout } from "../components/Layout"; -import { VideoList } from "../components/VideoList"; +import VideoList from "../components/VideoList/"; import { getVideos } from "../lib/getVideos"; -import type { Videos } from "../types/video"; -type HomeProps = { - videos: Videos; -}; - -const Home: NextPage = () => { +const Home: NextPage = () => { return ( <> diff --git a/tubearchivist/www/src/pages/playlist.tsx b/tubearchivist/www/src/pages/playlist.tsx index 6d95bec..30148cf 100644 --- a/tubearchivist/www/src/pages/playlist.tsx +++ b/tubearchivist/www/src/pages/playlist.tsx @@ -26,7 +26,7 @@ export const getServerSideProps: GetServerSideProps = async (context) => { }; } - await queryClient.prefetchQuery("playlists", () => + await queryClient.prefetchQuery(["playlists", session.ta_token.token], () => getPlaylists(session.ta_token.token) ); @@ -44,9 +44,13 @@ const Playlist = () => { data: { data: playlists }, error, isLoading, - } = useQuery("playlists", () => getPlaylists(session.ta_token.token), { - enabled: !!session.ta_token.token, - }); + } = useQuery( + ["playlists", session.ta_token.token], + () => getPlaylists(session.ta_token.token), + { + enabled: !!session.ta_token.token, + } + ); const [viewStyle, setViewStyle] = useState("grid"); diff --git a/tubearchivist/www/src/types/video.ts b/tubearchivist/www/src/types/video.ts index 1c30391..14f131f 100644 --- a/tubearchivist/www/src/types/video.ts +++ b/tubearchivist/www/src/types/video.ts @@ -53,6 +53,7 @@ export interface Downloads { subtitle_index: boolean; throttledratelimit: boolean; integrate_ryd: boolean; + integrate_sponsorblock: boolean; } export interface Scheduler { @@ -79,41 +80,71 @@ export interface Subscriptions { export interface Datum { active: boolean; - category: string[]; + category: Category[]; channel: Channel; date_downloaded: number; description: string; media_url: string; player: Player; + playlist: Playlist[]; published: string; stats: Stats; tags: string[]; title: string; - vid_last_refresh: string; + vid_last_refresh: LastRefresh; + vid_thumb_base64: string; vid_thumb_url: string; youtube_id: string; } +export enum Category { + ScienceTechnology = "Science & Technology", +} + export interface Channel { channel_active: boolean; - channel_banner_url: string; + channel_banner_url: ChannelBannerURL; channel_description: string; - channel_id: string; - channel_last_refresh: string; - channel_name: string; + channel_id: ChannelID; + channel_last_refresh: LastRefresh; + channel_name: ChannelName; channel_subs: number; channel_subscribed: boolean; - channel_thumb_url: string; + channel_thumb_url: ChannelThumbURL; channel_tvart_url: boolean; channel_views: number; } +export enum ChannelBannerURL { + CacheChannelsUCFhXFikryT4AFcLkLw2LBLABannerJpg = "/cache/channels/UCFhXFikryT4aFcLkLw2LBLA_banner.jpg", +} + +export enum ChannelID { + UCFhXFikryT4AFcLkLw2LBLA = "UCFhXFikryT4aFcLkLw2LBLA", +} + +export enum LastRefresh { + The05APR2022 = "05 Apr, 2022", +} + +export enum ChannelName { + NileRed = "NileRed", +} + +export enum ChannelThumbURL { + CacheChannelsUCFhXFikryT4AFcLkLw2LBLAThumbJpg = "/cache/channels/UCFhXFikryT4aFcLkLw2LBLA_thumb.jpg", +} + export interface Player { watched: boolean; duration: number; duration_str: string; } +export enum Playlist { + PLbaramj7Nly5K5AsvQoI9PJQhy47PfDAF = "PLbaramj7Nly5K5AsvQoI9PJQhy47pfDAf", +} + export interface Stats { view_count: number; like_count: number;