My current code only finds first video in this json. I want it to search all the jsonData.data.mediaDetails.

This is my current code : "const getMp4FileSizes = async (jsonData) => {
  const mp4FileSizes = [];
  if (jsonData.data.mediaDetails) {
    for (const media of jsonData.data.mediaDetails) {
      if (media.video_info && media.video_info.variants) {
        for (const variant of media.video_info.variants) {
          if (variant.content_type === "video/mp4") {
            const fileSize = await getMp4FileSize(variant.url);
            if (fileSize) {
              mp4FileSizes.push({
                url: variant.url,
                fileSize: fileSize
              });
            }
          }
        }
      }
    }
  } else {
    for (const media of jsonData.data.quoted_tweet.mediaDetails) {
      if (media.video_info && media.video_info.variants) {
        for (const variant of media.video_info.variants) {
          if (variant.content_type === "video/mp4") {
            const fileSize = await getMp4FileSize(variant.url);
            if (fileSize) {
              mp4FileSizes.push({
                url: variant.url,
                fileSize: fileSize
              });
            }
          }
        }
      }
    }
  }
  return mp4FileSizes;
};"

This json has more than 1 mediaDetails : "{
"data": {
"__typename": "Tweet",
"lang": "ta",
"favorite_count": 15,
"possibly_sensitive": false,
"created_at": "2024-02-23T12:05:48.000Z",
"display_text_range": [
0,
215
],
"entities": {
"hashtags": [],
"urls": [],
"user_mentions": [],
"symbols": [],
"media": [
{
"display_url": "pic.twitter.com/HgdvxydCtH",
"expanded_url": "https://twitter.com/rubane3/status/1760999397951692825/video/1",
"indices": [
216,
239
],
"url": "https://t.co/HgdvxydCtH"
}
]
},
"id_str": "1760999397951692825",
"text": "திராவிடம் திராவிட கட்சிகளே மண்ணின் சாப கேடுகள்.. மலைக்குள்ளே கல் க்வாரி கட்சி வச்சிருக்கானுங்க.. இப்படி பட்ட திருட்டு கூட்டதுக்கு வாக்கு செலுத்தி மண்ணை அழிக்க வெல்ல வைக்கும் படித்த முட்டாள் வாழும் குமரி மாவட்டம்.... https://t.co/HgdvxydCtH",
"user": {
"id_str": "551734383",
"name": "ரூபன் ராஜ்",
"profile_image_url_https": "https://pbs.twimg.com/profile_images/1631857768553496580/4vPhrhSW_normal.jpg",
"screen_name": "rubane3",
"verified": false,
"is_blue_verified": false,
"profile_image_shape": "Circle"
},
"edit_control": {
"edit_tweet_ids": [
"1760999397951692825"
],
"editable_until_msecs": "1708693548000",
"is_edit_eligible": true,
"edits_remaining": "5"
},
"mediaDetails": [
{11 items},
{11 items}
],
"photos": [],
"video": {
"aspectRatio": [
16,
9
],
"contentType": "media_entity",
"durationMs": 68147,
"mediaAvailability": {
"status": "available"
},
"poster": "https://pbs.twimg.com/ext_tw_video_thumb/1760998855049428993/pu/img/_QNJ2aTpfUC_2tiX.jpg",
"variants": [
{
"type": "video/mp4",
"src": "https://video.twimg.com/ext_tw_video/1760998855049428993/pu/vid/avc1/480x270/YB-ZAON6aIbcoeyz.mp4?tag=12"
},
{
"type": "video/mp4",
"src": "https://video.twimg.com/ext_tw_video/1760998855049428993/pu/vid/avc1/640x360/hQ_eH-MGRWAv4xEB.mp4?tag=12"
},
{
"type": "video/mp4",
"src": "https://video.twimg.com/ext_tw_video/1760998855049428993/pu/vid/avc1/1280x720/F-HtKmjr_mqerw-E.mp4?tag=12"
},
{
"type": "application/x-mpegURL",
"src": "https://video.twimg.com/ext_tw_video/1760998855049428993/pu/pl/bBHXRY9ItFCLmL7W.m3u8?tag=12&container=cmaf"
}
],
"videoId": {
"type": "tweet",
"id": "1760999397951692825"
},
"viewCount": 0
},
"conversation_count": 0,
"news_action_type": "conversation",
"isEdited": false,
"isStaleEdit": false
}
}"