Документация и API
Smart Player JS API
ПО представляет собой интернет сервис, дополнительных требований по установке программы со стороны пользователя не требуется.

Плеер Video Publisher состоит из
следующих частей:

Кроссплатформенность

Гибкое единое API позволяет быстро интегрировать видео-платформу в собственную CMS сайта


Возможность демонстрировать рекламу в сети Интернет

Отслеживание ключевых событий в процессе просмотра видео


Поддержка всех современных стандартов видео (DASH/HLS/MP4)


Адаптивный стримминг

Совместимость с любым доступным способом монетизации на сайте клиента

Кастомизация интерфейса плеера под клиента

Возможность использовать плэйлисты


Поддержка прямых эфиров


Подключение DRM-модуля для защиты авторских прав контента


Поддержка AVOD/TVOD/SVOD/EST моделей продажи контента
Инструкции по установке плеера Video Publisher

Партнёр должен вставить этот код к себе на страницу, для подключения Smart API:


  • Простой плеер Video Publisher

   <script language="JavaScript" type="text/javascript" src="/src/player_builder.min.js"></script>
    <object class="TviglePlayer">
    <param name="bgcolor" value="#000000"/>
    <param name="width" value="720">
    <param name="height" value="405">
    <param name="id" value="875223">
    <param name="playlistID" value="35044">
    <param name="useAPI" value="true">
    <param name="autoChangeVideo" value="true">
    <param name="autoStart" value="true">
    </object>
  • Плеер Video Publisher с возможностью управления и прослушкой событий

<script language="JavaScript" type="text/javascript" src="/src/player_builder.min.js"></script>
    <object class="TviglePlayer">

    ...

    <!-- eventHandler: String (необязательный) - Имя JS метода, который будет обрабатывать "события" из тикета VP-110 -->
    <param name="eventHandler" value="Partner.eventHandler">

    <!-- templateLoadHandler: String (необязательный) - Имя JS метода, который будет вызван в момент инициализации плеера -->
    <param name="templateLoadHandler" value="Partner.onLoaded">

    <!-- templateReadyHandler: String (необязательный) - Имя JS метода, который будет вызван в момент готовности плеера к проигрыванию -->
    <param name="templateReadyHandler" value="Partner.onReady">

    ...

    </object>

JavaScript


 var PlayerProxy = function(player) {
        this.player = undefined;
        this.handlers = {
        "current_video_change": function(id) {
        console.warn("----now video id is", id);
        },
        "play": function(video) {
        console.warn("----video playing");
        },
        "pause": function(video) {
        console.warn("----video paused");
        },
        "on_progress": function(position) {
        console.warn("----position eq", position);
        }
        };
    };

    //----------------------------------- METHODS
    PlayerProxy.prototype.play = function() {
    this.getPlayer().play();
    };

    PlayerProxy.prototype.pause = function() {
    this.getPlayer().pause();
    };

    PlayerProxy.prototype.stop = function() {
    this.getPlayer().stop();
    };

    PlayerProxy.prototype.next = function(autoplay) {
    this.getPlayer().next(autoplay);
    };

    PlayerProxy.prototype.prev = function(autoplay) {
    this.getPlayer().prev(autoplay);
    };

    PlayerProxy.prototype.setQuality = function(quality) {
    this.getPlayer().setQuality(quality);
    };

    PlayerProxy.prototype.seek = function(position) {
    this.getPlayer().seek(position);
    };

    PlayerProxy.prototype.getState = function() {
    var self = this;
    this.getPlayer().getState(function(state) {
    var isPlaying = !!(state & self.states.STATE_PLAYING);
    console.warn(isPlaying);
    });
    };

    //-----------------------------------
    PlayerProxy.prototype.getPlayer = function() {
    return this.getPlayerObject().getModule(tvigle.api.modules.APIModules.VIDEO_PLAYER);
    };

    PlayerProxy.prototype.setPlayerObject = function(player) {
    this.player = player;
    };

    PlayerProxy.prototype.getPlayerObject = function() {
    return this.player;
    };

    PlayerProxy.prototype.getHandler = function(name) {
    return this.handlers[name];
    };

    //----------------------------------- STATIC
    PlayerProxy.getInstance = function() {
    if (this.instance === undefined) {
    this.instance = new PlayerProxy();
    }
    return this.instance;
    };

    Partner = (function(player) {
    "use strict";
    return {

    /**
    * Player was created
    * @param {String} id   Player ID
    */
    "onLoaded": function(id) {
    player.setPlayerObject(tvigle.api.getPlayer(id));
    },

    /**
    * Player prepared to play
    */
    "onReady": function() {
    // Autoplay example
    // player.play();
    },

    /**
    * Event router
    * @param event
    */
    "eventHandler": function(event) {
    var command = event['name'],
    args = event['args'];
    var method = player.getHandler(command);

    if (typeof method === "function") {
    method.apply(player, args);
    } else if (window.console){
    console.log("Function named " + command + "(" + args.length + " params) is not defined.");
    }
    }
    };

    this.states = {};
    this.states.STATE_INITED = 1 << 0;
    this.states.STATE_ACTIVATED = 1 << 1;
    this.states.STATE_AD_SHOWING = 1 << 2;
    this.states.STATE_BUFFERING = 1 << 3;
    this.states.STATE_PLAYING = 1 << 4;
    this.states.STATE_PAUSED = 1 << 5;
    this.states.STATE_STOPPED = 1 << 6;
    this.states.STATE_IN_SEEK = 1 << 7;
    this.states.STATE_FULLSCREEN = 1 << 8;
    this.states.STATE_FULLBROWSER = 1 << 9;
    this.states.STATE_FITTED = 1 << 10;
    this.states.STATE_CONTINUOUS_PLAY = 1 << 11;
    this.states.STATE_FIT_AVAILABLE = this.states.STATE_FULLBROWSER | this.states.STATE_FULLSCREEN;
    this.states.STATE_MIDDLE_ROLL_WAS = 1 << 12;
    })(PlayerProxy.getInstance());

