Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

youtube.videos().insert() fails silently, returns "valid" response #893

Closed
CodeSpent opened this issue May 7, 2020 · 10 comments
Closed
Assignees
Labels
needs more info This issue needs more information from the customer to proceed. type: question Request for information or clarification. Not an issue.

Comments

@CodeSpent
Copy link

CodeSpent commented May 7, 2020

Environment details

  • OS type and version: Ubuntu 18.04
  • Python version: python 3.5
  • pip version: pip 9.0.0
  • google-api-python-client version: 1.8.2

Steps to reproduce

  1. Upload video using resource.videos().insert()
  2. Reference response

Code example

        try:
            request = youtube.videos().insert(
                part="snippet",
                body={
                    "snippet": {
                        "categoryId": "22",
                        "description": "This is a test of uploading videos.",
                        "title": "Test Video Upload"
                    }
                },
                media_body=MediaFileUpload(TEST_VIDEO_LOCAL_PATH, chunksize=-1, resumable=False)
            )
            response = request.execute()
            logger.info("Response from VIDEO UPLOAD: %s", repr(response))
            return True
        except HttpError as e:
            print("Http Error During Upload: %s", repr(e.content))
            return False

Stack trace

Response from VIDEO UPLOAD: {'id': 'MC_vt7BjFmk', 'kind': 'youtube#video', 'etag': '"Dn5xIderbhAnUk5TAW0qkFFir0M/Bznl1B0nznSPuGYIdgxeQcUP2Vs"', 'snippet': {'title': 'Test Video Upload', 'publishedAt': '2020-05-07T14:28:55.000Z', 'channelTitle': 'Patrick Hanford', 'localized': {'title': 'Test Video Upload', 'description': 'This is a test of uploading videos.'}, 'description': 'This is a test of uploading videos.', 'categoryId': '22', 'channelId': 'UCZ5AUe-rp3rXKeFS0yx4ZBA', 'thumbnails': {'high': {'height': 360, 'width': 480, 'url': 'https://i.ytimg.com/vi/MC_vt7BjFmk/hqdefault.jpg'}, 'default': {'height': 90, 'width': 120, 'url': 'https://i.ytimg.com/vi/MC_vt7BjFmk/default.jpg'}, 'medium': {'height': 180, 'width': 320, 'url': 'https://i.ytimg.com/vi/MC_vt7BjFmk/mqdefault.jpg'}}, 'liveBroadcastContent': 'none'}}

I'm sure there is another issue here somewhere, but not providing any context is poor developer experience. We've spent hours trying to guess what the issue could be, and we shouldn't have to. Documenting why this type of response occurs would be helpful in debugging.

@CodeSpent CodeSpent changed the title Upload fails silently, returns "valid" response youtube.videos().insert() fails silently, returns "valid" response May 7, 2020
@busunkim96
Copy link
Contributor

Hi @CodeSpent,

When you say "fails silently" is the video not being uploaded, or is it being uploaded with some fields being ignored?

@busunkim96 busunkim96 added type: question Request for information or clarification. Not an issue. needs more info This issue needs more information from the customer to proceed. labels May 7, 2020
@CodeSpent
Copy link
Author

CodeSpent commented May 7, 2020

@busunkim96 sorry should've be more verbose. No video is uploaded, but a video resource is returned. Title and description are there and status states uploaded, but there's nothing on the target channel.

Is there something additional I need to do in order for the media itself to post, and if so, where might that be documented?

@busunkim96
Copy link
Contributor

Hm, that's odd. I would expect one of these errors to be returned if something went wrong.

If you search for the video with the resource's ID are you able to find it?

https://developers.google.com/youtube/v3/docs/videos/list?apix_params=%7B%22part%22%3A%22snippet%2CcontentDetails%2Cstatistics%22%2C%22id%22%3A%22Ks-_Mh1QhMc%22%7D

@CodeSpent
Copy link
Author

CodeSpent commented May 7, 2020

@busunkim96 this is the response, so does not appear so. Video id returned for reference (also in the full response above): R46N1uEb7lM.

{
    "kind": "youtube#videoListResponse",
    "etag": "\"Dn5xIderbhAnUk5TAW0qkFFir0M/q9wh51deRpP1b7X8Nc3D-bdBxqs\"",
    "pageInfo": {
        "totalResults": 0,
        "resultsPerPage": 0
    },
    "items": []
}

@CodeSpent
Copy link
Author

I am seeing in Youtube Studio that the video is there with the error message "Processing Abandoned". Is there anywhere I can get some support on this? I am able to upload the same video manually without any issue, but I can't really debug this when the client implies that everything is succeeding.

Most recent video id is: ZJlszmP1oto

@busunkim96
Copy link
Contributor

Hi @CodeSpent,

I've sent an email to the Youtube Data API folks to see if they have a definitive answer.

In the meantime I'd take a look at these Stack Overflow posts. One answer suggests trying the upload via the UI to make sure there are no issues with the video itself.

@CodeSpent
Copy link
Author

I have tried that and able to upload via UI, as well I have used https://github.com/tokland/youtube-upload/ to successfully upload my test video from the server without issue. There's obviously something wrong with my code, but I don't know all the conditions that will return a video ID when a video isn't actually uploaded which makes this tough to debug.

MediaFileUpload: "{\"_mimetype\": \"video/mp4\", \"_module\": \"googleapiclient.http\", \"_class\": \"MediaFileUpload\", \"_chunksize\": 4194304, \"_resumable\": true, \"_filename\": \"/tmp/WPHM-48k-pl-33366.mp4\", \"_size\": 368882}"

I can also conclude with above that the video does make it to MediaFileUpload just fine. I've tried numerous chunk sizes including -1, but always the same result: I receive a video ID, I'm told upload is successful, but the video is unavailable & states in studio that processing has been abandoned.

Any help from them would be greatly appreciated. Does not appear to be an issue with the client, there's probably just some condition that's undocumented (or difficult to find) that is being met to cause the silent failure. Considering this is not an issue with the google-api-python-client in particular, you may close this if you'd like, but maybe this reveals a case we can discover where it might be good to add a new exception or something to the client so developers are able to properly diagnose this issue.

@CodeSpent
Copy link
Author

I've figured this out. It turned out to be a permissions issue with the directory. Maybe there's somewhere in the client it can be determined and alerted to the developer that the file is not able to be uploaded? Not sure, but did get it rectified, thank you for your help!

@busunkim96
Copy link
Contributor

Ah that's good to hear! Opened #910 to track the possibility of adding more checks around MediaFileUpload

@jivanmainali
Copy link

I've figured this out. It turned out to be a permissions issue with the directory. Maybe there's somewhere in the client it can be determined and alerted to the developer that the file is not able to be uploaded? Not sure, but did get it rectified, thank you for your help!

hey , How did you fix it ?
I am still getting same issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs more info This issue needs more information from the customer to proceed. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

3 participants