415上载到API时出错

2024-04-28 10:17:05 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图使用SubDB(http://thesubdb.com/api/)在python3.x中编写一个自动字幕查找器。我现在正在开发一个上传功能。但是,我不能让它工作。我一直收到415错误(不支持的媒体类型)。在SubDB网站上,提供了“请求示例”:

POST /?action=upload HTTP/1.1
Host: api.thesubdb.com
User-Agent: SubDB/1.0 (Pyrrot/0.1; http://github.com/jrhames/pyrrot-cli)
Content-Length: 60047
Content-Type: multipart/form-data; boundary=xYzZY

- - --xYzZY
Content-Disposition: form-data; name="hash"

edc1981d6459c6111fe36205b4aff6c2
- - --xYzZY
Content-Disposition: form-data; name="file"; filename="subtitle.srt"
Content-Type: application/octet-stream


[PAYLOAD]

但我不知道该如何解释,我在网上也找不到答案。这是我当前的代码:

^{pr2}$

任何建议都将不胜感激!在


Tags: name功能formcomapihttpdatatype
1条回答
网友
1楼 · 发布于 2024-04-28 10:17:05

我也有同样的问题。在

您可能想看看这个https://github.com/ivandrofly/SubDBSharp

尝试以下操作:

    POST /?action=upload HTTP/1.1
    Host: api.thesubdb.com
    User-Agent: SubDB/1.0 (Pyrrot/0.1; http://github.com/jrhames/pyrrot-cli)
    Content-Length: [Subtitle content length including boundary length]
    Content-Type: multipart/form-data; boundary=xYzZY

     xYzZY
    Content-Disposition: form-data; name="hash"

    edc1981d6459c6111fe36205b4aff6c2
     xYzZY
    Content-Disposition: form-data; name="file"; filename="subtitle.srt"
    Content-Type: application/octet-stream

    [SUBTITLE CONTENT]
     xYzZY


    # Content-Length:
    Content length should be from  xYzZY to last  xYzZY see above.

注意:边界开始于xyzy,结束于[SUBTITLE CONTENT]

相关问题 更多 >