Методы доступные партнёру (Сеттеры)


loadVideoByID(id: Integer): void
play(): void
pause(): void
stop(): void
seek(time: Number): void
next([autoplay: Boolean]): void
prev([autoplay: Boolean]): void
setVolume(volume: Number): void
setQuality(quality: String): void (описание ниже, раздел "Качества видео")
fullscreen(): void

Методы доступные партнёру (Геттеры)


getVolume(callback: Function): void
getDuration(callback: Function): void
getVideoQueue(callback: Function): void
getCurrentVideo(callback: Function): void
getPosition(callback: Function): void
getState(callback: Function): void (описание ниже, раздел "Состояния плеера")

Состояния плеера Video Publisher


(1 << 0) - Плеер проинициализирован
(1 << 1) - Плеер готов к проигрыванию
(1 << 2) - Идёт показ рекламы (плеер заблокирован)
(1 << 3) - Идёт буферизация
(1 << 4) - Играет
(1 << 5) - На паузе
(1 << 6) - Был остановлен
(1 << 7) - Идёт поиск ключевого кадра во время выполнения метода seek
(1 << 8) - Плеер зафулскринен
(1 << 9) - Плеер зафулбраузен
(1 << 10) - Overlay
(1 << 11) - Проигрывание продолжается

Качества видео


HD240 - 240p качество
HD320 - 320p качество
HD480 - 480p качество
HD720 - 720p качество
HD1080 - 1080p качество
HD1440 - 1440p качество
Работа с контентом | ВИДЕО
Добавление видео POST /api/videos/
Request (application/json)
01
  • Body

{
    "name": "Название видео",
    "description": "Описание видео",
    "show_ad": true,
    "age_restrictions": "6+",
    "publication_date": "%Y-%m-%d %H:%M",
    "callback_url": "http://example.com/callback/",
    "source_url" : "http://example.com/source.mp4",
    "resources": :[
        {
            "quality":"240p",
            "url":"http://www.tvigle.ru/1.avi"
        },
        {
            "quality":"720p",
            "url":"http://www.tvigle.ru/2.avi"
        }
    ]
}
  • Schema

{
    "type":"object",
    "required":[
        "name",
        "description"
    ],
    "properties":{
        "name":{
            "type":"string"
        },
        "description":{
            "type":"string"
        }
    },
    "show_ad":{
        "type":"boolean"
    },
    "age_restrictions":{
        "type":"string"
    },
    "publication_date":{
        "type":"date-time"
    },
    "callback_url":{
        "type":"string"
    },
    "source_url":{
        "type":"string"
    },
    "resources":{
        "type":"array",
        "items":{
            "type":"object",
            "required":[
                "quality",
                "url"
            ],
            "properties":{
                "quality":"string",
                "url":"string"
            }
        }
    }
}
  • Response 201 (application/json)

{
    "embed_html": "<script language='JavaScript' 
                        type='text/javascript' 
                        src='/static/player/player_builder.min.js'></script>
        <object class='TviglePlayer'>
            <param name='bgcolor' value='#000000' />
            <param name='height' value='405' />
            <param name='width' value='702' />
            <param name='id' value='1' />
            <param name='useAPI' value='true' />
            <param name='autoChangeVideo' value='false' />
        </object>",
    "duration": "0:47",
    "id": 1,
    "category": 5,
    "errors": [],
    "country_restrictions": [],
    "age_restrictions": "18+",
    "progress": 100,
    "thumbnail": "http://photo.tvigle.ru/res/prt/c330f15b00e2d7499a04688ae5657e5d/40/33/000001284033/pub.jpg",
    "resources": [
        {
            "status": "queued",
            "progress": 0,
            "errors": [],
            "quality": "240p",
            "id": 2
        },
        {
            "status": "queued",
            "progress": 0,
            "errors": [],
            "quality": "480p",
            "id": 1
        }
    ],
    "status": "published",
    "description": "",
    "tags": [],
    "show_ad": true,
    "is_active": true,
    "is_playable": true,
    "publication_date": null,
    "name": "\u041A\u0430\u043A\u043E\u0435-\u0442\u043E \u0438\u043C\u044F",
    "created_at": "2013-06-29 10:19:43",
    "aspect_ratio": "16:9",
    "distribution": 1,
    "freezeFrame": null
}
Получение списка видео GET /api/videos/{?contract_id}{?order_by}{?q}{?name}{?status}{?tv_id}{?license_date_to}
  • Parameters
  • contract_id (optional, numeric, 1) ... id контракта, к которому привязано видео
  • order_by (optional, string, -created_time) ... поле, по которому сортировать. Допустимые значения: -name, name, created_time, -created_time, -publication_start_date, publication_start_date
  • q (optional, string, Поиск) ... поисковая строка, по которой искать видео
  • name (optional, string, Видео) ... имя, по которому фильтровать видео
  • status (optional, string, published) ... статус, по которому фильтровать видео. Допустимые варианты: queued, waiting, processing, finished, published, failed, cancelled
  • tv_id (optional, string, 111) ... tv_id, по которому фильтровать видео
  • license_date_to (optional, string, 'YYYY-MM-DD') ... license_date_to, фильтр по дате завершения лицензии. Выводит видео, лицензия на которые истекает не позднее указанной даты.
