pusaitou / mikochiku_alarm

GNU General Public License v3.0
17 stars 7 forks source link

より軽量なAPIを使用し,ID取得時の通信量を削減する #38

Closed taizan-hokuto closed 4 years ago

taizan-hokuto commented 4 years ago

関連issue

27

これまでは配信ページを直接スクレイピングしていたので、通信量が数10キロバイトと大きかったのですが、 YunzheZJUさんが #27で教えてくださった APIを使用することにより、1回あたりの通信量が数キロバイトまで削減できます。

YunzheZJU commented 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 :-)).

taizan-hokuto commented 4 years ago

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!

hidori-11 commented 4 years ago

通信容量削減できるのもですし、jsonで取得できるのもいいですね! 私も日が昇ってから見てみようと思います。(みこ畜みるにぇ)

taizan-hokuto commented 4 years ago

ありがとうございます。よろしくおねがいします。(朝から私用で一日手が放せないので諸々返信遅くなるかもです)

pusaitou commented 4 years ago

私が言っていたエラー処理の内容を悉く実装してくださいましてありがとうございました! まさかAPIにまで対応してくださるとはあっぱれです!

こちらyoutubeのモバイルのURL(m.youtube.com)にパラメーターが付いただけでjsonが吐かれていますがこれは公式のAPIを介した通信とみてよろしいのでしょうか? OAuthなどを用いて認証を受けていませんがyoutubeにもこのようなリンクにアクセスするだけで使えるAPIがあるとは思ってもいませんでした YunzheZJUさんがどのようか経緯でこれを発見したのかとても気になります!

YunzheZJU commented 4 years ago

こちら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).

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!

taizan-hokuto commented 4 years ago

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.

taizan-hokuto commented 4 years ago

上記でいただいたレビューを踏まえ、修正を反映致しました。ご確認の程よろしくお願いいたします。 修正前の大きな変更点としては、Retryを削除しました。 Retry機能を使っていて、リトライが発生すると、規定回数を超えてタイムアウトするまでの間GUIが動かなくなるためです。 (これを解決するには、リクエスト部分を別スレッド化する?) ネットワークエラー等で接続できない状態が発生しても、結局40秒後に再接続を試行するため、わざわざリトライする必要はないと判断しました。

hidori-11 commented 4 years ago

修正作業、お疲れさまです 早速確認させていただきます (メン限見るので遅いかも)

pusaitou commented 4 years ago

みなさま開発レビューお疲れさまでした!マージさせていただきます