Using Python API to upload many videos but cannot figure out right values for tags

I am setting up an instance of peertube that will be part of my offline testbed. Part of what that requires is for me to create user accounts for thousands of users and make it look as though they have each uploaded many videos at some point.

I was delighted to see that there is a python implementation of the API and I’ve made it to the point of creating user accounts automatically through it. When I try to upload videos I’ve been unable to figure out what the right value I should be passing to api_instance.videos_upload_post. I don’t really care what value is there, so I’ve tried passing None, and empty list, a list with a string in it (it says I need at least 2), a list with 2 strings, a dict mapping strings to ints, and they all get rejected with the message

HTTP response body: {"errors":{"tags":{"value":"skaion,0","msg":"Should have correct tags","param":"tags","location":"body"}}}

where the skaion,0 part changes depending on what I’m trying to put in the tags field.

What value should work for it and/or how can I find suitable values to pass?

I’ve managed to address all the other issues that call was raising, but I’m stumped how to get by this one.

I could try to use the tool peertube-upload.js but since I’m going to be doing hundreds of thousands of videos I’m hoping to avoid having to spawn a new process for each.

My current work around was to not pass that argument to videos_upload_post, but I also had to turn off client side validation (which would make sure that had at least 2 characters). So I added configuration.client_side_validation = False right after setting the authentication token and before creating the api_client. That seems like it’s working, though it’s still going to take a while for things to get uploaded before I really know for sure.

Where did you find that implementation? I suggest you get in touch with their developers first. Note that video POST is documented in our REST API: PeerTube

For reference, I found the Python implementation at https://framagit.org/framasoft/peertube/clients/python which I found linked from the bottom of https://docs.joinpeertube.org/api-rest-getting-started, so I felt like they had some degree of « officialness » about them.

Yes, it is official. However, it is merely automatically generated based on our REST API OpenAPI spec, for which my previous comment still applies.

Thanks for following up. I guess I’m not quite sure how to use the link you gave to solve the problem though. That says that the tags parameter should be a list (or is array different here?) of strings. If I try passing a list of strings though I get the error reported in the question. If I pass, say tags=['tag1', 'tag2'] when calling the videos_upload function I get the error about not passing valid tags.

Again, in PeerTube as in the OpenAPI spec, it is not just mentioned an array, but

Array of strings [ 1 … 5 ] items unique
Video tags (maximum 5 tags each between 2 and 30 characters)

So by giving ‹ 0 ›, you are not passing a valid tag, which should be at least 2 chars long.

Sure, but what about the ['tag1', 'tag2'] list example? That has 2 strings both of which are greater than 2 characters long and produced the same error (I think the clientconcatenated them to pass 'tag1,tag2' in that case).

Also, I was never able to find a way to not pass it through the client even though it’s marked as an optional field. Passing None, '', and [] each resulted in the client rejecting it before trying to submit because it had to be a string with at least 2 characters.

I’m happy, once my load script finishes which will now take a few hours, to continue trying to figure this out so future readers might find a solution other than my turning off the client validation, but I am going from memory of attempts now and that’s always a risky thing for me to do. If you have an example value you believe should work I’ll try it eventually (probably not for a day or two), and report back the results.