npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ouitube

v0.3.4

Published

L'API Ouitube est une bibliothèque JavaScript qui permet d'interagir avec l'API Ouitube pour récupérer, ajouter, mettre à jour et supprimer des vidéos.

Downloads

47

Readme

API Ouitube

L'API Ouitube est une bibliothèque JavaScript qui permet d'interagir avec l'API Ouitube pour récupérer, ajouter, mettre à jour et supprimer des vidéos.

Installation

Pour utiliser cette API, vous devez d'abord l'installer en utilisant npm :

npm install ouitube

Configuration

Pour démarrer la configuration, merci de créer un compte sur le site de streaming Ouitube (https://ouitube.fr), puis créer une application. Vous obtiendrez ainsi deux clés : clientId et clientSecret qui vous seront utiles pour la suite.

const { Ouitube } = require("ouitube");

const clientId = "Votre_Client_ID";
const clientSecret = "Votre_Client_Secret";


const ouitube = new Ouitube(clientId, clientSecret);

Exemples d'utilisation

Obtenir des vidéos par page

ouitube.request({
  url: "/video",
  method: "GET",
  query: [
    {
      name: "pageNumber",
      value: 5
    },
    {
      name: "pageLimit",
      value: 20
    }
  ]
})
.then(data => {
  console.log("Vidéos par page :", data);
});

Obtenir une video avec son code unique

ouitube.request({
  url: "/video/:uniqueCode",
  method: "GET"
})
.then(video => {
  console.log("Video :", video);
});

Rechercher des vidéos

ouitube.request({
    url: "/video/search",
    method: "GET",
    query: [
      {
        name: "name",
        value: "symfony" // mot clé de recherche
      },
      {
        name: "pageNumber",
        value: 1
      },
      {
        name: "pageLimit",
        value: 2
      }
    ]
  })
  .then(data => {
    console.log("Résultats de recherche :", data);
  });

Ajouter une vidéo

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
    <style>
    
    </style>
</head>
<body>
    
    <h1>Document</h1>
    <div class="container">
        <form id="videoForm" action="/api/videos" method="post" enctype="multipart/form-data">
            <div class="row">
                <div class="col-12 m-1">
                    <label for="name">Name :</label>
                    <input type="text" value="new name" id="name" placeholder="Video Name" name="name" class="form-control" required/>
                </div>
                <div class="col-12 m-1">
                    <label for="description">Description :</label>
                    <input type="text" value="new description" id="description" name="description" placeholder="Video Description" class="form-control" required/>
                </div>
                <div class="col-12 m-1">
                    <label for="file">File :</label>
                    <input type="file" id="file" name="file" class="form-control" required>
                </div>
            </div>
            <button type="submit" class="btn btn-primary">Save</button>
        </form>
        

    </div>

    <script type="module" src="./node_modules/ouitube/dist/index.js"></script>
    <script type="module" src="./script.js"></script>

</body>
</html>

const clientId = "Votre_Client_ID";
const clientSecret = "Votre_Client_Secret";

const oui = new Ouitube(clientId, clientSecret);

// Sélectionnez le formulaire
const videoForm = document.getElementById('videoForm');

// Écoutez l'événement de soumission du formulaire
videoForm.addEventListener('submit', async (e) => {
    e.preventDefault();

    // Récupérez les données du formulaire
    const formData = new FormData();

    const video = {
        name: document.getElementById("name").value,
        description: document.getElementById("description").value,
        create_at: new Date()
    }
    const file = document.getElementById("file").files[0]

    console.log({
        video, file
    });

    formData.append('video', JSON.stringify(video))
    formData.append('videoFile', file)

    
    // Effectuez une requête POST pour créer une nouvelle vidéo (vous devez gérer cela côté serveur)
    try {
        const response = await oui.request({
            method: "POST",
            data: formData,
            callback: (progress) =>{ console.log({progress});}
          })
       

          console.log('Video created successfully : ', response);
          alert('Video created successfully.');
        
    } catch (error) {
        // Gérez les erreurs réseau ici
        alert('Network error.');
    }
});

Mettre à jour les informations d'une viedo


const clientId = "Votre_Client_ID";
const clientSecret = "Votre_Client_Secret";

const oui = new Ouitube(clientId, clientSecret);

// video à modifier 
const video = {
  "_id": "65397fbcd05971e9bb10b348",
  "name": "Mise en place de l'inscription avec Angular",
  "description": "new description",
  "videoUri": "/video/read/65397fbcd05971e9bb10b348",
  "uniqueCode": "Ogro80OJ-w_ssY~rHB",
  "author": "65267c24068cd81609006d6c",
  "posterFiles": [
      "https://api.ouitube.fr/assets/images/posters/37521827974751698267067025_poster_1.jpg",
      "https://api.ouitube.fr/assets/images/posters/37521827974751698267067025_poster_2.jpg",
      "https://api.ouitube.fr/assets/images/posters/37521827974751698267067025_poster_3.jpg",
      "https://api.ouitube.fr/assets/images/posters/37521827974751698267067025_poster_4.jpg"
  ],
  "duration": "0:7:27",
  "created_at": "2023-10-25T19:28:41.273Z"
}

  oui.request({
    url: "/video/"+video.uniqueCode,
    method: "PUT",
    data: {
      name : "Cours 1 Présentation du framework frontend Angular",
      description : "Angular est un framework frontend Js"
    }
  })
  .then(data => {
    console.log("Vidéo modifiée :", data);
  });

Mettre à jour une vidéo

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Ouitube API</title>
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
    <style>
    
    </style>
</head>
<body>
    
    <h1>Update Video</h1>
    <div class="container">
        <form id="videoForm" novalidate>
            <div class="row">
                <div class="col-12 m-1">
                    <label for="name">Name :</label>
                    <input type="text" value="new name" id="name" placeholder="Video Name" name="name" class="form-control" required/>
                </div>
                <div class="col-12 m-1">
                    <label for="description">Description :</label>
                    <input type="text" value="new description" id="description" name="description" placeholder="Video Description" class="form-control" required/>
                </div>
                <div class="col-12 m-1">
                    <label for="file">File :</label>
                    <input type="file" id="file" name="file" class="form-control" required>
                </div>
            </div>
            <button type="submit" class="btn btn-primary">Update</button>
        </form>
        

    </div>

    <script type="module" src="./dist/index.js"></script>
    <script type="module" src="./script.js"></script>

</body>
</html>

const clientId = "Votre_Client_ID";
const clientSecret = "Votre_Client_Secret";

const oui = new Ouitube(clientId, clientSecret);

// video à modifier
let video = {
  "_id": "65397fbcd05971e9bb10b348",
  "name": "Cours 1 Présentation du framework frontend Angular",
  "description": "Angular est un framework frontend Js",
  "videoUri": "/video/read/65397fbcd05971e9bb10b348",
  "uniqueCode": "Ogro80OJ-w_ssY~rHB",
  "author": "65267c24068cd81609006d6c",
  "posterFiles": [
    "https://api.ouitube.fr/assets/images/posters/37521827974751698267067025_poster_1.jpg",
    "https://api.ouitube.fr/assets/images/posters/37521827974751698267067025_poster_2.jpg",
    "https://api.ouitube.fr/assets/images/posters/37521827974751698267067025_poster_3.jpg",
    "https://api.ouitube.fr/assets/images/posters/37521827974751698267067025_poster_4.jpg"
  ],
  "duration": "0:7:27",
  "updated_at": "2023-10-26T08:27:58.853Z",
  "created_at": "2023-10-25T19:28:41.273Z"
}
const uniqueCode = video.uniqueCode
oui.request({
  url: "/video/"+uniqueCode,
  method: "GET"
}).then(data => {
  if(data.isSuccess){
    video = data.result

    document.getElementById("name").value = video.name
    document.getElementById("description").value = video.description
  }
})
// Sélectionnez le formulaire
const videoForm = document.getElementById('videoForm');


// Écoutez l'événement de soumission du formulaire
videoForm.addEventListener('submit', async (e) => {
  e.preventDefault();

  // Récupérez les données du formulaire
  
  const video = {
    name: document.getElementById("name").value,
    description: document.getElementById("description").value,
    create_at: new Date()
  }
  const file = document.getElementById("file").files[0]
  
  console.log({
    video, file
  });
  

  let formData
  if(file){
    formData = new FormData();
    formData.append('video', JSON.stringify(video))
    formData.append('videoFile', file)

  }else{
    formData = video
  }


  // Effectuez une requête POST pour créer une nouvelle vidéo (vous devez gérer cela côté serveur)
  try {
    const response = await oui.request({
      url: "/video/"+uniqueCode,
      method: "PUT",
      data: formData,
      callback: (progress) => { console.log({ progress }); }
    })


    console.log('Video updated successfully : ', response);
    alert('Video updated successfully.');

  } catch (error) {
    // Gérez les erreurs réseau ici
    alert('Network error.');
  }
});

Supprimer une vidéo

const clientId = "Votre_Client_ID";
const clientSecret = "Votre_Client_Secret";

const oui = new Ouitube(clientId, clientSecret);

// video à supprimer 
const video = {
    "_id": "65397f7fd05971e9bb10b33c",
    "name": "new name",
    "description": "new description",
    "videoUri": "/video/read/65397f7fd05971e9bb10b33c",
    "uniqueCode": "PkgisSAw_nI~wpm-QM",
    "author": "65267c24068cd81609006d6c",
    "posterFiles":[
        "https://api.ouitube.fr/assets/images/posters/123091311281871698267007392_poster_1.jpg",
        "https://api.ouitube.fr/assets/images/posters/123091311281871698267007392_poster_2.jpg",
        "https://api.ouitube.fr/assets/images/posters/123091311281871698267007392_poster_3.jpg",
        "https://api.ouitube.fr/assets/images/posters/123091311281871698267007392_poster_4.jpg"
    ],
    "duration": "0:3:51",
    "created_at": "2023-10-25T19:28:41.273Z"
}

  oui.request({
    url: "/video/"+video.uniqueCode,
    method: "DELETE",
  })
  .then(data => {
    console.log("Vidéo supprimée :", data);
  });

Documentation supplémentaire

Pour plus d'informations sur les méthodes disponibles, les requêtes et les réponses, veuillez consulter la documentation dans le code source de cette API (https://ouitube.fr/documentation).

Contributions

Les contributions sont les bienvenues ! Si vous souhaitez améliorer cette API, veuillez soumettre des pull requests.

Licence

Ce projet est sous licence MIT - voir le fichier LICENSE.md pour plus de détails.