打开字幕的 REST API POST /api/v1/download
Posted
技术标签:
【中文标题】打开字幕的 REST API POST /api/v1/download【英文标题】:Open Subtitle's REST API POST /api/v1/download 【发布时间】:2021-02-18 21:42:47 【问题描述】:我从 Opensubtitle 的新 API here 阅读了文档,并在尝试到达下载端点时收到 500 错误。我在其他端点上取得了成功,包括 /api/v1/login 和 /api/v1/subtitles。
这是我尝试请求的 JSON 格式的数据
'id': '5164746',
'type': 'subtitle',
'attributes': 'subtitle_id': '5164746',
'language': 'en',
'download_count': 9608,
'new_download_count': 46,
'hearing_impaired': False,
'hd': True,
'format': None,
'fps': 23.976,
'votes': 0,
'points': 0,
'ratings': 0.0,
'from_trusted': False,
'foreign_parts_only': False,
'auto_translation': False,
'ai_translated': False,
'machine_translated': None,
'upload_date': '2020-02-09T13:59:42Z',
'release': '2160p.4K.BluRay.x265.10bit.AAC5.1-[YTS.MX]',
'comments': "Slightly resynced the 1080p.WEBRip.x264-[YTS.LT] version by explosiveskull to this 4K release. HI removed. I didn't do 4K sync for Infinity War, as they're already on site here:\r\nHi: https://www.opensubtitles.org/en/subtitles/7436082/avengers-infinity-war-en\r\nNo HI: https://www.opensubtitles.org/en/subtitles/7436058/avengers-infinity-war-en",
'legacy_subtitle_id': 8092829,
'uploader': 'uploader_id': 66694,
'name': 'pooond',
'rank': 'bronze member',
'feature_details': 'feature_id': 626618,
'feature_type': 'Movie',
'year': 2019,
'title': 'Avengers: Endgame',
'movie_name': '2019 - Avengers: Endgame',
'imdb_id': 4154796,
'tmdb_id': 299534,
'url': 'https://www.opensubtitles.com/en/subtitles/legacy/8092829',
'related_links': 'label': 'All subtitles for Avengers: Endgame',
'url': 'https://www.opensubtitles.com/en/movies/2019-untitled-avengers-movie',
'img_url': 'https://s9.osdb.link/features/8/1/6/626618.jpg',
'files': ['file_id': 5274788,
'cd_number': 1,
'file_name': 'Avengers.Endgame.2019.2160p.4K.BluRay.x265.10bit.AAC5.1-[YTS.MX].srt']
这是我要发送的请求:
headers =
'Api-Key': api_one,
'Authorization': auth,
'Content-Type': 'application/json',
data = '"file_id":5274788,"sub_format":"srt","file_name":"Avengers.Endgame.2019.2160p.4K.BluRay.x265.10bit.AAC5.1-[YTS.MX]","strip_html":true,"cleanup_links":true,"remove_adds":true,"in_fps":0,"out_fps":0,"timeshift":0'
response = requests.post('https://www.opensubtitles.com/api/v1/download', headers=headers, data=data)
有其他人成功使用此 API 的下载端点吗?
【问题讨论】:
【参考方案1】:啊,好的,我找到了解决方案。看起来某些参数有错误。这是documentation 的链接。更新了 post 请求的 data 参数,只包含 file_id。
data = '"file_id":5274788'
response = requests.post('https://www.opensubtitles.com/api/v1/download', headers=headers, data=data)
【讨论】:
以上是关于打开字幕的 REST API POST /api/v1/download的主要内容,如果未能解决你的问题,请参考以下文章
Youtube API - 如何使用自定义控件打开/关闭字幕,更改语言?