02
  • Response 200 (application/json)

{
    "total_count":3064,
    "result":[
        {
            "status":"published",
            "embed_html":"<iframe src='http://127.0.0.1:8000/video/5350456/?playerId=13&amp;partnerId=1' 
                width='854' 
                height='405' 
                frameborder='no' 
                scrolling='no' 
                webkitAllowFullScreen 
                mozallowfullscreen 
                allowfullscreen></iframe>",
            "subtitle":null,
            "description":"\u043f\u043e\u043f-\u043c\u0443\u0437\u044b\u043a\u0430 La Vtornik!",
            "tags":[
                "\u043f\u043e\u043f-\u043c\u0443\u0437\u044b\u043a\u0430",
                "La Vtornik",
                "\u043f\u043e\u043f"
            ],
            "iframe_url":"http://127.0.0.1:8000/video/5350456/?playerId=13&partnerId=1",
            "show_ad":true,
            "embed_object":"<object class='TviglePlayer'>
                    <param name='id' value='5350456'>
                    <param name='adv_cat_id' value='6'>
                    <param name='partnerId' value='1'>
                    <param name='autoStart' value='true'>
                    <param name='forceFlashObject' value='true'>
                    <param name='wmode' value='opaque'>
                    <param name='playerId' value='13'>
                    <param name='width' value='854'>
                    <param name='height' value=''>
                    <param name='useAPI' value='true'>
                    <param name='autoChangeVideo' value='false'>
                    <!--<param name='api_sign' value='play_token=111&expire=222&key=333'>-->
                    <!--<param name='trace' value='true'>-->
                </object>
                <script language='JavaScript' 
                        type='text/javascript' 
                        data-hang='false' 
                        src='/static/player/player_builder.min.js'></script>",
            "is_active":true,
            "is_playable":true,
            "duration_in_ms":201762,
            "callback_url":null,
            "errors":[],
            "meta":{
                "country_restrictions":[]
            },
            license": {
                "date_from": "2017-03-20",
                "date_to": "2018-03-20"
            },
            "duration":"3:21",
            "publication_date":"2013-12-28 21:00:00",
            "is_banned":false,
            "freezeFrame":"//127.0.0.1:8000/res/2016/01/11/0f113cb6-ccb7-448d-83b0-32611fb2648f.png",
            "partner_id":1,
            "id":5350456,
            "category":27774,
            "rightholder":18799,
            "country_restrictions":[],
            "name":"\u0417\u0430\u0446\u0435\u043f\u0438\u043b\u0430",
            "publication_start_date":"",
            "age_restrictions":"12+",
            "created_at":"2016-01-11 18:18:20",
            "url":"/client/videos/5350456/",
            "publication_end_date":"",
            "aspect_ratio":null,
            "progress":100,
            "distribution":1,
            "status_display":"\u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d",
            "thumbnail":"//127.0.0.1:8000/res/2016/01/11/18da8e2d-3f87-4bf8-bcc6-c14e917b2738.jpg",
            "resources":[
                {
                    "status":"finished",
                    "errors":[],
                    "format":"flv",
                    "progress":100,
                    "quality":"1080p",
                    "id":9632266
                },
                {
                    "status":"finished",
                    "errors":[],
                    "format":"mp4",
                    "progress":100,
                    "quality":"480p",
                    "id":9632263
                }
            ],
            "tv_id":null
        }
    ]
}
Получение списка партнёрского видео GET /api/videos/{?partner_id}
  • Parameters
  • partner_id (required, integer, 1) ... id партнёра, видео которого доступно
  • примечание: для получения списка видео Tvigle.ru необходимо использовать параметр ?partner_id=24
03
  • Response 200 (application/json)

