Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [10.x, 12.x, 14.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build --if-present
- run: npm test
3,897 changes: 3,897 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "oblectoclient",
"version": "0.0.1",
"version": "0.0.4",
"description": "Oblecto Server javascript client library",
"main": "dist/index.js",
"scripts": {
"build": "./node_modules/@babel/cli/bin/babel.js src -d dist",
"test": "./node_modules/mocha/bin/mocha tests/**/*.js --reporter spec"
"test": "./node_modules/mocha/bin/mocha tests/**/*.js --reporter spec",
"prepare": "npm run build"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -34,5 +35,8 @@
},
"dependencies": {
"axios": "^0.19.2"
}
},
"files": [
"dist/"
]
}
6 changes: 6 additions & 0 deletions src/OblectoLibraryClients/MovieLibraryClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,10 @@ export default class MovieLibraryClient {

return response.data;
}

async getWatching() {
let response = await this.oblectoSession.axios.get(`/movies/watching`);

return response.data;
}
}
11 changes: 11 additions & 0 deletions src/OblectoRemotes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export default class OblectoRemotes {
constructor(oblectoSession) {
this.oblectoSession = oblectoSession;
}

async getClients() {
let response = await this.oblectoSession.axios.get(`/clients`);

return response.data;
}
}
12 changes: 12 additions & 0 deletions src/OblectoSession.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ import MovieLibraryClient from './OblectoLibraryClients/MovieLibraryClient';
import SeriesLibraryClient from './OblectoLibraryClients/SeriesLibraryClient';
import EpisodeLibraryClient from './OblectoLibraryClients/EpisodeLibraryClient';
import UserManager from './UserManager';
import OblectoStreamSession from './OblectoStreamSession';
import OblectoRemotes from './OblectoRemotes';

export default class OblectoSession {
constructor(host) {
this.host = host;

this.axios = axios.create({
baseURL: host,
timeout: 1000
Expand All @@ -15,6 +19,7 @@ export default class OblectoSession {
this.seriesLibrary = new SeriesLibraryClient(this);
this.episodeLibrary = new EpisodeLibraryClient(this);
this.userManager = new UserManager(this);
this.remotes = new OblectoRemotes(this);
}

async getSessionToken(username, password) {
Expand All @@ -33,4 +38,11 @@ export default class OblectoSession {

this.axios.defaults.headers.common = {'Authorization': `bearer ${this.accessToken}`};
}

async createStreamSession(fileId) {
let session = new OblectoStreamSession(fileId, this);
await session.initSession();

return session;
}
}
20 changes: 20 additions & 0 deletions src/OblectoStreamSession.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export default class OblectoStreamSession {
constructor(fileId, oblecto) {
this.oblecto = oblecto;
this.fileId = fileId;
}

async initSession() {
let {data: {sessionId, seeking}} = await this.oblecto.axios.get(`/session/create/${this.fileId}`);

this.sessionId = sessionId;
this.severSideSeeking = (seeking === 'server');
}

getUrl(offset) {
if (offset)
return `${this.host}/session/stream/${this.sessionId}?offset=${offset}`
return `${this.oblecto.host}/session/stream/${this.sessionId}`
}

}
36 changes: 34 additions & 2 deletions tests/oblectoSession.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ let expect = require('expect.js');
let OblectoSession = require('../dist/OblectoSession').default;

let username = 'robin';
let password = 'robin';
let password = 'R197PT2T';

let host = 'http://localhost:8080';
let host = 'http://oblecto';

describe('Oblecto Session', function () {
describe('authenticate', async function () {
Expand Down Expand Up @@ -63,6 +63,18 @@ describe('Oblecto Session', function () {
expect(response).to.be.an('array');
});
});

it('Movie watching', async function () {
const oblectoSession = new OblectoSession(host);
await oblectoSession.authenticate(username, password);

let response = await oblectoSession.movieLibrary.getWatching();

console.log(response);

expect(response).to.be.an('array');

});
});

describe('Series Library', async function () {
Expand Down Expand Up @@ -176,4 +188,24 @@ describe('Oblecto Session', function () {
});
});

describe('Playback session', async function () {
it('Session Create', async function () {
const oblectoSession = new OblectoSession(host);
await oblectoSession.authenticate(username, password);

let streamSession = await oblectoSession.createStreamSession(2);

console.log(streamSession.getUrl());
});
});

describe('Remotes', async function () {
it('List clients', async function () {
const oblectoSession = new OblectoSession(host);
await oblectoSession.authenticate(username, password);

console.log(await oblectoSession.remotes.getClients());
});
});

});