marco-land / sanity-plugin-vimeo-field

Retrieve Vimeo video data via the API with an access token and store it in Sanity.
MIT License
12 stars 1 forks source link

Extend Fields which are requested from vimeo #3

Closed miller-design closed 7 months ago

miller-design commented 7 months ago

Hi there,

Is there any option or plan to allow a user when setting up the plugin to specify/select what data they want to retrieve from Vimeo?

As a use case, we need the duration value to be available for all videos and we only need to return the source files to be returned.

Cheers

marco-land commented 7 months ago

Hi Miller, that is a good point. At the moment the only fields that are requested are play,pictures,files,name but I will include an option to extend the fields. I think for your use case you'd need the video field (Vimeo docs).

marco-land commented 7 months ago

I've just added field options to 1.0.1:

// … your schema
defineField({
  title: 'Vimeo',
  name: 'vimeo',
  type: 'vimeo',
  // Optional: Extend the default fields, see below for more information
  options: {
    fields: ['metadata'],
  },
})
miller-design commented 7 months ago

Hi Marco,

Thank you so much for looking into this it's greatly appreciated.

One thing that I have come across while testing this updated option out is that I can't seem to get anything to return from "video" when I add it to my fields options array.

Your example of metadata works as I tested including and excluding it when I set the field options. However when I was checking over the response page I couldn't see a response of metadata in the list.

eg this is how I'm defining my field: defineField({ title: 'Short Loop Video', name: 'shortLoop', type: 'vimeo', options: { fields: ['metadata', 'video'] } }), I have also tested creating a new API key in case I may have limited my access but I still didn't have any luck with retrieving any additional data. I have also tested the following options which also didn't return any data: location, project and text track

Cheers, Jack

marco-land commented 7 months ago

Hi Jack,

sorry, I did not mention this in my earlier response: I was wrong to add the video field for the duration. Basically, this should be the full list of fields.

So, for storing the video‘s duration I just tested it like this and it worked:

options: {
  fields: ['duration'],
},

Can you check if that works for you, too?

miller-design commented 7 months ago

Hi Marco,

Awesome stuff I'll test this out shortly.

Currently having an issue with caching on my requests so I can't say at the moment if the above will work.

Cheers, Jack

miller-design commented 7 months ago

Hi Marco,

just to confirm that using:

options: {
  fields: ['duration'],
}

does indeed allow me to access the duration value.

Thanks again for making this update.

Cheers, Jack