{
    "total_count":3064,
    "result":[
        {
            "status":"published",
            "embed_html":"<iframe src='http://127.0.0.1:8000/video/5350456/?playerId=13&amp;partnerId=1'
                width='854'
                height='405'
                frameborder='no'
                scrolling='no' 
                webkitAllowFullScreen 
                mozallowfullscreen 
                allowfullscreen></iframe>",
            "subtitle":null,
            "description":"\u043f\u043e\u043f-\u043c\u0443\u0437\u044b\u043a\u0430 La Vtornik!",
            "tags":[
                "\u043f\u043e\u043f-\u043c\u0443\u0437\u044b\u043a\u0430",
                "La Vtornik",
                "\u043f\u043e\u043f"
            ],
            "iframe_url":"http://127.0.0.1:8000/video/5350456/?playerId=13&partnerId=1",
            "show_ad":true,
            "embed_object":"<object class='TviglePlayer'>
                <param name='id' value='5350456'>
                <param name='adv_cat_id' value='6'>
                <param name='partnerId' value='1'>
                <param name='autoStart' value='true'>
                <param name='forceFlashObject' value='true'>
                <param name='wmode' value='opaque'>
                <param name='playerId' value='13'>
                <param name='width' value='854'>
                <param name='height' value=''>
                <param name='useAPI' value='true'>
                <param name='autoChangeVideo' value='false'>
                <!--<param name='api_sign' value='play_token=111&expire=222&key=333'>-->
                <!--<param name='trace' value='true'>-->
                </object>
                <script language='JavaScript' 
                        type='text/javascript' 
                        data-hang='false' 
                        src='/static/player/player_builder.min.js'></script>",
            "is_active":true,
            "is_playable":true,
            "duration_in_ms":201762,
            "callback_url":null,
            "errors":[],
            "meta":{
                "country_restrictions":[]
            },
            "duration":"3:21",
            "publication_date":"2013-12-28 21:00:00",
            "is_banned":false,
            "freezeFrame":"//127.0.0.1:8000/res/2016/01/11/0f113cb6-ccb7-448d-83b0-32611fb2648f.png",
            "partner_id":1,
            "id":5350456,
            "category":27774,
            "rightholder":18799,
            "country_restrictions":[],
            "name":"\u0417\u0430\u0446\u0435\u043f\u0438\u043b\u0430",
            "publication_start_date":"",
            "age_restrictions":"12+",
            "created_at":"2016-01-11 18:18:20",
            "url":"/client/videos/5350456/",
            "publication_end_date":"",
            "aspect_ratio":null,
            "progress":100,
            "distribution":1,
            "status_display":"\u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d",
            "thumbnail":"//127.0.0.1:8000/res/2016/01/11/18da8e2d-3f87-4bf8-bcc6-c14e917b2738.jpg",
            "resources":[
                {
                    "status":"finished",
                    "errors":[],
                    "format":"flv",
                    "progress":100,
                    "quality":"1080p",
                    "id":9632266
                },
                {
                    "status":"finished",
                    "errors":[],
                    "format":"mp4",
                    "progress":100,
                    "quality":"480p",
                    "id":9632263
                }
            ],
            "tv_id":null
        }
    ]
}
Удаление видео DELETE /api/videos/{id}
  • Parameters
  • id (required, integer, 1) ... id видео
  • Response 204
04
Получение видео по ID GET /api/videos/{id}
  • Parameters
  • id (required, integer, 1) ... id видео
05
  • Response 200 (application/json)

{
    "status":"published",
    "embed_html":"<iframe src='http://127.0.0.1:8000/video/5350456/?playerId=13&amp;partnerId=1'
        width='854'
        height='405'
        frameborder='no'
        scrolling='no' 
        webkitAllowFullScreen 
        mozallowfullscreen 
        allowfullscreen></iframe>",
    "subtitle":null,
    "description":"\u043f\u043e\u043f-\u043c\u0443\u0437\u044b\u043a\u0430 La Vtornik!",
    "tags":[
        "\u043f\u043e\u043f-\u043c\u0443\u0437\u044b\u043a\u0430",
        "La Vtornik",
        "\u043f\u043e\u043f"
    ],
    "iframe_url":"http://127.0.0.1:8000/video/5350456/?playerId=13&partnerId=1",
    "show_ad":true,
    "embed_object":"<object class='TviglePlayer'>
            <param name='id' value='5350456'>
            <param name='adv_cat_id' value='6'>
            <param name='partnerId' value='1'>
            <param name='autoStart' value='true'>
            <param name='forceFlashObject' value='true'>
            <param name='wmode' value='opaque'>
            <param name='playerId' value='13'>
            <param name='width' value='854'>
            <param name='height'value=''>
            <param name='useAPI' value='true'>
            <param name='autoChangeVideo' value='false'>
            <!--<param name='api_sign' value='play_token=111&expire=222&key=333'>-->
            <!--<param name='trace' value='true'>-->
        </object>
        <script language='JavaScript' 
                type='text/javascript' 
                data-hang='false' 
                src='/static/player/player_builder.min.js'></script>",
    "is_active":true,
    "is_playable":true,
    "duration_in_ms":201762,
    "callback_url":null,
    "errors":[],
    "meta":{
        "country_restrictions":[]
    },
    "duration":"3:21",
    "publication_date":"2013-12-28 21:00:00",
    "is_banned":false,
    "freezeFrame":"//127.0.0.1:8000/res/2016/01/11/0f113cb6-ccb7-448d-83b0-32611fb2648f.png",
    "partner_id":1,
    "id":5350456,
    "category":27774,
    "rightholder":18799,
    "country_restrictions":[],
    "name":"\u0417\u0430\u0446\u0435\u043f\u0438\u043b\u0430",
    "publication_start_date":"",
    "age_restrictions":"12+",
    "created_at":"2016-01-11 18:18:20",
    "url":"/client/videos/5350456/",
    "publication_end_date":"",
    "aspect_ratio":null,
    "progress":100,
    "distribution":1,
    "status_display":"\u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d",
    "thumbnail":"//127.0.0.1:8000/res/2016/01/11/18da8e2d-3f87-4bf8-bcc6-c14e917b2738.jpg",
    "resources":[
        {
            "status":"finished",
            "errors":[],
            "format":"flv",
            "progress":100,
            "quality":"1080p",
            "id":9632266
        },
        {
            "status":"finished",
            "errors":[],
            "format":"mp4",
            "progress":100,
            "quality":"480p",
            "id":9632263
        }
    ],
    "tv_id":null
}
Получение метаданных видео GET /api/videos/{video_id}/meta/?partner_id=24{?access_token}
  • Parameters
  • video_id (required, numeric, 1) ... id видео
  • access_token (required, string, 2356db1a9ed7243a61ea58cd29cc7573) ... авторизационный токен
06
  • Response 200 (application/json)

