Skip to content

Commit

Permalink
🏥📺 Updated with Glitch
Browse files Browse the repository at this point in the history
  • Loading branch information
System committed May 9, 2017
1 parent c74ee0b commit 850037a
Show file tree
Hide file tree
Showing 10 changed files with 458 additions and 38 deletions.
37 changes: 0 additions & 37 deletions .gitignore

This file was deleted.

6 changes: 6 additions & 0 deletions .glitch-assets
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{"name":"drag-in-files.svg","date":"2016-10-22T16:17:49.954Z","url":"https://cdn.hyperdev.com/drag-in-files.svg","type":"image/svg","size":7646,"imageWidth":276,"imageHeight":276,"thumbnail":"https://cdn.hyperdev.com/drag-in-files.svg","thumbnailWidth":276,"thumbnailHeight":276,"dominantColor":"rgb(102, 153, 205)","uuid":"adSBq97hhhpFNUna"}
{"name":"click-me.svg","date":"2016-10-23T16:17:49.954Z","url":"https://cdn.hyperdev.com/click-me.svg","type":"image/svg","size":7116,"imageWidth":276,"imageHeight":276,"thumbnail":"https://cdn.hyperdev.com/click-me.svg","thumbnailWidth":276,"thumbnailHeight":276,"dominantColor":"rgb(243, 185, 186)","uuid":"adSBq97hhhpFNUnb"}
{"name":"paste-me.svg","date":"2016-10-24T16:17:49.954Z","url":"https://cdn.hyperdev.com/paste-me.svg","type":"image/svg","size":7242,"imageWidth":276,"imageHeight":276,"thumbnail":"https://cdn.hyperdev.com/paste-me.svg","thumbnailWidth":276,"thumbnailHeight":276,"dominantColor":"rgb(42, 179, 185)","uuid":"adSBq97hhhpFNUnc"}
{"uuid":"adSBq97hhhpFNUna","deleted":true}
{"uuid":"adSBq97hhhpFNUnb","deleted":true}
{"uuid":"adSBq97hhhpFNUnc","deleted":true}
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,27 @@
# GoogleHomeKodi
Welcome to the Glitch BETA
=========================

Click `Show` in the header to see your app live. Updates to your code will instantly deploy and update live.

Glitch is a developer playground that lets you code a real web-app without the slow setup and deployment steps.

