Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3721

YouTube Data API (v3) Captions insert does not properly show up in YouTube Studio

$
0
0

I'm building a process to upload videos to YouTube and automatically set the captions for the video. The upload works, although that needed some fiddling around to get all the parameters to work as expected. Now that I understand that it makes a lot more sense but I still struggle to get the captions to work.

The youtube.captions().insert(..) call works and I receive a valid response, but the captions don't show up in the channel studio overview of YouTube.

I got the following code:

    def update_youtube_captions(p):      # ...      captions_file = f'{pdir}/youtube_captions.txt'      with open(captions_file, 'w+') as cf:        cf.write(captions_text)      # set captions file      creds = get_credentials()      with build('youtube', 'v3', credentials=creds) as youtube:        print('trying to set captions...')        request = youtube.captions().insert(              body={"sync": True,"snippet": {"videoId": video_id,"language": voice,"name": "English","isDraft": True,                },            },            part="id,snippet",            media_body=MediaFileUpload(captions_file, chunksize=1024 * 1024, resumable=True),        )        try:            response = request.execute()          # ...        except Exception as x:          print(x)          # ...        # ...

The response I receive is something like this:

"youtube_captions_upload_response": {"etag": "...","id": "...","kind": "youtube#caption","snippet": {"audioTrackType": "unknown","isAutoSynced": true,"isCC": false,"isDraft": true,"isEasyReader": false,"isLarge": false,"language": "en-UK","lastUpdated": "2022-04-19T07:29:31.49499Z","name": "English","status": "syncing","trackKind": "standard","videoId": "..."        }    },

This looks OK imo.

More irritating is the fact now, that for most videos this doesn't show up like expected:Studio 2As you can see, it only displays:

    1. English (video language)

It looks like this captions is automatically generated by YouTube. My draft is nowhere to be found. Funny enough, if I click on the "copy and edit" button besides it, a prompt pops up warning me This action overwrites your current draft for English. - So, where is my draft? In the Studio in the tab Drafts nothing is visible:Studio 3


This only seemed to work once I set isDraft=False and instantly publishing it. If I did that then at some point (probably once YouTube has processed the audio and synched it) it started to show up. In the studio, for some videos it looks like this:Studio 1On the image there are 3 captions for an older video visible:

    1. English (UK, video language, tbd)
    1. English (UK, "English")
    1. English (automatically)

where the 2nd one is the one I uploaded with the script.

Now, if it were always like this, it would be okay with me. Although I'm wondering why it doesn't recognize that the 2nd one I uploaded should be 1. (the video language). But I want isDraft=True in order for it to show up in the Studio under "drafts" for me to quickly review before publishing it. So I changed that.


Since I know what the captions should be, there is no need for YouTube to create something automatically. Idealy the videos only have 1 caption: The one I upload which would be visible as English (video language) - just because that's better than English (UK) - 'English' which seems somewhat redundant.

I was wondering if I had to youtube.captions().list(..) first, after the upload, and then update the one which might be already present. "Might be" - you might ask yourself, how come I'm not sure? Well, I've used up my daily quota once again because failed attempts also contribute to your daily usage, so I have to wait another 24h before continuing my attempts... Also, doing it like this with the initial list(..) requires more quota-points as described here (50 list + 450 update = 500, vs. 400 insert), which is not desireable.

Any inputs on what might be going on?Thanks!


Viewing all articles
Browse latest Browse all 3721

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>