{
    "album":"",
    "description":"Недавно уволенные друзья, которым уже за сорок...",
    "film_studios":[],
    "kinopoisk_id":null,
    "url":"http://www.tvigle.ru/video/kadry-treiler/",
    "season":null,
    "tags":[
        "Оуэн Уилсон",
        "Винс Вон",
        "The Internship",
        "2013",
    ],
    "original_name":"",
    "persons":{
        "producers":[],
        "directors":[],
        "writers":[],
        "actors":[],
        "composer":[],
        "singers":[]
    },
    "release_year":null,
    "awards":[],
    "genries":[
        "Комедия"
    ],
    "series":null,
    "countries":[],
    "id":5147182,
    "name":"Кадры Трейлер"
}
Редактирование видео PUT /api/videos/{id}
  • Parameters
  • id (required, integer, 1) ... id видео
  • Request (application/json)
07
  • Body

{
    "name": "Название видео",
    "description": "Описание видео",
    "show_ad": true,
    "age_restrictions": "6+",
    "publication_date": "%Y-%m-%d %H:%M"
}
  • Schema

{
    "type":"object",
    "required":[
        "name",
        "description"
    ],
    "properties":{
        "name":{
            "type":"string"
        },
        "description":{
            "type":"string"
        }
    },
    "show_ad":{
        "type":"boolean"
    },
    "age_restrictions":{
        "type":"string"
    },
    "publication_date":{
        "type":"date-time"
    }
}
Работа с контентом | Плейлисты

Список GET /api/playlists/{?q}
  • Parameters
  • q (required, string, строка) ... строка, по которой искать плейлисты
01
  • Response 200 (application/json)

{
    "total_count":1,
    "result":[
        {
            "embed_html":"<iframe src='http://cloud.tvigle.ru/playlist/1/?playerId=1&amp;partnerId=1'
                width='854'
                height='405'
                frameborder='no'
                scrolling='no' 
                webkitAllowFullScreen 
                mozallowfullscreen 
                allowfullscreen></iframe>",
            "description":"",
            "iframe_url":"http://cloud.tvigle.ru/playlist/1/?playerId=1&partnerId=1",
            "embed_object":"<object class='TviglePlayer'>
                    <param name='playlistID' value='1'>
                    <param name='id' value=''>
                    <param name='adv_cat_id' value='1'>
                    <param name='partnerId' value='1'>
                    <param name='autoStart' value='true'>
                    <param name='forceFlashObject' value='true'>
                    <param name='wmode' value='opaque'>
                    <param name='playerId' value='1'>
                    <param name='width' value='854'>
                    <param name='height' value=''>
                    <param name='useAPI' value='true'>
                    <param name='autoChangeVideo' value='false'>
                </object>
                <script language='JavaScript' 
                        type='text/javascript' 
                        data-hang='false' 
                        src='//cloud.tvigle.ru/static/player/player_builder.min.js'></script>",
            "is_active":true,
            "number_of_videos":0,
            "id":1,
            "name":"123"
        }
    ]
}
Создание POST /api/playlists/
02
  • Response 200 (application/json)

{
    "description": "test_playlist_description",
    "name": "test_playlist_name6"
}
  • Response 201 (application/json)

{
    "embed_html":"<iframe src='http://cloud.tvigle.ru/playlist/1/?playerId=1&amp;partnerId=1'
        width='854'
        height='405'
        frameborder='no'
        scrolling='no' 
        webkitAllowFullScreen 
        mozallowfullscreen 
        allowfullscreen></iframe>",
    "description":"test_playlist_description",
    "iframe_url":"http://cloud.tvigle.ru/playlist/1/?playerId=1&partnerId=1",
    "embed_object":"<object class='TviglePlayer'>
            <param name='playlistID' value='1'>
            <param name='id' value=''>
            <param name='adv_cat_id' value='1'>
            <param name='partnerId' value='1'>
            <param name='autoStart' value='true'>
            <param name='forceFlashObject' value='true'>
            <param name='wmode' value='opaque'>
            <param name='playerId' value='1'>
            <param name='width' value='854'>
            <param name='height' value=''>
            <param name='useAPI' value='true'>
            <param name='autoChangeVideo' value='false'>
        </object>
        <script language='JavaScript' 
                type='text/javascript' 
                data-hang='false' 
                src='//cloud.tvigle.ru/static/player/player_builder.min.js'></script>",
    "is_active":true,
    "number_of_videos":0,
    "id":1,
    "name":"test_playlist_name6"
}
Детали GET /api/playlists/{id}/
  • Parameters
  • id (required, numeric, 1) ... id плейлиста
03
  • Response 200 (application/json)

{
    "embed_html":"<iframe src='http://cloud.tvigle.ru/playlist/1/?playerId=1&amp;partnerId=1'
        width='854'
        height='405'
        frameborder='no'
        scrolling='no' 
        webkitAllowFullScreen 
        mozallowfullscreen 
        allowfullscreen></iframe>",
    "description":"",
    "iframe_url":"http://cloud.tvigle.ru/playlist/1/?playerId=1&partnerId=1",
    "embed_object":"<object class='TviglePlayer'>
            <param name='playlistID' value='1'>
            <param name='id' value=''>
            <param name='adv_cat_id' value='1'>
            <param name='partnerId' value='1'>
            <param name='autoStart' value='true'>
            <param name='forceFlashObject' value='true'>
            <param name='wmode' value='opaque'>
            <param name='playerId' value='1'>
            <param name='width' value='854'>
            <param name='height' value=''>
            <param name='useAPI' value='true'>
            <param name='autoChangeVideo' value='false'>
        </object>
        <script language='JavaScript' 
                type='text/javascript' 
                data-hang='false' 
                src='//cloud.tvigle.ru/static/player/player_builder.min.js'></script>",
    "is_active":true,
    "number_of_videos":0,
    "id":1,
    "name":"123"
}

