#25 Error: "The upload failed with an unexpected response: <Response [400]>"

Closed
opened 5 years ago by wotaniii · 14 comments
wotaniii commented 5 years ago

when I try to get peertube working, it gives me an Error 400 - Bad Request.

I tried to stick as close to the readme as possible, I can't seem to get this working.

Here is my minimal working example:

dockerfile:

FROM ubuntu:bionic

RUN apt-get update && apt-get install -y python-pip python-dev python git
RUN python -m pip install --upgrade pip setuptools wheel
RUN pip install docopt schema python-magic requests-toolbelt tzlocal
RUN pip install google-auth google-auth-oauthlib google-auth-httplib2  google-api-python-client

RUN git clone https://git.lecygnenoir.info/LecygneNoir/prismedia.git /prismedia
RUN mkdir work
WORKDIR work
ADD a.mp4 a.mp4
ADD peertube_secret peertube_secret

RUN /prismedia/prismedia_upload.py -f a.mp4 --platform=peertube

run with:

docker build -t test . && docker run --rm -it test

output:

2019-01-05 15:00:14,531 No suitable NFO found, skipping.
2019-01-05 15:00:15,141 Peertube: Uploading video...
2019-01-05 15:00:16,183 Peertube: The upload failed with an unexpected response: <Response [400]>

peertube_secret:


[peertube]
client_id = xxxxxxxxxxxxx
client_secret = xxxxxxxxxxxxxx
username = xxxxxxxxxx
password = xxxxxxxxxxx
peertube_url = https://peervideos.com/
OAUTHLIB_INSECURE_TRANSPORT = '0' #Default use https

when I try to get peertube working, it gives me an Error 400 - Bad Request. I tried to stick as close to the readme as possible, I can't seem to get this working. Here is my minimal working example: dockerfile: ``` FROM ubuntu:bionic RUN apt-get update && apt-get install -y python-pip python-dev python git RUN python -m pip install --upgrade pip setuptools wheel RUN pip install docopt schema python-magic requests-toolbelt tzlocal RUN pip install google-auth google-auth-oauthlib google-auth-httplib2 google-api-python-client RUN git clone https://git.lecygnenoir.info/LecygneNoir/prismedia.git /prismedia RUN mkdir work WORKDIR work ADD a.mp4 a.mp4 ADD peertube_secret peertube_secret RUN /prismedia/prismedia_upload.py -f a.mp4 --platform=peertube ``` run with: docker build -t test . && docker run --rm -it test output: ``` 2019-01-05 15:00:14,531 No suitable NFO found, skipping. 2019-01-05 15:00:15,141 Peertube: Uploading video... 2019-01-05 15:00:16,183 Peertube: The upload failed with an unexpected response: <Response [400]> ``` peertube_secret: ``` [peertube] client_id = xxxxxxxxxxxxx client_secret = xxxxxxxxxxxxxx username = xxxxxxxxxx password = xxxxxxxxxxx peertube_url = https://peervideos.com/ OAUTHLIB_INSECURE_TRANSPORT = '0' #Default use https ```
wotaniii commented 5 years ago
Poster

a.mp4 is just some random video i found somewhere, and converted it to mp4 with ffmpeg

a.mp4 is just some random video i found somewhere, and converted it to mp4 with ffmpeg
wotaniii closed this issue 5 years ago
wotaniii reopened this issue 5 years ago
wotaniii commented 5 years ago
Poster

I did not install "python-magic-bin", since it doesn't seem to exist for ubuntu

I did not install "python-magic-bin", since it doesn't seem to exist for ubuntu
Zykino commented 5 years ago
Poster

Do you use Python2 or Python3 ?

Prismedia si developed in Python2 and some of it's dependencies cannot be found in Python3. I don't remember if "python-magic-bin" is one of them, if pip cannot install it you surely are using Python3.

