Skip to content

Commit

Permalink
Dev (#120)
Browse files Browse the repository at this point in the history
* Add initial support for jellyfin clients

* Add additional movie information to database

* Add more routing stubs

* Add endpoints for movie artwork

* More jellyfin api stubs

* Jellyfin websocket emulation

* hwaccel_output_format should be an input option

* Simplify episode indexing and identification

* Add new FTPS driver for importing media

* More importing stuff

* Add new config option for import concurrency

* Initial fixes for jellyfin emulation

* More jellyfin emulation work

* Working playback in jellyfin client

* More jellyfin stuff
  • Loading branch information
robinp7720 committed Nov 2, 2023
1 parent 2a61242 commit 9b698d3
Show file tree
Hide file tree
Showing 27 changed files with 1,481 additions and 43 deletions.
14 changes: 14 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"dependencies": {
"async": "^3.2.0",
"axios": "^0.21.1",
"basic-ftp": "^5.0.3",
"bcrypt": "^5.0.1",
"fastest-levenshtein": "^1.0.12",
"fluent-ffmpeg": "^2.1.2",
Expand All @@ -43,6 +44,8 @@
"neo-blessed": "^0.2.0",
"node-rsa": "^1.1.1",
"node-tvdb": "^4.1.0",
"node-uuid": "^1.4.8",
"primus": "^7.3.5",
"recursive-readdir": "^2.2.2",
"restify": "^9.0.0-rc.3",
"restify-cors-middleware2": "^2.2.0",
Expand Down
3 changes: 3 additions & 0 deletions res/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@
}
}
},
"seedboxImport": {
"concurrency": 1
},
"seedboxes": [
{
"name": "Main seedbox",
Expand Down
65 changes: 65 additions & 0 deletions src/lib/embyEmulation/ServerAPI/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import restify from 'restify';
import routes from './routes';
import corsMiddleware from 'restify-cors-middleware2';

export default class EmbyServerAPI {
/**
* @param {EmbyEmulation} embyEmulation
*/
constructor(embyEmulation) {
this.embyEmulation = embyEmulation;

// Initialize REST based server
this.server = restify.createServer();

// Allow remote clients to connect to the backend
const cors = corsMiddleware({
preflightMaxAge: 5, // Optional
origins: ['*'],
allowHeaders: ['API-Token'],
exposeHeaders: ['API-Token-Expiry']
});

this.server.pre(cors.preflight);
this.server.use(cors.actual);

this.server.use(restify.plugins.authorizationParser());
this.server.use(restify.plugins.queryParser({ mapParams: true }));
this.server.use(restify.plugins.bodyParser({ mapParams: true }));

this.server.pre(function(req, res, next) {
req.url = req.url.toLowerCase();
next();
});

this.server.pre(function(req, res, next) {
if (!req.headers['x-emby-authorization']) return next();

req.headers['emby'] = req.headers['x-emby-authorization'].split(', ');

let auth = {};

for (let i in req.headers['emby']) {
let item = req.headers['emby'][i].split('=');

auth[item[0]] = item[1].replace(/"/g, '');
}

req.headers['emby'] = auth;

next();
});

this.server.use(async function (request, response) {
console.log(request.url, request.params, request.method);
});

// Add routes routes
routes(this.server, this.embyEmulation);

// Start restify server
this.server.listen(8096, () => {
console.log('Jellyfin emulation server listening at %s', this.server.url);
});
}
}
12 changes: 12 additions & 0 deletions src/lib/embyEmulation/ServerAPI/routes/branding/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export default (server, embyEmulation) => {
server.get('/branding/configuration', async (req, res) => {
res.send({
LoginDisclaimer: 'This is an Oblecto Media server',
CustomCss: ''
});
});

server.get('/branding/css', async (req, res) => {
res.send();
});
};
32 changes: 32 additions & 0 deletions src/lib/embyEmulation/ServerAPI/routes/displaypreferences/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* @param {*} server
* @param {EmbyEmulation} embyEmulation
*/
export default (server, embyEmulation) => {
server.get('/displaypreferences/usersettings', async (req, res) => {
res.send(
{
'Id':'3ce5b65d-e116-d731-65d1-efc4a30ec35c',
'SortBy':'SortName',
'RememberIndexing':false,
'PrimaryImageHeight':250,
'PrimaryImageWidth':250,
'CustomPrefs':{
'chromecastVersion':'stable','skipForwardLength':'30000','skipBackLength':'10000','enableNextVideoInfoOverlay':'False','tvhome':null,'dashboardTheme':null,'http://192.168.176.55:30013/web/index.htmlmoviecollections':'{\u0022SortBy\u0022:\u0022SortName\u0022,\u0022SortOrder\u0022:\u0022Ascending\u0022}','http://192.168.176.55:30013/web/index.htmlseries':'{\u0022SortBy\u0022:\u0022SortName\u0022,\u0022SortOrder\u0022:\u0022Ascending\u0022}','file:///app/share/jellyfinmediaplayer/web-client/desktop/index.htmltrailers':'{\u0022SortBy\u0022:\u0022SortName\u0022,\u0022SortOrder\u0022:\u0022Ascending\u0022}','file:///app/share/jellyfinmediaplayer/web-client/desktop/index.htmlseries':'{\u0022SortBy\u0022:\u0022SortName\u0022,\u0022SortOrder\u0022:\u0022Ascending\u0022}'
},
'ScrollDirection':'Horizontal',
'ShowBackdrop':true,
'RememberSorting':false,
'SortOrder':'Ascending',
'ShowSidebar':false,
'Client':'emby'
});
});

server.get('/LiveTv/Programs/Recommended', async (req, res) => {
res.send(
{
'Items':[],'TotalRecordCount':0,'StartIndex':0
});
});
};
24 changes: 24 additions & 0 deletions src/lib/embyEmulation/ServerAPI/routes/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import system from './system';
import users from './users';
import sessions from './sessions';
import displaypreferences from './displaypreferences';
import branding from './branding';
import shows from './shows';
import items from './items';
import videos from './videos';

/**
*
* @param server
* @param {EmbyEmulation} embyEmulation
*/
export default (server, embyEmulation) => {
system(server, embyEmulation);
users(server, embyEmulation);
sessions(server, embyEmulation);
displaypreferences(server, embyEmulation);
branding(server, embyEmulation);
shows(server, embyEmulation);
items(server, embyEmulation);
videos(server, embyEmulation);
};

0 comments on commit 9b698d3

Please sign in to comment.