Изменение PUT /api/playlists/{id}/

  • Parameters
  • id (required, numeric, 1) ... id плейлиста
04
  • Request (application/json)

{
    "description": "update2",
    "name": "updated1"
}
  • Response 200 (application/json)

{
    "embed_html":"<iframe src='http://cloud.tvigle.ru/playlist/1/?playerId=1&amp;partnerId=1'
        width='854'
        height='405'
        frameborder='no'
        scrolling='no'
        webkitAllowFullScreen 
        mozallowfullscreen 
        allowfullscreen></iframe>",
    "description":"update2",
    "iframe_url":"http://cloud.tvigle.ru/playlist/1/?playerId=1&partnerId=1",
    "embed_object":"<object class='TviglePlayer'>
            <param name='playlistID' value='1'>
            <param name='id' value=''>
            <param name='adv_cat_id' value='1'>
            <param name='partnerId' value='1'>
            <param name='autoStart' value='true'>
            <param name='forceFlashObject' value='true'>
            <param name='wmode' value='opaque'>
            <param name='playerId' value='1'>
            <param name='width' value='854'>
            <param name='height' value=''>
            <param name='useAPI' value='true'>
            <param name='autoChangeVideo' value='false'>
        </object>
        <script language='JavaScript' 
                type='text/javascript' 
                data-hang='false' 
                src='//cloud.tvigle.ru/static/player/player_builder.min.js'></script>",
    "is_active":true,
    "number_of_videos":0,
    "id":1,
    "name":"updated1"
}
Удаление DELETE /api/playlists/{id}/
  • Parameters
  • id (required, numeric, 1) ... id плейлиста
  • Response 204
05

Список видео GET /api/playlists/{id}/videos/

  • Parameters
  • id (required, numeric, 1) ... id плейлиста
06
  • Response 200 (application/json)

{
    "total_count":1,
    "result":[
        {
            "embed_html":"<iframe src='http://cloud.tvigle.ru/video/1/?playerId=1' 
                width='702' 
                height='405' 
                frameborder='no' 
                scrolling='no' 
                webkitAllowFullScreen 
                mozallowfullscreen 
                allowfullscreen></iframe>",
            "subtitle":null,
            "callback_url":null,
            "meta":{
                "country_restrictions":[]
            },
            "duration":"2:44",
            "partner_id":24,
            "id":5144693,
            "category":33295,
            "errors":[],
            "country_restrictions":[],
            "age_restrictions":"0+",
            "publication_end_date":"2015-11-20 12:58:03",
            "progress":100,
            "thumbnail":"//example.com/thumbnail.png",
            "resources":[
                {
                    "status":"finished",
                    "errors":[],
                    "format":"mp4",
                    "progress":100,
                    "quality":"240p",
                    "id":850898
                },
                {
                    "status":"finished",
                    "errors":[],
                    "format":"flv",
                    "progress":100,
                    "quality":"240p",
                    "id":850899
                },
                {
                    "status":"finished",
                    "errors":[],
                    "format":"flv",
                    "progress":100,
                    "quality":"480p",
                    "id":850900
                },
                {
                    "status":"finished",
                    "errors":[],
                    "format":"mp4",
                    "progress":100,
                    "quality":"480p",
                    "id":850901
                }
            ],
            "tv_id":null,
            "status":"finished",
            "description":"Описание",
            "tags":[
                "тег 1",
                "тег 2",
            ],
            "iframe_url":"http://cloud.tvigle.ru/video/1/?playerId=1",
            "show_ad":true,
            "embed_object":"<object class='TviglePlayer'>
                    <param name='id' value='1'>
                    <param name='adv_cat_id' value='1'>
                    <param name='partnerId' value='1'>
                    <param name='autoStart' value='true'>
                    <param name='forceFlashObject' value='true'>
                    <param name='wmode' value='opaque'>
                    <param name='playerId' value='1'>
                    <param name='width' value=''>
                    <param name='height' value=''>
                    <param name='useAPI' value='true'>
                    <param name='autoChangeVideo' value='false'>
                    <!--<param name='api_sign' value='play_token=111&expire=222&key=333'>-->
                    <!--<param name='trace' value='true'>-->
            </object>
            <script language='JavaScript' 
                    type='text/javascript' 
                    data-hang='false' 
                    src='//cloud.tvigle.ru/static/player/player_builder.min.js'></script>",
            "is_active":true,
            "is_playable":true,
            "duration_in_ms":146680,
            "status_display":"\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d",
            "publication_date":"2013-02-20 15:40:00",
            "is_banned":false,
            "rightholder":1,
            "name":"Название",
            "publication_start_date":"",
            "created_at":"2014-08-18 20:43:48",
            "url":"/client/videos/1/",
            aspect_ratio":null,
            "distribution":1,
            "freezeFrame":null,
            "order":1
        }
    ]
}
Добавление видео POST /api/playlists/{playlist_id}/videos/{video_id}/
  • Parameters
  • playlist_id (required, numeric, 1) ... id плейлиста
  • video_id (required, numeric, 1) ... id видео
  • Response 201
07

Удаление видео DELETE /api/playlists/{playlist_id}/videos/{video_id}/

  • Parameters
  • playlist_id (required, numeric, 1) ... id плейлиста
  • video_id (required, numeric, 1) ... id видео
  • Response 204
