Spaces:
				
			
			
	
			
			
		Sleeping
		
	
	
	
			
			
	
	
	
	
		
		
		Sleeping
		
	Commit 
							
							·
						
						4a2aa81
	
1
								Parent(s):
							
							2d4a391
								
Transcirpt fetching with exception handling
Browse files- Data/yt_transcript.py +9 -4
    	
        Data/yt_transcript.py
    CHANGED
    
    | @@ -16,10 +16,15 @@ def get_video_id(video_links_list): | |
| 16 |  | 
| 17 | 
             
            def fetch_yt_transcript(video_ids):
         | 
| 18 | 
             
                for id in video_ids:
         | 
| 19 | 
            -
                     | 
| 20 | 
            -
                     | 
| 21 | 
            -
                         | 
| 22 | 
            -
                         | 
|  | |
|  | |
|  | |
|  | |
|  | |
| 23 | 
             
                return transcripts
         | 
| 24 |  | 
| 25 |  | 
|  | |
| 16 |  | 
| 17 | 
             
            def fetch_yt_transcript(video_ids):
         | 
| 18 | 
             
                for id in video_ids:
         | 
| 19 | 
            +
                    print(f"Fetching transcript for: {id}")
         | 
| 20 | 
            +
                    try:
         | 
| 21 | 
            +
                        output = YouTubeTranscriptApi.get_transcript(id)
         | 
| 22 | 
            +
                        for transcript in output:
         | 
| 23 | 
            +
                            transcripts.append(transcript['text'])
         | 
| 24 | 
            +
                        print(f"Finished fetching transcript for: {id}")
         | 
| 25 | 
            +
                    except Exception as e:
         | 
| 26 | 
            +
                        print(f"Transcript not found for video: {id}")
         | 
| 27 | 
            +
                        transcripts.append("")
         | 
| 28 | 
             
                return transcripts
         | 
| 29 |  | 
| 30 |  |