yt icon indicating copy to clipboard operation
yt copied to clipboard

Yt::Collections::Videos#includes

Open fw42 opened this issue 3 years ago • 2 comments

I'm trying to manually retrieve some videos with their contentDetails included.

The following does not work as expected:

Yt::Collections::Videos.new.includes(:content_details).where(id: ids)

It generates an HTTP call with part=snippet (not part=snippet,contentDetails as expected).

There also appears to be some kind of bug in eager_load_items_from where it's using item['id']['videoId'] while it should be using item['id'] (the method attributes_for_new_item seems to do it correctly by first checking use_list_endpoint?).

Am I doing something wrong or is this a bug? Thanks

fw42 avatar May 25 '22 18:05 fw42

part = 'snippet,contentDetails'
Yt::Collections::Videos.new.where(id: video_id, part: part).first

I think includes is used for something else.

kangkyu avatar Jun 16 '22 20:06 kangkyu

That doesn't quite work either. This is the workaround I'm using right now, in case anyone else stumbles over the same problem:

hack = Yt::Collections::Videos.new.includes(:snippet, :content_details).where(id: ids, part: 'snippet,contentDetails')
response = hack.send(:list_request, hack.send(:list_params)).run

fw42 avatar Jun 16 '22 21:06 fw42

I'm closing this issue because it seems working somehow. If you open a pr for an improvement, that would be great!

kangkyu avatar Oct 29 '22 15:10 kangkyu