08
Работа с контентом | Категории
Список GET /api/library/{?q}{?parent_id}{?level}
  • Parameters
  • q (optional, string, запрос) ... строка запроса, по которой фильтровать категории
  • parent_id (optional, numeric, 1) ... id родительской категории
  • level (optional, numeric, 1) ... уровень вложенности категории. Например, чтобы получить категории только 1 уровня, необходимо передать level=1
01
  • Response 200 (application/json)

{
    "total_count": 11,
    "result": [
        {
            "description": "description",
            "has_children": false,
            "is_active": true,
            "id": 20114,
            "name": "ttt",
            "level": 0,
            "url": "/client/categories/20114/",
            "priority": 0,
            "parent_id": null,
            "number_of_videos": 0,
            "thumbnail": ""
        }
    ]
}

Список партнёрских GET /api/library/{?partner_id}{?parent_id}

  • Parameters
  • partner_id (required, numeric, 1) ... id партнёра, контент которого доступен текущему партнёру
  • parent_id (optional, numeric, 1) ... id родительской категории
02
  • Response 200 (application/json)

{
    "total_count": 11,
    "result": [
        {
            "description": "description",
            "has_children": false,
            "is_active": true,
            "id": 20114,
            "name": "ttt",
            "level": 0,
            "url": "/client/categories/20114/",
            "priority": 0,
            "parent_id": null,
            "number_of_videos": 0,
            "thumbnail": ""
        }
    ]
}
Создание [POST]
03
  • Request (application/json)

{
    "description": "description",
    "has_children": false,
    "is_active": true,
    "name": "ttt",
    "url": "/client/categories/20115/",
    "parent_id": null,
    "thumbnail": ""
}
  • Response 201 (application/json)

{
    "description": "description",
    "has_children": false,
    "is_active": true,
    "id": 20115,
    "name": "ttt",
    "level": 0,
    "url": "/client/categories/20115/",
    "priority": 0,
    "parent_id": null,
    "number_of_videos": 0,
    "thumbnail": ""
}
Изменение PUT /api/library/{id}/
  • Parameters
  • id (required, numeric, 1) ... id категории
04
  • Request (application/json)

{
    "description": "desc2",
    "name": "cat2",
    "parent": 20103
}
  • Response 201 (application/json)

{
    "description": "desc2",
    "has_children": false,
    "is_active": true,
    "id": 20115,
    "name": "cat2",
    "level": 0,
    "url": "/client/categories/20115/",
    "priority": 0,
    "parent_id": null,
    "number_of_videos": 0,
    "thumbnail": ""
}
Удаление DELETE /api/library/{id}/
  • Parameters
  • id (required, numeric, 1) ... id категории
  • Response 204
05
Добавление видео POST /api/library/{id}/videos/
  • Parameters
  • id (required, numeric, 1) ... id категории
06
  • Response 201 (application/json)

{
    video_id:111
}

Список видео GET /api/library/{id}/videos/

  • Parameters
  • id (integer)
07
  • Response 200 (application/json)

{
    "total_count":3064,
    "result":[
        {
            "status":"published",
            "embed_html":"<iframe src='http://127.0.0.1:8000/video/5350456/?playerId=13&amp;partnerId=1'
                width='854'
                height='405'
                frameborder='no'
                scrolling='no'
                webkitAllowFullScreen 
                mozallowfullscreen 
                allowfullscreen></iframe>",
            "subtitle":null,
            "description":"\u043f\u043e\u043f-\u043c\u0443\u0437\u044b\u043a\u0430 La Vtornik!",
            "tags":[
                "\u043f\u043e\u043f-\u043c\u0443\u0437\u044b\u043a\u0430",
                "La Vtornik",
                "\u043f\u043e\u043f"
            ],
            "iframe_url":"http://127.0.0.1:8000/video/5350456/?playerId=13&partnerId=1",
            "show_ad":true,
            "embed_object":"<object class='TviglePlayer'>
                    <param name='id' value='5350456'>
                    <param name='adv_cat_id' value='6'>
                    <param name='partnerId' value='1'>
                    <param name='autoStart' value='true'>
                    <param name='forceFlashObject' value='true'>
                    <param name='wmode' value='opaque'>
                    <param name='playerId' value='13'>
                    <param name='width' value='854'>
                    <param name='height' value=''>
                    <param name='useAPI' value='true'>
                    <param name='autoChangeVideo' value='false'>
                    <!--<param name='api_sign' value='play_token=111&expire=222&key=333'>-->
                    <!--<param name='trace' value='true'>-->
                </object>
                <script language='JavaScript' 
                        type='text/javascript' 
                        data-hang='false' 
                        src='/static/player/player_builder.min.js'></script>",
            "is_active":true,
            "is_playable":true,
            "duration_in_ms":201762,
            "callback_url":null,
            "errors":[],
            "meta":{
                "country_restrictions":[]
            },
            "duration":"3:21",
            "publication_date":"2013-12-28 21:00:00",
            "is_banned":false,
            "freezeFrame":"//127.0.0.1:8000/res/2016/01/11/0f113cb6-ccb7-448d-83b0-32611fb2648f.png",
            "partner_id":1,
            "id":5350456,
            "category":27774,
            "rightholder":18799,
            "country_restrictions":[],
            "name":"\u0417\u0430\u0446\u0435\u043f\u0438\u043b\u0430",
            "publication_start_date":"",
            "age_restrictions":"12+",
            "created_at":"2016-01-11 18:18:20",
            "url":"/client/videos/5350456/",
            "publication_end_date":"",
            "aspect_ratio":null,
            "progress":100,
            "distribution":1,
            "status_display":"\u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d",
            "thumbnail":"//127.0.0.1:8000/res/2016/01/11/18da8e2d-3f87-4bf8-bcc6-c14e917b2738.jpg",
            "resources":[
                {
                    "status":"finished",
                    "errors":[],
                    "format":"flv",
                    "progress":100,
                    "quality":"1080p",
                    "id":9632266
                },
                {
                    "status":"finished",
                    "errors":[],
                    "format":"mp4",
                    "progress":100,
                    "quality":"480p",
                    "id":9632263
                }
            ],
            "tv_id":null
        }
    ]
}
Удаление видео DELETE /api/library/{category_id}/videos/{video_id}/
  • Parameters
  • category_id (integer)
  • video_id (integer)
  • Response 204
