Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Youtube video transcripts
#3
(Feb-15-2020, 10:03 AM)DeaD_EyE Wrote: They key video_id is not in transcript.

Replace line 14:
transcript.video_id, with video_id,

Then try again.
If the next error occurs, you know that this attribute is also not provided by the current transcript element.

Thanks for your reply. Yes, that fixed it, but I had to also remove all of those other attributes. Possibly I need to make sure that package has those attributes. Have been adding extra code to the other script, so that it writes to a file and prints; helps understand the data coming back.

#!/usr/bin/python

from youtube_transcript_api import YouTubeTranscriptApi

video_id = 'My3QHayBBfQ'
transcript_list = YouTubeTranscriptApi.get_transcript(video_id)

print(transcript_list[0])
print(transcript_list[1])
print(transcript_list[2])

with open('your_file.txt', 'w') as f:
    for item in transcript_list:
        f.write("%s\n" % item)
Is there a debug feature with python ? I'm used to stepping through code and examining variables, etc.
Reply


Messages In This Thread
Youtube video transcripts - by jehoshua - Feb-15-2020, 05:33 AM
RE: Youtube video transcripts - by DeaD_EyE - Feb-15-2020, 10:03 AM
RE: Youtube video transcripts - by jehoshua - Feb-15-2020, 09:55 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to check if video has been deleted or removed in youtube using python Prince_Bhatia 14 11,860 Feb-21-2020, 04:33 AM
Last Post: jehoshua
  I have a question from a YouTube video I saw: nelsonkane 9 5,181 Dec-27-2017, 11:17 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020