Closed taizan-hokuto closed 4 years ago
You did it! Thank you very much for implementing my proposal!!!!!!!!!!!!! I'll try reviewing the code tomorrow (currently being enrolled in mikochiku today :-)).
Thank you, too. You have sown a great seed, I've only raised it :) I did not know the existence of lighter APIs. Thanks to you for sharing these with us and clear explanations, I got the motivation to implement it. I hope you enjoy the mikochiku life!
通信容量削減できるのもですし、jsonで取得できるのもいいですね! 私も日が昇ってから見てみようと思います。(みこ畜みるにぇ)
ありがとうございます。よろしくおねがいします。(朝から私用で一日手が放せないので諸々返信遅くなるかもです)
私が言っていたエラー処理の内容を悉く実装してくださいましてありがとうございました! まさかAPIにまで対応してくださるとはあっぱれです!
こちらyoutubeのモバイルのURL(m.youtube.com)にパラメーターが付いただけでjsonが吐かれていますがこれは公式のAPIを介した通信とみてよろしいのでしょうか? OAuthなどを用いて認証を受けていませんがyoutubeにもこのようなリンクにアクセスするだけで使えるAPIがあるとは思ってもいませんでした YunzheZJUさんがどのようか経緯でこれを発見したのかとても気になります!
こちらyoutubeのモバイルのURL(m.youtube.com)にパラメーターが付いただけでjsonが吐かれていますがこれは公式のAPIを介した通信とみてよろしいのでしょうか? OAuthなどを用いて認証を受けていませんがyoutubeにもこのようなリンクにアクセスするだけで使えるAPIがあるとは思ってもいませんでした YunzheZJUさんがどのようか経緯でこれを発見したのかとても気になります!
Excuse me if I did not translate your question accurately. I'll answer your questions as if you are asking me: 'Can we see this url as an official API? I'm curious about how did you find this url where OAuth is not required, just accessing a link to youtube.'
To be honest, I think the url used in this trick is not provided as an API for developers because the url is not documented anywhere (I guess) as well as it does not even require a Google Developer App Key, not to say the OAuth verification. This url with proper params should be seen as a non-documented, but still being used, AJAX interface (In my own language).
Therefore it brings the difficulty to us, that is, the param, the return structure and even the url itself are subject to change without being noticed by us. That why I felt a bit worried when Taizan-hokuto Sama is trying to parse the json returned with a solid structure, which may break when the json structure changes, instead of the RegEx, which offers robustness to some extent.
Also a careful check should be carried out whether accessing of this url in scripts is valid under YouTube's current Terms of service. #33
I'm working as a junior front-end web developer and I think I'm a bit sensitive to AJAXs of this kind. When I'm trying to find another url than the channel homepage, I first checked the mobile page. In my experience, webpages targetting mobile phones (usually starts with m.
or h5.
) will usually load as few resources as possible to save users' network traffic and gain a render boost. And when I'm toggling the filter on /video
, I noticed that data on the page is updated without a full reload of page, which indicates that an AJAX has been fired. Then I checked the network and found the request we are talking about.
Actually I don't know the effect of any param in ?view=2&flow=list&pbj=1
but only be sure that this request can be reproduced without OTA (One Time Auth). Lucky!
trying to parse the json returned with a solid structure, which may break when the json structure changes, instead of the RegEx, which offers robustness to some extent.
I agree with you. It's nice to be able to flexibly adapt to changes in JSON structure with using RegEX. To be honest, I'm not familiar with RegEx... I would appreciate if you could teach us if you come up with a delicious way. I'm also preparing a sample JSON data for testing.
上記でいただいたレビューを踏まえ、修正を反映致しました。ご確認の程よろしくお願いいたします。 修正前の大きな変更点としては、Retryを削除しました。 Retry機能を使っていて、リトライが発生すると、規定回数を超えてタイムアウトするまでの間GUIが動かなくなるためです。 (これを解決するには、リクエスト部分を別スレッド化する?) ネットワークエラー等で接続できない状態が発生しても、結局40秒後に再接続を試行するため、わざわざリトライする必要はないと判断しました。
修正作業、お疲れさまです 早速確認させていただきます (メン限見るので遅いかも)
みなさま開発レビューお疲れさまでした!マージさせていただきます
関連issue
27
これまでは配信ページを直接スクレイピングしていたので、通信量が数10キロバイトと大きかったのですが、 YunzheZJUさんが #27で教えてくださった APIを使用することにより、1回あたりの通信量が数キロバイトまで削減できます。