Benjamin-Loison / YouTube-operational-API

YouTube operational API works when YouTube Data API v3 fails.
400 stars 50 forks source link

Add `order=uploadDate` to `search?q=QUERY&type=video` #320

Closed tekinc closed 3 weeks ago

tekinc commented 1 month ago

Hi, great job with this API. I was in the middle of importing millions of videos but it didn't complete now that you have suspended your service.

What would you recommend the best way to accomplish this?

Benjamin-Loison commented 1 month ago

What do you mean by importing millions of videos?

Related to #317.

tekinc commented 1 month ago

Import millions of video records.

Benjamin-Loison commented 1 month ago

Without further details as requested (records not helping), I close this issue.

See https://yt.lemnoslife.com for alternatives.

tekinc commented 4 weeks ago

Hi, how can I search and order by date using YouTube v1 API?

Benjamin-Loison commented 4 weeks ago

You mean YouTube Data API v3 or YouTube operational API? See YouTube-operational-API/wiki/Glossary/a6950ce5b5b5809b41129a0d1ded16b039a64358 if unsure.

Benjamin-Loison commented 4 weeks ago

What are you searching? Videos, shorts or/and channels? By a string query like MrBeast Squid Game?

tekinc commented 4 weeks ago

I am using YouTube operational API and am searching for videos.

Benjamin-Loison commented 3 weeks ago

Let me know if Webscrap_any_website/src/commit/12586241ddbb0651f639565cd0bf65085fa42d16/https:/www.youtube.com/results/main.py#{L112,L14-L18} does not meet your needs.

tekinc commented 3 weeks ago

Thanks but I am using your PHP implementation. Do you have the fix for that?

Benjamin-Loison commented 3 weeks ago

I do not plan to add PHP support for this feature, let me know if I should add an HTTP interface, see Webscrap_any_website/src/commit/12586241ddbb0651f639565cd0bf65085fa42d16/README.md#install-your-own-http-interface-instance, that you would have to host for this feature.

tekinc commented 3 weeks ago

It would be great if you could add it to HTTP interface. I am already hosting your YouTube operational API.

Benjamin-Loison commented 3 weeks ago

Note that the solution I proposed you, see #issuecomment-2445499106, is independent from YouTube operational API.

I just updated the HTTP interface as you requested, such that:

curl -X GET 'http://localhost:8080/https:/www.youtube.com/results?search_query=Minecraft' -d 'type=video' -d 'sort by=upload date'

should meet your needs.

tekinc commented 3 weeks ago

Great, thanks

tekinc commented 3 weeks ago

Hi, sorry is it possible for you to add this to the YouTube operational API? I have already the entire flow in place and would to keep it.

Benjamin-Loison commented 3 weeks ago

Sorry but I won't implement this feature to the YouTube operational API, see #327#issuecomment-2450624202 for details about why.

tekinc commented 3 weeks ago

Understood, is it possible to guide me where I can make that change? All I need is to set the order param correctly.

Benjamin-Loison commented 3 weeks ago

If you mean helping me to tell you what to change in YouTube operational API, then forget it. I have not yet done such complex thing and I do not recommend anyone to do so. Generating Protobuf in PHP is a hell while in Python it is very easy.

tekinc commented 3 weeks ago

Didn't realize is was that complicated in YouTube operational API. You already have a viewCount order parameter, I thought it would be easy to add "age" or "date". I guess not?

image

Benjamin-Loison commented 3 weeks ago

The code you selected is a hardcoded Protobuf string, for your very precise use case (search?q=QUERY&type=video&order=uploadDate) another one might fit your needs. However, it acts as an unoptimized blackbox which is very easily no more interesting, for instance such a hardcoded approach would not work for search?q=QUERY&type=channel&order=uploadDate, as type=channel and order=uploadDate would need to merge 2 hardcoded blackbox Protobufs with such an approach, so you would have to hardcode the merge result and so on. Hence, the number of hardcoded Protobuf string would be exponential... So it is not an approach that I recommend, as it results in Protobuf hell syntax as we can see at the bottom of your screen. The purpose of my work is to meet all needs, not just your precise use case at the expense of the needs of others, that's why I focus for this kind of complex feature on Webscrap any website as it is far better implemented and such better implementation is not easily possible in PHP as far as I know. Please do not ask me further assistance on what I consider as a bad approach.

tekinc commented 3 weeks ago

Thanks for the response. Last question, I am only using the YouTube operational API for type=video searches. How could I generate a Protobuf string to replace that hardcoded one to support these parameters q=QUERY&type=video&order=uploadDate?