Recherche avancée

Médias (91)

Autres articles (30)

  • Déploiements possibles

    31 janvier 2010, par

    Deux types de déploiements sont envisageable dépendant de deux aspects : La méthode d’installation envisagée (en standalone ou en ferme) ; Le nombre d’encodages journaliers et la fréquentation envisagés ;
    L’encodage de vidéos est un processus lourd consommant énormément de ressources système (CPU et RAM), il est nécessaire de prendre tout cela en considération. Ce système n’est donc possible que sur un ou plusieurs serveurs dédiés.
    Version mono serveur
    La version mono serveur consiste à n’utiliser qu’une (...)

  • Création définitive du canal

    12 mars 2010, par

    Lorsque votre demande est validée, vous pouvez alors procéder à la création proprement dite du canal. Chaque canal est un site à part entière placé sous votre responsabilité. Les administrateurs de la plateforme n’y ont aucun accès.
    A la validation, vous recevez un email vous invitant donc à créer votre canal.
    Pour ce faire il vous suffit de vous rendre à son adresse, dans notre exemple "http://votre_sous_domaine.mediaspip.net".
    A ce moment là un mot de passe vous est demandé, il vous suffit d’y (...)

  • Les tâches Cron régulières de la ferme

    1er décembre 2010, par

    La gestion de la ferme passe par l’exécution à intervalle régulier de plusieurs tâches répétitives dites Cron.
    Le super Cron (gestion_mutu_super_cron)
    Cette tâche, planifiée chaque minute, a pour simple effet d’appeler le Cron de l’ensemble des instances de la mutualisation régulièrement. Couplée avec un Cron système sur le site central de la mutualisation, cela permet de simplement générer des visites régulières sur les différents sites et éviter que les tâches des sites peu visités soient trop (...)

Sur d’autres sites (5680)

  • Track API calls in Node.js with Piwik

    25 juin 2014, par Frederic Hemberger — Community, API, Node.js

    When using Piwik for analytics, sometimes you don’t want to track only your website’s visitors. Especially as modern web services usually offer RESTful APIs, why not use Piwik to track those requests as well ? It really gives you a more accurate view on how users interact with your services : In which ways do your clients use your APIs compared to your website ? Which of your services are used the most ? And what kind of tools are consuming your API ?

    If you’re using Node.js as your application platform, you can use piwik-tracker. It’s a lightweight wrapper for Piwik’s own Tracking HTTP API, which helps you tracking your requests.

    First, start with installing piwik-tracker as a dependency for your project :

    npm install piwik-tracker --save

    Then create a new tracking instance with your Piwik URL and the site ID of the project you want to track. As Piwik requires a fully qualified URL for analytics, add it in front of the actual request URL.

    var PiwikTracker = require('piwik-tracker');

    // Initialize with your site ID and Piwik URL
    var piwik = new PiwikTracker(1, 'http://mywebsite.com/piwik.php');

    // Piwik works with absolute URLs, so you have to provide protocol and hostname
    var baseUrl = 'http://example.com';

    // Track a request URL:
    piwik.track(baseUrl + req.url);

    Of cause you can do more than only tracking simple URLs : All parameters offered by Piwik’s Tracking HTTP API Reference are supported, this also includes custom variables. During Piwik API calls, those are referenced as JSON string, so for better readability, you should use JSON.stringify({}) instead of manual encoding.

    piwik.track({
       // The full request URL
       url: baseUrl + req.url,

       // This will be shown as title in your Piwik backend
       action_name: 'API call',

       // User agent and language settings of the client
       ua: req.header('User-Agent'),
       lang: req.header('Accept-Language'),

       // Custom request variables
       cvar: JSON.stringify({
         '1': ['API version', 'v1'],
         '2': ['HTTP method', req.method]
       })
    });

    As you can see, you can pass along arbitrary fields of a Node.js request object like HTTP header fields, status code or request method (GET, POST, PUT, etc.) as well. That should already cover most of your needs.

    But so far, all requests have been tracked with the IP/hostname of your Node.js application. If you also want the API user’s IP to show up in your analytics data, you have to override Piwik’s default setting, which requires your secret Piwik token :

    function getRemoteAddr(req) {
       if (req.ip) return req.ip;
       if (req._remoteAddress) return req._remoteAddress;
       var sock = req.socket;
       if (sock.socket) return sock.socket.remoteAddress;
       return sock.remoteAddress;
    }

    piwik.track({
       // …
       token_auth: '<YOUR SECRET API TOKEN>',
       cip: getRemoteAddr(req)
    });

    As we have now collected all the values that we wanted to track, we’re basically done. But if you’re using Express or restify for your backend, we can still go one step further and put all of this together into a custom middleware, which makes tracking requests even easier.

    First we start off with the basic code of our new middleware and save it as lib/express-piwik-tracker.js :

    // ./lib/express-piwik-tracker.js
    var PiwikTracker = require('piwik-tracker');

    function getRemoteAddr(req) {
       if (req.ip) return req.ip;
       if (req._remoteAddress) return req._remoteAddress;
       var sock = req.socket;
       if (sock.socket) return sock.socket.remoteAddress;
       return sock.remoteAddress;
    }

    exports = module.exports = function analytics(options) {
       var piwik = new PiwikTracker(options.siteId, options.piwikUrl);

       return function track(req, res, next) {
           piwik.track({
               url: options.baseUrl + req.url,
               action_name: 'API call',
               ua: req.header('User-Agent'),
               lang: req.header('Accept-Language'),
               cvar: JSON.stringify({
                 '1': ['API version', 'v1'],
                 '2': ['HTTP method', req.method]
               }),
               token_auth: options.piwikToken,
               cip: getRemoteAddr(req)

           });
           next();
       }
    }

    Now to use it in our application, we initialize it in our main app.js file :

    // app.js
    var express      = require('express'),
       piwikTracker = require('./lib/express-piwik-tracker.js'),
       app          = express();

    // This tracks ALL requests to your Express application
    app.use(piwikTracker({
       siteId    : 1,
       piwikUrl  : 'http://mywebsite.com/piwik.php',
       baseUrl   : 'http://example.com',
       piwikToken: '<YOUR SECRET API TOKEN>'
    }));

    This will now track each request going to every URL of your API. If you want to limit tracking to a certain path, you can also attach it to a single route instead :

    var tracker = piwikTracker({
       siteId    : 1,
       piwikUrl  : 'http://mywebsite.com/piwik.php',
       baseUrl   : 'http://example.com',
       piwikToken: '<YOUR SECRET API TOKEN>'
    });

    router.get('/only/track/me', tracker, function(req, res) {
       // Your code that handles the route and responds to the request
    });

    And that’s everything you need to track your API users alongside your regular website users.

  • avformat/mxfenc : fix muxing when audio tracks are longer than video track

    30 avril 2018, par Baptiste Coudurier
    avformat/mxfenc : fix muxing when audio tracks are longer than video track
    
    • [DH] libavformat/mxfenc.c
  • mxf : Extract origin information from material and source track

    22 juillet 2014, par Marc-Antoine Arnaud
    mxf : Extract origin information from material and source track
    

    Signed-off-by : Luca Barbato <lu_zero@gentoo.org>

    • [DBH] libavformat/mxfdec.c