我使用bundler安装了yt gem。设置过程指出,如果我在命令行输入yt info
,我应该得到以下结果
Yt version 0.25.6
Hello, world!
我得到了版本,但没有得到预期的结果:
Yt version 0.25.26
/Users/michael/.rvm/gems/ruby-2.2.3/gems/yt-0.25.26/lib/yt/request.rb:83:in `run': A request to YouTube API caused an unexpected server error: (Yt::Errors::ServerError)
{}
You can retry the same request manually by running:
curl -X GET -H "content-length: 0" -H "user-agent: Yt::Request (gzip)" "https://www.youtube.com/annotations_invideo?key=AIzaSyBSvIOM0EGX1tcrf5IAlYJuH_ttqVgTO4Q&video_id=BPNYv0vd78A"
但是,如果我手动请求内容,它可以正常工作:
Michaels-MacBook-Air-2:yt michael$ curl -X GET -H "content-length: 0" -H "user-agent: Yt::Request (gzip)" "https://www.youtube.com/annotations_invideo?key=AIzaSyBSvIOM0EGX1tcrf5IAlYJuH_ttqVgTO4Q&video_id=BPNYv0vd78A"
<?xml version="1.0" encoding="UTF-8" ?><document><annotations><annotation author="" id="annotation_1585555999" log_data="xble=1&ei=Vvn7Vq35LIej-AXX8IeYAg&a-v=BPNYv0vd78A&a-type=4&a-id=annotation_1585555999" style="title" type="text"><TEXT>Hello, world!</TEXT><segment><movingRegion type="rect"><rectRegion d="0" h="25.2779998779" t="0:00.000" w="75.0" x="13.1540002823" y="67.3239974976" /><rectRegion d="0" h="25.2779998779" t="0:02.089" w="75.0" x="13.1540002823" y="67.3239974976" /></movingRegion></segment><appearance bgAlpha="0.25" bgColor="0" borderAlpha="0.10000000149" effects="" fgColor="16777215" fontWeight="bold" highlightFontColor="16777215" textSize="21.6642" /></annotation>
<annotation id="channel:563d3ce4-0000-20cc-8fd5-001a11463304" style="playlist" type="promotion"
log_data="ret-t=2&a-ch=UCwCnUcLcb9-eSrHa_RQGkQQ&a-type=12&a-v=BPNYv0vd78A&xble=1&ret-exp=-4&link-id=PLuW4g7xujBWfU26JUTW1DGs3hk4LD5KaL&ei=Vvn7Vq35LIej-AXX8IeYAg&ret-smrt=1&a-id=563d3ce4-0000-20cc-8fd5-001a11463304">
<data>{"text_line_2":"Adorable Kids","is_mobile":false,"text_line_1":"Check this playlist","playlist_length":"187","end_ms":3000,"start_ms":1000,"collapse_delay_ms":86400000,"image_url":"https:\/\/i.ytimg.com\/vi\/deG1wnpgL1s\/mqdefault.jpg"}</data>
<segment/>
<action trigger="click" type="openUrl">
<url type="hyperlink" target="new" value="https://www.youtube.com/watch?v=deG1wnpgL1s&list=PLuW4g7xujBWfU26JUTW1DGs3hk4LD5KaL&annotation_id=563d3ce4-0000-20cc-8fd5-001a11463304&feature=iv&ei=Vvn7Vq35LIej-AXX8IeYAg&src_vid=BPNYv0vd78A"/>
</action>
</annotation>
</annotations></document>
在阅读了可能的解决方案后,我重新安装了rvm和openssl,但它没有工作
Michaels-MacBook-Air-2:yt michael$ openssl version
OpenSSL 1.0.2g 1 Mar 2016
Michaels-MacBook-Air-2:yt michael$ rvm version
rvm 1.27.0 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]