Do you use Python2 or Python3 ? Prismedia si developed in Python2 and some of it's dependencies cannot be found in Python3. I don't remember if "python-magic-bin" is one of them, if pip cannot install it you surely are using Python3.
Poster
Owner

Yes I think it's a good start, Ubuntu Bionic possibly use python3 as default now, so the docker image should have used python3

You could try to run python --version to check that inside your docker image. As far as I know, prismedia is not compatible with python3 at the moment, even if there are perhaps not lot to do.

As for python-magic-bin it's officially present on pypi, so pip should find it, except if there is a incompatibility with another packages (or with python3 ^^")

Yes I think it's a good start, Ubuntu Bionic possibly use python3 as default now, so the docker image should have used python3 You could try to run `python --version` to check that inside your docker image. As far as I know, prismedia is not compatible with python3 at the moment, even if there are perhaps not lot to do. As for [python-magic-bin](https://pypi.org/project/python-magic-bin/) it's officially present on pypi, so pip should find it, except if there is a incompatibility with another packages (or with python3 ^^")
wotaniii commented 5 years ago
Poster
 python --version
 Python 2.7.15rc1

should I try a different base image/kernel/OS?

Since error 400 means bad request, I'm assuming that some parameter I supplied is wrong (e.g. missing, or containing a wrong symbol)

Or maybe the host I use (https://peervideos.com/ ) uses a different API? Should I try a different host?

python --version Python 2.7.15rc1 should I try a different base image/kernel/OS? Since error 400 means bad request, I'm assuming that some parameter I supplied is wrong (e.g. missing, or containing a wrong symbol) Or maybe the host I use (https://peervideos.com/ ) uses a different API? Should I try a different host?
Zykino commented 5 years ago
Poster

Oh sorry, I think I read your post too quickly and may have mislead LecygneNoir too.

I cannot reach https://peervideos.com/ and if I try without I get some page with the PHP version of the server. I also don't find this instance on https://joinpeertube.org. Are you sure you pasted the right address? I found https://peervideo.net which look quite similar to the instance you gave us, are you sure of the URL?

If you are sure of the URL and it's your instance you should check it server side.
If you are sure of the URL and it's not your instance you should contact the admin so he can fix it.

Oh sorry, I think I read your post too quickly and may have mislead LecygneNoir too. I cannot reach https://peervideos.com/ and if I try without I get some page with the PHP version of the server. I also don't find this instance on https://joinpeertube.org. Are you sure you pasted the right address? I found https://peervideo.net which look quite similar to the instance you gave us, are you sure of the URL? If you are sure of the URL and it's your instance you should check it server side. If you are sure of the URL and it's not your instance you should contact the admin so he can fix it.
wotaniii commented 5 years ago
Poster

when I try a new host, https://peervideo.net , it gives me the same error as before:

2019-01-08 21:41:06,362 Peertube: Uploading video...
2019-01-08 21:41:07,165 Peertube: The upload failed with an unexpected response: <Response [400]>

can I somehow activate debug-mode, so it tells me what kind of request had been sent?


I tried again with the old host and it now gives me

2019-01-08 21:43:55,655 No suitable NFO found, skipping.
2019-01-08 21:43:55,803 Peertube: Error: HTTPSConnectionPool(host='peervideos.com', port=443): Max retries exceeded with url: /api/v1/users/token (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fdcceddba50>: Failed to establish a new connection: [Errno 111] Connection refused',))

It seems the old host went offline somewhere in the last 2 days

when I try a new host, https://peervideo.net , it gives me the same error as before: ```2019-01-08 21:41:06,129 No suitable NFO found, skipping. 2019-01-08 21:41:06,362 Peertube: Uploading video... 2019-01-08 21:41:07,165 Peertube: The upload failed with an unexpected response: <Response [400]> ``` can I somehow activate debug-mode, so it tells me what kind of request had been sent? ___ I tried again with the old host and it now gives me ``` 2019-01-08 21:43:55,655 No suitable NFO found, skipping. 2019-01-08 21:43:55,803 Peertube: Error: HTTPSConnectionPool(host='peervideos.com', port=443): Max retries exceeded with url: /api/v1/users/token (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fdcceddba50>: Failed to establish a new connection: [Errno 111] Connection refused',)) ``` It seems the old host went offline somewhere in the last 2 days
Poster
Owner

Yes, the "connexion refused" thing is because peervideos.com is down. Fot his one, we cannot do anything, if this is your instance, you'll have to contact the administrator, I do not know why it could be down, either technical problem or the admin choose to shutdown :-/

On the other hand, if https://peervideos.net is indeed your instance and you have access (and quota) into it, the 400 errors could means

  • something is wrong in your upload options in prismedia
  • something is wrong in the instance (perhaps it has disabled some feature)

Unfortunately, http 400 do not give information about what the problem is (it's not implemented in the HTTP protocol) so all prismedia could do is displaying the 400. However if you can reach him, the Peertube instance admin should have more info inside the instance logs.

In order to help find the root cause, could you confirm that you can successfully upload the very same video on the instance through the web interface?

If this work, then from the dockerfile you copy/paste I have noticed you add the peertube_secret in the video directory, and not the prismedia directory.
I have never tested this, so perhaps there is a tricky bug here. Could you try to add the secret in the prismedia directory instead?

Yes, the "connexion refused" thing is because peervideos.com is down. Fot his one, we cannot do anything, if this is your instance, you'll have to contact the administrator, I do not know why it could be down, either technical problem or the admin choose to shutdown :-/ On the other hand, if https://peervideos.net is indeed your instance and you have access (and quota) into it, the 400 errors could means - something is wrong in your upload options in prismedia - something is wrong in the instance (perhaps it has disabled some feature) Unfortunately, http 400 do not give information about what the problem is (it's not implemented in the HTTP protocol) so all prismedia could do is displaying the 400. However if you can reach him, the Peertube instance admin should have more info inside the instance logs. In order to help find the root cause, could you confirm that you can successfully upload the very same video on the instance through the web interface? If this work, then from the dockerfile you copy/paste I have noticed you add the peertube_secret in the video directory, and not the prismedia directory. I have never tested this, so perhaps there is a tricky bug here. Could you try to add the secret in the prismedia directory instead?
wotaniii commented 5 years ago
Poster

For clarification: I don't care about the video or the host. Both of those were just the first things that came to mind. If you can give me a 100% fine video and a 100% stable host, I will use these.

It would help me, if you can tell me which platforms are known to work, like: is it know to work on linux? ubuntu? windows 10? fedora?


I changed the line in the dockerfile to

ADD peertube_secret /prismedia/peertube_secret

So the peertube_secret is in the same directory, where I clone prismedia to.

and result was:

2019-01-09 12:26:44,843 No suitable NFO found, skipping.
Traceback (most recent call last):
  File "/prismedia/prismedia_upload.py", line 233, in <module>
    pt_upload.run(options)
  File "/prismedia/lib/pt_upload.py", line 221, in run
    insecure_transport = secret.get('peertube', 'OAUTHLIB_INSECURE_TRANSPORT')
  File "/usr/lib/python2.7/ConfigParser.py", line 330, in get
    raise NoSectionError(section)
ConfigParser.NoSectionError: No section: 'peertube'

I changed the entire dockerfile, so the working directory is /prismedia and the video is in /video and result is the same as before:

2019-01-09 12:30:38,996 No suitable NFO found, skipping.
2019-01-09 12:30:39,233 Peertube: Uploading video...
2019-01-09 12:30:40,299 Peertube: The upload failed with an unexpected response: <Response [400]>

the entire dockerfile now looks like this:

FROM ubuntu:bionic

RUN apt-get update && apt-get install -y python-pip python-dev python git
RUN python -m pip install --upgrade pip setuptools wheel
RUN pip install docopt schema python-magic requests-toolbelt tzlocal
RUN pip install google-auth google-auth-oauthlib google-auth-httplib2  google-api-python-client

RUN git clone https://git.lecygnenoir.info/LecygneNoir/prismedia.git /prismedia
RUN mkdir /video
ADD a.mp4 /video/a.mp4
WORKDIR prismedia
ADD peertube_secret /prismedia/peertube_secret

CMD /prismedia/prismedia_upload.py -f /video/a.mp4 --platform=peertube

Uploading the video looks fine (see attachment)


My guess is that I missed something silly and obvious (like lack of quotationmarks in the secret-file (this is probably not it, I already tried adding different kind of quotation marks)), or there is something very unexpected, like maybe the lack of a dependency, which just isn't installed by default in a minimal ubuntu.

For clarification: I don't care about the video or the host. Both of those were just the first things that came to mind. If you can give me a 100% fine video and a 100% stable host, I will use these. It would help me, if you can tell me which platforms are known to work, like: is it know to work on linux? ubuntu? windows 10? fedora? ___ I changed the line in the dockerfile to ADD peertube_secret /prismedia/peertube_secret So the peertube_secret is in the same directory, where I clone prismedia to. and result was: ``` 2019-01-09 12:26:44,843 No suitable NFO found, skipping. Traceback (most recent call last): File "/prismedia/prismedia_upload.py", line 233, in <module> pt_upload.run(options) File "/prismedia/lib/pt_upload.py", line 221, in run insecure_transport = secret.get('peertube', 'OAUTHLIB_INSECURE_TRANSPORT') File "/usr/lib/python2.7/ConfigParser.py", line 330, in get raise NoSectionError(section) ConfigParser.NoSectionError: No section: 'peertube' ``` I changed the entire dockerfile, so the working directory is /prismedia and the video is in /video and result is the same as before: ``` 2019-01-09 12:30:38,996 No suitable NFO found, skipping. 2019-01-09 12:30:39,233 Peertube: Uploading video... 2019-01-09 12:30:40,299 Peertube: The upload failed with an unexpected response: <Response [400]> ``` the entire dockerfile now looks like this: ``` FROM ubuntu:bionic RUN apt-get update && apt-get install -y python-pip python-dev python git RUN python -m pip install --upgrade pip setuptools wheel RUN pip install docopt schema python-magic requests-toolbelt tzlocal RUN pip install google-auth google-auth-oauthlib google-auth-httplib2 google-api-python-client RUN git clone https://git.lecygnenoir.info/LecygneNoir/prismedia.git /prismedia RUN mkdir /video ADD a.mp4 /video/a.mp4 WORKDIR prismedia ADD peertube_secret /prismedia/peertube_secret CMD /prismedia/prismedia_upload.py -f /video/a.mp4 --platform=peertube ``` Uploading the video looks fine (see attachment) ___ My guess is that I missed something silly and obvious (like lack of quotationmarks in the secret-file (this is probably not it, I already tried adding different kind of quotation marks)), or there is something very unexpected, like maybe the lack of a dependency, which just isn't installed by default in a minimal ubuntu.
Poster
Owner

Okay, thanks for all details!
I have checked the peervideo.net version, it's the same on my test instance so it's not a compatibility problem.

Regarding the host, I use the script on fedora (28), centos 7 and debian 9 without problem. As your .mp4 upload correctly through the interface, it should works also with prismedia, as we use the same API than the web client.

I setup a python virtualenv for test which works, please find the requirement.txt attached, you should be able to install all requirements with pip install -r requirements.txt

Normally all defaults value in option should be okay, but just to be sure, could you try to use the default NFO with:

CMD /prismedia/prismedia_upload.py -f /video/a.mp4 --platform=peertube --nfo=nfo_example.txt

The NFO should provide all options and I used it for tests with success.

Okay, thanks for all details! I have checked the peervideo.net version, it's the same on my test instance so it's not a compatibility problem. Regarding the host, I use the script on fedora (28), centos 7 and debian 9 without problem. As your .mp4 upload correctly through the interface, it should works also with prismedia, as we use the same API than the web client. I setup a python virtualenv for test which works, please find the requirement.txt attached, you should be able to install all requirements with `pip install -r requirements.txt` Normally all defaults value in option should be okay, but just to be sure, could you try to use the default NFO with: ``` CMD /prismedia/prismedia_upload.py -f /video/a.mp4 --platform=peertube --nfo=nfo_example.txt ``` The NFO should provide all options and I used it for tests with success.
Poster
Owner

Gosh @wotaniii I am sorry it seems gitea does not manage .txt uploads, I have missed that...
You can got the requirements.txt here : https://framadrop.org/r/f1xb4nF4eB#tEK8D/8tdZF83WDJjmjjHyx+sFF1INHyqv3XlBNKhKM=

Sorry ^^"

Gosh @wotaniii I am sorry it seems gitea does not manage .txt uploads, I have missed that... You can got the requirements.txt here : https://framadrop.org/r/f1xb4nF4eB#tEK8D/8tdZF83WDJjmjjHyx+sFF1INHyqv3XlBNKhKM= Sorry ^^"
wotaniii commented 5 years ago
Poster

Thanks this worked. I think my misstake was a missing nfo-file.

Thanks this worked. I think my misstake was a missing nfo-file.
wotaniii closed this issue 5 years ago
wotaniii commented 5 years ago
Poster

for anyone interested, here is my final dockerfile:

FROM ubuntu:bionic

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y python-pip python-dev python git tzdata
RUN python -m pip install --upgrade pip setuptools wheel
RUN pip install docopt schema python-magic requests-toolbelt tzlocal
RUN pip install google-auth google-auth-oauthlib google-auth-httplib2  google-api-python-client

RUN git clone https://git.lecygnenoir.info/LecygneNoir/prismedia.git /prismedia
RUN mkdir /video
WORKDIR /video
ADD a.mp4 a.mp4
ADD thumb.jpg thumb.jpg
ADD nfo_example.txt nfo_example.txt
ADD peertube_secret peertube_secret

CMD /prismedia/prismedia_upload.py -f a.mp4 --platform=peertube --nfo=nfo_example.txt

The nfo_example.txt comes from the repo, but I had to change the path to the thumb-nail.

for anyone interested, here is my final dockerfile: ``` FROM ubuntu:bionic ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install -y python-pip python-dev python git tzdata RUN python -m pip install --upgrade pip setuptools wheel RUN pip install docopt schema python-magic requests-toolbelt tzlocal RUN pip install google-auth google-auth-oauthlib google-auth-httplib2 google-api-python-client RUN git clone https://git.lecygnenoir.info/LecygneNoir/prismedia.git /prismedia RUN mkdir /video WORKDIR /video ADD a.mp4 a.mp4 ADD thumb.jpg thumb.jpg ADD nfo_example.txt nfo_example.txt ADD peertube_secret peertube_secret CMD /prismedia/prismedia_upload.py -f a.mp4 --platform=peertube --nfo=nfo_example.txt ``` The `nfo_example.txt` comes from the repo, but I had to change the path to the thumb-nail.
Poster
Owner

Great thank you for the feedback!

It seems to me that you should use the script without NFO, we may have parameters not initialized correctly that are causing the error 🤔

I'll create a bug to investigate further this one, meanwhile do not hesitate to came back if you have any problem ;-)

Great thank you for the feedback! It seems to me that you should use the script without NFO, we may have parameters not initialized correctly that are causing the error :thinking: I'll create a bug to investigate further this one, meanwhile do not hesitate to came back if you have any problem ;-)
Sign in to join this conversation.
No Milestone
No Assignees
3 Participants
Notifications
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
There is no content yet.