0
votes

Fliter des vidéos en direct de l'API de recherche YouTube

J'essaie d'obtenir des vidéos en utilisant une requête de recherche avec youtube v3 api Search: list .

Mon corps de requête ressemble à ceci:

  request = youtube.search().list(
            part="snippet",
            maxResults=40,
            q="Cat work york"
        )

Mais le problème est qu'il renvoie des vidéos en direct parmi d'autres vidéos régulières. Je ne veux pas que les vidéos en direct soient renvoyées, comment puis-je faire cela? s'il vous plaît aidez-moi ici.

Merci


0 commentaires

3 Réponses :


0
votes

Je pense que vous devriez essayer de passer ce paramètre:

broadcastStatus="completed"

Voici la référence:

https://developers-dot-devsite-v2-prod.appspot.com/youtube/v3/live/docs/liveBroadcasts/list#parameters


2 commentaires

Salut, merci pour votre réponse. Je ne veux pas non plus de diffusion ou de streaming de vidéos. Juste les vidéos téléchargées régulièrement. Comment les interroger?


Vous pouvez peut-être essayer broadcastType='persistent' avec broadcastStatus='completed' .



0
votes

J'ai essayé avec cette demande et je n'ai eu aucune vidéo en direct - sans avoir besoin de filtres supplémentaires:

URL:

{
  "kind": "youtube#searchListResponse",
  "etag": "-KMpLk38ZnJHhWd5fPfmwou7bX4",
  "nextPageToken": "CAoQAA",
  "regionCode": "CO",
  "pageInfo": {
    "totalResults": 1000000,
    "resultsPerPage": 10
  },
  "items": [
    {
      "kind": "youtube#searchResult",
      "etag": "fe7kdo2hrlF2OjEpk8Nd1kbStFw",
      "id": {
        "kind": "youtube#video",
        "videoId": "jDoVckC6NhA"
      },
      "snippet": {
        "publishedAt": "2015-07-30T21:25:54Z",
        "channelId": "UC9k-yiEpRHMNVOnOi_aQK8w",
        "title": "Woman Endures Cat Calls Walking in Street: 'It Makes You Feel Like A Fool'",
        "description": "Cosmopolitan magazine is getting a lot of attention for a video they posted to their website of women facing a barrage of cat calls just by walking down the streets ...",
        "thumbnails": {
          "default": {
            "url": "https://i.ytimg.com/vi/jDoVckC6NhA/default.jpg",
            "width": 120,
            "height": 90
          },
          "medium": {
            "url": "https://i.ytimg.com/vi/jDoVckC6NhA/mqdefault.jpg",
            "width": 320,
            "height": 180
          },
          "high": {
            "url": "https://i.ytimg.com/vi/jDoVckC6NhA/hqdefault.jpg",
            "width": 480,
            "height": 360
          }
        },
        "channelTitle": "Inside Edition",
        "liveBroadcastContent": "none",
        "publishTime": "2015-07-30T21:25:54Z"
      }
    },
    {
      "kind": "youtube#searchResult",
      "etag": "k0tqw-tDAsnJZ5HJjBmHXZyiaiY",
      "id": {
        "kind": "youtube#video",
        "videoId": "aAxx1EZwDIY"
      },
      "snippet": {
        "publishedAt": "2016-02-13T05:35:16Z",
        "channelId": "UC-2ePlhDlfJyzU7vypHFgBQ",
        "title": "2 night races in traffic (cat & mouse)!!",
        "description": "what i normally encounter on my way home !!",
        "thumbnails": {
          "default": {
            "url": "https://i.ytimg.com/vi/aAxx1EZwDIY/default.jpg",
            "width": 120,
            "height": 90
          },
          "medium": {
            "url": "https://i.ytimg.com/vi/aAxx1EZwDIY/mqdefault.jpg",
            "width": 320,
            "height": 180
          },
          "high": {
            "url": "https://i.ytimg.com/vi/aAxx1EZwDIY/hqdefault.jpg",
            "width": 480,
            "height": 360
          }
        },
        "channelTitle": "Daily Street Racing",
        "liveBroadcastContent": "none",
        "publishTime": "2016-02-13T05:35:16Z"
      }
    },
    {
      "kind": "youtube#searchResult",
      "etag": "grZqq0QA-Z1xxcNDM4Iukhqx3GI",
      "id": {
        "kind": "youtube#video",
        "videoId": "nMlJJKNWQZY"
      },
      "snippet": {
        "publishedAt": "2018-06-24T13:00:04Z",
        "channelId": "UCINb0wqPz-A0dV9nARjJlOQ",
        "title": "Cat Runs A Real Estate Office In Brooklyn | The Dodo City Pets",
        "description": "This Cat Runs A Real Estate Office In Brooklyn | Valentino's dad found him as a stray and brought him to work at his real estate office in Carroll Gardens, ...",
        "thumbnails": {
          "default": {
            "url": "https://i.ytimg.com/vi/nMlJJKNWQZY/default.jpg",
            "width": 120,
            "height": 90
          },
          "medium": {
            "url": "https://i.ytimg.com/vi/nMlJJKNWQZY/mqdefault.jpg",
            "width": 320,
            "height": 180
          },
          "high": {
            "url": "https://i.ytimg.com/vi/nMlJJKNWQZY/hqdefault.jpg",
            "width": 480,
            "height": 360
          }
        },
        "channelTitle": "The Dodo",
        "liveBroadcastContent": "none",
        "publishTime": "2018-06-24T13:00:04Z"
      }
    },
    {
      "kind": "youtube#searchResult",
      "etag": "SzycZTHAXxzRnxJH7pl1H-3AHhc",
      "id": {
        "kind": "youtube#video",
        "videoId": "ZUO9ijDjXTg"
      },
      "snippet": {
        "publishedAt": "2020-08-14T03:04:14Z",
        "channelId": "UCcl8P4rYjdbxbFTXxkNXuZQ",
        "title": "Mega Hits 2020 🍍 Best Of Vocal Deep House Summer Music Mix 🍍 Deep Feeling By ChilledVibes Live #7",
        "description": "Mega Hits 2020 Best Of Vocal Deep House Summer Music Mix Deep Feeling By ChilledVibes Live #7 #SummerMusicMix #BestOfDeepHouse ...",
        "thumbnails": {
          "default": {
            "url": "https://i.ytimg.com/vi/ZUO9ijDjXTg/default.jpg",
            "width": 120,
            "height": 90
          },
          "medium": {
            "url": "https://i.ytimg.com/vi/ZUO9ijDjXTg/mqdefault.jpg",
            "width": 320,
            "height": 180
          },
          "high": {
            "url": "https://i.ytimg.com/vi/ZUO9ijDjXTg/hqdefault.jpg",
            "width": 480,
            "height": 360
          }
        },
        "channelTitle": "ChilledVibes",
        "liveBroadcastContent": "none",
        "publishTime": "2020-08-14T03:04:14Z"
      }
    },
    {
      "kind": "youtube#searchResult",
      "etag": "nNSPJNKlYZWYA5FDN96Jv9nFygk",
      "id": {
        "kind": "youtube#video",
        "videoId": "-JOy1nM6UoA"
      },
      "snippet": {
        "publishedAt": "2008-04-21T03:37:32Z",
        "channelId": "UCmSOMw225KDZwqOsLFe9GSw",
        "title": "CAT POWER - New York",
        "description": "Snail is sad but determined to make things work in NYC, with music by Cat Power.",
        "thumbnails": {
          "default": {
            "url": "https://i.ytimg.com/vi/-JOy1nM6UoA/default.jpg",
            "width": 120,
            "height": 90
          },
          "medium": {
            "url": "https://i.ytimg.com/vi/-JOy1nM6UoA/mqdefault.jpg",
            "width": 320,
            "height": 180
          },
          "high": {
            "url": "https://i.ytimg.com/vi/-JOy1nM6UoA/hqdefault.jpg",
            "width": 480,
            "height": 360
          }
        },
        "channelTitle": "puppetbully",
        "liveBroadcastContent": "none",
        "publishTime": "2008-04-21T03:37:32Z"
      }
    },
    {
      "kind": "youtube#searchResult",
      "etag": "HUmDdgYk1jz3lv6cNhiZLyqek8c",
      "id": {
        "kind": "youtube#video",
        "videoId": "XcAH4OMPlDs"
      },
      "snippet": {
        "publishedAt": "2020-04-17T15:53:42Z",
        "channelId": "UCUw3KEvEX49JlnYhlneD-CA",
        "title": "Running the York Cat Trail During Lockdown April 2020",
        "description": "For anyone who would like to experience the York Cat Trail but who can't get to York. Come with me on a 12 minute whistle stop tour of the cats on buildings in ...",
        "thumbnails": {
          "default": {
            "url": "https://i.ytimg.com/vi/XcAH4OMPlDs/default.jpg",
            "width": 120,
            "height": 90
          },
          "medium": {
            "url": "https://i.ytimg.com/vi/XcAH4OMPlDs/mqdefault.jpg",
            "width": 320,
            "height": 180
          },
          "high": {
            "url": "https://i.ytimg.com/vi/XcAH4OMPlDs/hqdefault.jpg",
            "width": 480,
            "height": 360
          }
        },
        "channelTitle": "The Cat Gallery",
        "liveBroadcastContent": "none",
        "publishTime": "2020-04-17T15:53:42Z"
      }
    },
    {
      "kind": "youtube#searchResult",
      "etag": "B6Mx6RpMg8UXlABqaFPgJd_EOqk",
      "id": {
        "kind": "youtube#video",
        "videoId": "df7g19GzFkg"
      },
      "snippet": {
        "publishedAt": "2019-11-05T02:24:12Z",
        "channelId": "UCDVYQ4Zhbm3S2dlz7P1GBDg",
        "title": "Cat on the Field Scores 50-Yd TD Run! 🐾",
        "description": "A fluffy feline makes its way onto the field and somehow gets to the end zone for a touchdown! The Dallas Cowboys take on the New York Giants during Week 9 ...",
        "thumbnails": {
          "default": {
            "url": "https://i.ytimg.com/vi/df7g19GzFkg/default.jpg",
            "width": 120,
            "height": 90
          },
          "medium": {
            "url": "https://i.ytimg.com/vi/df7g19GzFkg/mqdefault.jpg",
            "width": 320,
            "height": 180
          },
          "high": {
            "url": "https://i.ytimg.com/vi/df7g19GzFkg/hqdefault.jpg",
            "width": 480,
            "height": 360
          }
        },
        "channelTitle": "NFL",
        "liveBroadcastContent": "none",
        "publishTime": "2019-11-05T02:24:12Z"
      }
    },
    {
      "kind": "youtube#searchResult",
      "etag": "k5CXKp3kDIqnyqT03Vxj9_tMdKg",
      "id": {
        "kind": "youtube#video",
        "videoId": "j0RgF_AL5vk"
      },
      "snippet": {
        "publishedAt": "2018-08-31T02:11:05Z",
        "channelId": "UC4L0b4TTnV_dK67pWxPxPXA",
        "title": "FAT CAT PUT ALL THAT WORK IN AND TURNED ON PAPPY MASON HE IS NOW IN ADX SUFFERING 🤦🏽‍♂️😢",
        "description": "Fat cat TRIPLE DOUBLE CROSSER.",
        "thumbnails": {
          "default": {
            "url": "https://i.ytimg.com/vi/j0RgF_AL5vk/default.jpg",
            "width": 120,
            "height": 90
          },
          "medium": {
            "url": "https://i.ytimg.com/vi/j0RgF_AL5vk/mqdefault.jpg",
            "width": 320,
            "height": 180
          },
          "high": {
            "url": "https://i.ytimg.com/vi/j0RgF_AL5vk/hqdefault.jpg",
            "width": 480,
            "height": 360
          }
        },
        "channelTitle": "KING EARNER",
        "liveBroadcastContent": "none",
        "publishTime": "2018-08-31T02:11:05Z"
      }
    },
    {
      "kind": "youtube#searchResult",
      "etag": "QM6IfM0553SCG8Lb21omcpVmZ2k",
      "id": {
        "kind": "youtube#video",
        "videoId": "4cb1YIsyty4"
      },
      "snippet": {
        "publishedAt": "2016-09-12T14:18:43Z",
        "channelId": "UCEcDA5zAfZTVr93HoUzYf_w",
        "title": "Cat® Power Box Rake Attachment Operating Tips",
        "description": "http://www.cat.com/en_US/products/new/attachments/rakes.html | Learn operating tips for the Power Box Rake work tool attachment for Skid Steer Loaders, ...",
        "thumbnails": {
          "default": {
            "url": "https://i.ytimg.com/vi/4cb1YIsyty4/default.jpg",
            "width": 120,
            "height": 90
          },
          "medium": {
            "url": "https://i.ytimg.com/vi/4cb1YIsyty4/mqdefault.jpg",
            "width": 320,
            "height": 180
          },
          "high": {
            "url": "https://i.ytimg.com/vi/4cb1YIsyty4/hqdefault.jpg",
            "width": 480,
            "height": 360
          }
        },
        "channelTitle": "Cat Landscaping and Construction",
        "liveBroadcastContent": "none",
        "publishTime": "2016-09-12T14:18:43Z"
      }
    },
    {
      "kind": "youtube#searchResult",
      "etag": "gXii2GJAAanIFjYjqeIZvsctnHI",
      "id": {
        "kind": "youtube#video",
        "videoId": "4pq9N8qrTT0"
      },
      "snippet": {
        "publishedAt": "2020-07-14T14:23:32Z",
        "channelId": "UChLtXXpo4Ge1ReTEboVvTDg",
        "title": "''Rocco, put your tail down": Cat interrupts virtual UK parliamentary meeting",
        "description": "A member of the UK parliament's cat interrupted a live virtual committee meeting on Tuesday, prompting laughter from others on the call. John Nicolson was ...",
        "thumbnails": {
          "default": {
            "url": "https://i.ytimg.com/vi/4pq9N8qrTT0/default.jpg",
            "width": 120,
            "height": 90
          },
          "medium": {
            "url": "https://i.ytimg.com/vi/4pq9N8qrTT0/mqdefault.jpg",
            "width": 320,
            "height": 180
          },
          "high": {
            "url": "https://i.ytimg.com/vi/4pq9N8qrTT0/hqdefault.jpg",
            "width": 480,
            "height": 360
          }
        },
        "channelTitle": "Global News",
        "liveBroadcastContent": "none",
        "publishTime": "2020-07-14T14:23:32Z"
      }
    }
  ]
}

Et voici les résultats de la première page:

https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=10&q=Cat%20work%20york&type=video&key=[YOUR_API_KEY]

Si vous avez toujours des " vidéos en direct ", ajoutez le filtre videoDuration=medium dans la demande d'URL.


0 commentaires

0
votes

Essayez ceci https://developers.google.com/youtube/v3/docs/search/list avec les filtres suivants:

part="snippet", 
q="/-Live",
safeSearch="strict",
type="video


1 commentaires

Vous m'avez sauvé, merci :)