[About Glitch](https://glitch.com/about)


Your Project
------------

On the back-end,
- your app starts at `server.js`
- add frameworks and packages in `package.json`
- safely store app secrets in `.env`

On the front-end,
- edit `public/client.js`, `public/style.css` and `views/index.html`
- drag in `assets`, like images or music, to add them to your project


Made by Fog Creek
-----------------

\ ゜o゜)ノ
50 changes: 50 additions & 0 deletions kodi-connection/api-methods.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
module.exports = [
{
name: 'Addons',
methods: ['ExecuteAddon', 'GetAddonDetails', 'GetAddons', 'SetAddonEnabled']
},
{
name: 'Application',
methods: ['GetProperties', 'Quit', 'SetMute', 'SetVolume']
},
{
name: 'AudioLibrary',
methods: ['Clean', 'Export', 'GetAlbumDetails', 'GetAlbums', 'GetArtistDetails', 'GetArtists', 'GetGenres', 'GetRecentlyAddedAlbums', 'GetRecentlyAddedSongs', 'GetRecentlyPlayedAlbums', 'GetRecentlyPlayedSongs', 'GetSongDetails', 'GetSongs', 'Scan', 'SetAlbumDetails', 'SetArtistDetails', 'SetSongDetails']
},
{
name: 'Files',
methods: ['Download', 'GetDirectory', 'GetFileDetails', 'GetSources', 'PrepareDownload']
},
{
name: 'GUI',
methods: ['ActivateWindow', 'GetProperties', 'SetFullscreen', 'ShowNotification']
},
{
name: 'Input',
methods: ['Back', 'ContextMenu', 'Down', 'ExecuteAction', 'Home', 'Info', 'Left', 'Right', 'Select', 'SendText', 'ShowCodec', 'ShowOSD', 'Up']
},
{
name: 'JSONRPC',
methods: ['GetConfiguration', 'Introspect', 'NotifyAll', 'Permission', 'Ping', 'SetConfiguration', 'Version']
},
{
name: 'PVR',
methods: ['GetChannelDetails', 'GetChannelGroupDetails', 'GetChannelGroups', 'GetChannels', 'GetProperties', 'Record', 'Scan']
},
{
name: 'Player',
methods: ['GetActivePlayers', 'GetItem', 'GetProperties', 'GoTo', 'Move', 'Open', 'PlayPause', 'Rotate', 'Seek', 'SetAudioStream', 'SetPartymode', 'SetRepeat', 'SetShuffle', 'SetSpeed', 'SetSubtitle', 'Stop', 'Zoom', 't', 't.Add', 't.Clear', 't.GetItems', 't.GetPlaylists', 't.GetProperties', 't.Insert', 't.Remove', 't.Swap']
},
{
name: 'System',
methods: ['EjectOpticalDrive', 'GetProperties', 'Hibernate', 'Reboot', 'Shutdown', 'Suspend']
},
{
name: 'VideoLibrary',
methods: ['Clean', 'Export', 'GetEpisodeDetails', 'GetEpisodes', 'GetGenres', 'GetMovieDetails', 'GetMovieSetDetails', 'GetMovieSets', 'GetMovies', 'GetMusicVideoDetails', 'GetMusicVideos', 'GetRecentlyAddedEpisodes', 'GetRecentlyAddedMovies', 'GetRecentlyAddedMusicVideos', 'GetSeasons', 'GetTVShowDetails', 'GetTVShows', 'RemoveEpisode', 'RemoveMovie', 'RemoveMusicVideo', 'RemoveTVShow', 'Scan', 'SetEpisodeDetails', 'SetMovieDetails', 'SetMusicVideoDetails', 'SetTVShowDetails']
},
{
name: 'XBMC',
methods: ['GetInfoBooleans', 'GetInfoLabels']
}
];
57 changes: 57 additions & 0 deletions kodi-connection/api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
module.exports = function(fetch) {
var namespaces = require('./api-methods.js');
var kodi_auth;

function addMethods(obj) {
namespaces.forEach(function(namespace) {
obj[namespace.name] = namespace.methods.reduce(function(result, method) {
result[method] = function(params, callback) {
return obj.send(namespace.name + '.' + method, params, callback);
};
return result;
}, {});
});
}

function Kodi(ip, port, username, password) {
kodi_auth = 'Basic ' + new Buffer(username + ':' + password).toString('base64');
this.url = 'http://' + ip + ':' + port + '/jsonrpc';
addMethods(this);
}

Kodi.prototype.sendHTTP = function(body, callback) {
console.log('Command sent = ' + body);
var headers = {
"Content-type": "application/json",
'Accept': "application/json",
'Authorization': kodi_auth
};

return fetch(this.url, {
method: 'POST',
body: body,
headers: headers
})
.then(function (response) {
return response.json();
})
.then(function(data) {
if(callback) callback(data);
return data;
});
};

Kodi.prototype.send = function(method, params, callback) {
var body = {
jsonrpc: "2.0",
id: 1,
method: method
};

if(params) body.params = params;
body = JSON.stringify(body);
return this.sendHTTP(body, callback);
};

return Kodi;
};
2 changes: 2 additions & 0 deletions kodi-connection/node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module.exports = require('./api.js')(require('node-fetch'));
module.exports = require('./api.js')(require('node-fetch'));
39 changes: 39 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"//1": "describes your app and its dependencies",
"//2": "https://docs.npmjs.com/files/package.json",
"//3": "updating this file will download and update your packages",

"name": "my-glitch-app",
"version": "0.0.1",
"description": "What am I about?",
"main": "server.js",
"scripts": {
"start": "node server.js"
},
"dependencies": {
"express": "^4.15.2",
"has-value": "^0.2.0",
"jrpc-schema": "^2.1.0",
"set-value": "^0.2.0",
"node-fetch": "^1.3.2",
"whatwg-fetch": "^0.9.0",
"dotenv": "^4.0.0",
"fuse.js": "^2.0.1"
},
"devDependencies": {
"eslint": "^1.9.0",
"babel-eslint": "^5.0.0-beta8"
},
"engines": {
"node": "6.10.x"
},
"repository": {
"url": "https://glitch.com/edit/#!/welcome-project"
},
"license": "MIT",
"keywords": [
"node",
"glitch",
"express"
]
}
82 changes: 82 additions & 0 deletions public/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/* styles */
/* called by your view template */

/* You might want to try something fancier: */
/* less: http://lesscss.org/ */

* {
box-sizing: border-box;
}

body {
font-family: helvetica, arial, sans-serif;
margin: 25px;
}

h1 {
font-weight: bold;
color: pink;
}

.bold {
font-weight: bold;
}

p {
max-width: 600px;
}

form {
margin-bottom: 25px;
padding: 15px;
background-color: cyan;
display: inline-block;
width: 100%;
max-width: 340px;
border-radius: 3px;
}

input {
display: block;
margin-bottom: 10px;
padding: 5px;
width: 100%;
border: 1px solid lightgrey;
border-radius: 3px;
font-size: 16px;
}

button {
font-size: 16px;
border-radius: 3px;
background-color: lightgrey;
border: 1px solid grey;
box-shadow: 2px 2px teal;
cursor: pointer;
}

button:hover {
background-color: yellow;
}

button:active {
box-shadow: none;
}

li {
margin-bottom: 5px;
}

footer {
margin-top: 50px;
padding-top: 25px;
border-top: 1px solid lightgrey;
}

footer > a {
color: #BBBBBB;
}

.nicejob {
text-decoration: line-through;
}
Loading

0 comments on commit 850037a

Please sign in to comment.