@@ -7,23 +7,20 @@ import "./video.css";
77interface  VideoData  { 
88  id : string ; 
99  youtubeUrl : string ; 
10-   type : "video"  |  "live"  |  "other" ;   // Changed type to include 'live' and 'other' 
10+   type : "video"  |  "live"  |  "other" ; 
1111} 
1212
1313const  getYoutubeVideoId  =  ( url : string ) : string  =>  { 
14-   // Handle youtu.be short links 
1514  if  ( url . includes ( "youtu.be/" ) )  { 
1615    const  match  =  url . match ( / y o u t u \. b e \/ ( [ ^ ? & \s ] + ) / ) ; 
1716    return  match  ? match [ 1 ] . split ( "?" ) [ 0 ]  : "" ; 
1817  } 
1918
20-   // Handle youtube.com/watch?v= links 
2119  if  ( url . includes ( "youtube.com/watch" ) )  { 
2220    const  match  =  url . match ( / [ ? & ] v = ( [ ^ & \s ] + ) / ) ; 
2321    return  match  ? match [ 1 ] . split ( "&" ) [ 0 ]  : "" ; 
2422  } 
2523
26-   // Handle youtube.com/shorts/ links 
2724  if  ( url . includes ( "youtube.com/shorts/" ) )  { 
2825    const  match  =  url . match ( / s h o r t s \/ ( [ ^ ? & \s ] + ) / ) ; 
2926    return  match  ? match [ 1 ] . split ( "?" ) [ 0 ]  : "" ; 
@@ -32,7 +29,6 @@ const getYoutubeVideoId = (url: string): string => {
3229  return  "" ; 
3330} ; 
3431
35- // Updated function to determine video type 
3632const  getYoutubeContentType  =  ( url : string ) : "video"  |  "live"  |  "other"  =>  { 
3733  if  ( 
3834    url . includes ( "youtu.be/rbi6XhWp2TU" )  || 
@@ -42,14 +38,12 @@ const getYoutubeContentType = (url: string): "video" | "live" | "other" => {
4238  )  { 
4339    return  "live" ; 
4440  }  else  if  ( url . includes ( "/shorts/" ) )  { 
45-     return  "other" ;   // Changed 'shorts' to 'other' 
41+     return  "other" ; 
4642  }  else  { 
4743    return  "video" ; 
4844  } 
4945} ; 
5046
51- // Youtube Video URLS 
52- // List of both videos and shorts which will be handeled by the component 
5347const  videoUrls : string [ ]  =  [ 
5448  "https://youtu.be/3dnQ2lDNeGI?list=PLrLTYhoDFx-kiuFiGQqVpYYZ56pIhUW63" , 
5549  "https://youtu.be/XWjx-RjmhRM?list=PLrLTYhoDFx-kiuFiGQqVpYYZ56pIhUW63" , 
@@ -82,15 +76,13 @@ const VideoCard: React.FC<{
8276  const  [ thumbnailUrl ,  setThumbnailUrl ]  =  useState ( "" ) ; 
8377  const  videoId  =  getYoutubeVideoId ( video . youtubeUrl ) ; 
8478
85-   // Try different thumbnail qualities in sequence 
8679  const  tryThumbnailUrl  =  ( url : string )  =>  { 
8780    if  ( ! videoId )  return ; 
8881
8982    const  img  =  new  Image ( ) ; 
90-     img . crossOrigin  =  "anonymous" ;   // Handle CORS if needed 
83+     img . crossOrigin  =  "anonymous" ; 
9184
9285    img . onload  =  ( )  =>  { 
93-       // Only set the URL if it's not an error image 
9486      if  ( img . width  >  0  &&  img . height  >  0 )  { 
9587        setThumbnailUrl ( url ) ; 
9688      }  else  { 
@@ -106,28 +98,22 @@ const VideoCard: React.FC<{
10698    console . log ( `Failed to load thumbnail: ${ failedUrl }  ` ) ; 
10799
108100    if  ( failedUrl . includes ( "maxresdefault" ) )  { 
109-       // Try hqdefault if maxresdefault fails 
110101      tryThumbnailUrl ( `https://i.ytimg.com/vi/${ videoId }  /hqdefault.jpg` ) ; 
111102    }  else  if  ( failedUrl . includes ( "hqdefault" ) )  { 
112-       // Try mqdefault if hqdefault fails 
113103      tryThumbnailUrl ( `https://i.ytimg.com/vi/${ videoId }  /mqdefault.jpg` ) ; 
114104    }  else  if  ( failedUrl . includes ( "mqdefault" ) )  { 
115-       // Try default if mqdefault fails 
116105      tryThumbnailUrl ( `https://i.ytimg.com/vi/${ videoId }  /default.jpg` ) ; 
117106    }  else  { 
118-       // All options failed, show placeholder 
119107      setThumbnailUrl ( "" ) ; 
120108    } 
121109  } ; 
122110
123111  useEffect ( ( )  =>  { 
124112    if  ( ! videoId )  return ; 
125113
126-     // Start with the highest quality thumbnail 
127114    console . log ( `Loading thumbnails for video ID: ${ videoId }  ` ) ; 
128115    tryThumbnailUrl ( `https://i.ytimg.com/vi/${ videoId }  /maxresdefault.jpg` ) ; 
129116
130-     // Also try the first frame as a fallback (sometimes works when others don't) 
131117    const  firstFrameUrl  =  `https://img.youtube.com/vi/${ videoId }  /0.jpg` ; 
132118    setTimeout ( ( )  =>  { 
133119      if  ( ! thumbnailUrl )  { 
@@ -136,7 +122,6 @@ const VideoCard: React.FC<{
136122      } 
137123    } ,  1000 ) ; 
138124
139-     // Fetch video title 
140125    const  fetchVideoTitle  =  async  ( )  =>  { 
141126      try  { 
142127        const  response  =  await  fetch ( 
@@ -171,7 +156,6 @@ const VideoCard: React.FC<{
171156          > 
172157            { title } 
173158          </ div > 
174-           < div  className = "video-type" > </ div > 
175159        </ div > 
176160        < div  className = "video-thumbnail" > 
177161          < div  className = "thumbnail-container" > 
@@ -185,7 +169,6 @@ const VideoCard: React.FC<{
185169                onError = { ( e )  =>  { 
186170                  const  img  =  e . target  as  HTMLImageElement ; 
187171                  console . log ( "Image error:" ,  img . src ) ; 
188-                   // Let the parent component handle the error 
189172                  setThumbnailUrl ( "" ) ; 
190173                } } 
191174              /> 
@@ -194,7 +177,6 @@ const VideoCard: React.FC<{
194177                < span > Loading thumbnail...</ span > 
195178              </ div > 
196179            ) } 
197-             { /* Play button removed as per request */ } 
198180          </ div > 
199181        </ div > 
200182      </ div > 
@@ -253,7 +235,7 @@ const Pagination: React.FC<{
253235function  BroadcastsPage ( ) : ReactElement  { 
254236  const  history  =  useHistory ( ) ; 
255237  const  [ currentPage ,  setCurrentPage ]  =  useState ( 1 ) ; 
256-   const  [ activeTab ,  setActiveTab ]  =  useState < "videos"  |  "live" > ( "videos" ) ;   // Changed 'shorts' to 'live' 
238+   const  [ activeTab ,  setActiveTab ]  =  useState < "videos"  |  "live" > ( "videos" ) ; 
257239  const  videosPerPage  =  12 ; 
258240
259241  const  videoData : VideoData [ ]  =  videoUrls . map ( ( url ,  index )  =>  ( { 
@@ -263,7 +245,7 @@ function BroadcastsPage(): ReactElement {
263245  } ) ) ; 
264246
265247  const  regularVideos  =  videoData . filter ( ( video )  =>  video . type  ===  "video" ) ; 
266-   const  liveVideos  =  videoData . filter ( ( video )  =>  video . type  ===  "live" ) ;   // Changed 'shorts' to 'live' 
248+   const  liveVideos  =  videoData . filter ( ( video )  =>  video . type  ===  "live" ) ; 
267249  const  otherVideos  =  videoData . filter ( ( video )  =>  video . type  ===  "other" ) ; 
268250
269251  const  indexOfLastVideo  =  currentPage  *  videosPerPage ; 
@@ -276,11 +258,11 @@ function BroadcastsPage(): ReactElement {
276258  const  paginatedLiveVideos  =  liveVideos . slice ( 
277259    indexOfFirstVideo , 
278260    indexOfLastVideo , 
279-   ) ;   // Changed 'shorts' to 'live' 
261+   ) ; 
280262  const  totalPages  =  Math . ceil ( 
281263    ( activeTab  ===  "videos"  ? regularVideos . length  : liveVideos . length )  / 
282264      videosPerPage , 
283-   ) ;   // Changed 'shorts' to 'live' 
265+   ) ; 
284266
285267  useEffect ( ( )  =>  { 
286268    setCurrentPage ( 1 ) ; 
@@ -312,7 +294,7 @@ function BroadcastsPage(): ReactElement {
312294            🎥 Videos
313295          </ button > 
314296          < button 
315-             className = { `tab-button ${ activeTab  ===  "live"  ? "active"  : "" }  ` }   // Changed 'shorts' to 'live' 
297+             className = { `tab-button ${ activeTab  ===  "live"  ? "active"  : "" }  ` } 
316298            onClick = { ( )  =>  setActiveTab ( "live" ) } 
317299          > 
318300            🔴 Past Live
@@ -334,11 +316,11 @@ function BroadcastsPage(): ReactElement {
334316          </ > 
335317        ) } 
336318
337-         { activeTab  ===  "live"  &&  (   // Changed 'shorts' to 'live' 
319+         { activeTab  ===  "live"  &&  ( 
338320          < > 
339321            < VideoSection 
340322              title = "Past Live Videos" 
341-               videos = { paginatedLiveVideos }   // Changed 'shorts' to 'live' 
323+               videos = { paginatedLiveVideos } 
342324              onClick = { handleVideoClick } 
343325            /> 
344326            < Pagination 
0 commit comments