08
Работа с контентом | хранящимся на стороне клиента (self-hosted)

Добавление видео POST /api/videos/

  • Parameters
  • quality … качество видео, используются значения 240, 360, 480, 720, 1080
  • URL … адрес видео, начиная с httpS://
01
  • Request (application/json)

{
    "name":"…",
    "resources":[
        {
            "quality":"240p",
            "url":"https://dl.dropboxusercontent.com/u/589071/H264_test5_voice_mp4_480x360.mp4"
        },
        {
            "quality":"720p",
            "url":"https://dl.dropboxusercontent.com/u/589071/H264_test5_voice_mp4_480x360.mp4"
        }
    ]
}
  • Response

{
    "status": "queued",
    "embed_html": "<iframe src='http://127.0.0.1:8000/video/5236513/?partnerId=23'
        width='702'
        height='405'
        frameborder='no'
        scrolling='no'
        webkitAllowFullScreen 
        mozallowfullscreen 
        allowfullscreen></iframe>",
    "subtitle": null,
    "description": "",
    "tags": [],
    "iframe_url": "http://127.0.0.1:8000/video/5236513/?partnerId=23",
    "show_ad": true,
    "embed_object": "<object class='TviglePlayer'>
            <param name='id' value='5236513'>
            <param name='partnerId' value='23'>
            <param name='forceFlashObject' value='true'>
            <param name='width' value='702'>
            <param name='height' value='405'>
            <param name='useAPI' value='true'>
            <param name='autoChangeVideo' value='false'>
        </object>
        <script language='JavaScript' 
                type='text/javascript' 
                data-hang='false' 
                src='/static/player/player_builder.min.js'></script>",
    "is_active": true,
    "is_playable": false,
    "duration_in_ms": null,
    "callback_url": null,
    "errors": [],
    "duration": null,
    "publication_date": null,
    "is_banned": false,
    "freezeFrame": null,
    "partner_id": 23,
    "id": 5236513,
    "category": null,
    "rightholder": 24,
    "country_restrictions": [],
    "name": "megatest",
    "publication_start_date": "",
    "age_restrictions": "0+",
    "created_at": "2014-12-05 11:17:08",
    "url": "/client/videos/5236513/",
    "publication_end_date": "",
    "aspect_ratio": null,
    "progress": 0,
    "distribution": 1,
    "status_display": "в очереди",
    "thumbnail": null,
    "resources":
        [
            {
                "status": "queued",
                "errors": [],
                "format": null,
                "progress": 0,
                "quality": "640p",
                "id": 2913816
            },
            {
                "status": "queued",
                "errors": [],
                "format": null,
                "progress": 0,
                "quality": "240p",
                "id": 2913815
            }
        ],
    "tv_id": null
}

Добавление превью POST /api/videos/{id}/thumbnail/

02
RSS
Видео GET /api/rss/videos/{?partner_id}
Поля согласно спецификации RSS 2.0 с использованием atom:link
  • Parameters
  • partner_id (integer)
01
  • Response 200 (application/rss+xml; charset=utf-8)

<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
    <channel>
        <title>Videos for Partner</title>
        <link>http://127.0.0.1:8000</link>
        <description></description>
        <atom:link href="/api/rss/videos/" rel="self"></atom:link>
        <language>ru</language>
        <lastBuildDate>Wed, 13 Apr 2016 12:08:09 -0000</lastBuildDate>
        <item>
            <title>Название видео</title>
            <link>http://127.0.0.1:8000/client/videos/id/</link>
            <description>Описание видео</description>
            <pubDate>Wed, 13 Apr 2016 12:08:09 -0000</pubDate>
            <guid>id видео</guid>
            <category>Категория видео</category>
        </item>
    </channel>
</rss>
Методы отдачи видео

Публичный метод отдачи видео GET /api/public/video/{id}/{?partner_id}
  • Parameters
  • id (required, integer) ... id видео
  • partner_id (required, integer) ... id площадки, на которой проигрывается видео
01
  • Response 200 (application/json)

{
    "video":{
        "description":"Описание видео",
        "title":"Название видео",
        "age_restrictions":"18+",
        "id":1,
        "freeze_frame":"//example.com/freeze_frame.png",
        "thumbnail":"//example.com/thumbnail.png",
        "duration":2916002,
        "category_id":1,
        "is_geo_blocked":false,
        "resources":{
            "mp4":{
                "480p":{
                    "link":"//example.com/video_480.mp4",
                    "size":402070623
                },
                "360p":{
                    "link":"//example.com/video_360.mp4",
                    "size":284513502
                }
            },
            "flv":{
                "480p":{
                    "link":"//example.com/video_480.flv",
                    "size":402070623
                },
                "360p":{
                    "link":"//example.com/video_360.flv",
                    "size":284513502
                }
            }
        },
        "owner_id":1
    }
}