Skip to content

Commit

Permalink
Us the same field names as XBMC and add missing tag field to movies.
Browse files Browse the repository at this point in the history
  • Loading branch information
nomad2k committed Jul 8, 2014
1 parent 1abbdee commit 0ebbce8
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 68 deletions.
2 changes: 1 addition & 1 deletion include/xbmc.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ function updateXBMCTables(form, recordType, recordId) {
}

switch (f.name) {
case 'Moviegenres':
case 'genre':
continue; // We don't want to save genres here
break;
Expand All @@ -154,6 +153,7 @@ function updateXBMCTables(form, recordType, recordId) {
case 'studio':
case 'director':
case 'genre':
case 'tag':
case 'theme':
case 'mood':
case 'style':
Expand Down
31 changes: 18 additions & 13 deletions movies/include.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ function setWatched() {
var selectedMovie = movieGrid.getSelectionModel().getSelected();

if (selectedMovie !== undefined && selectedMovie.data.watched === 0) {
setXBMCWatched(selectedMovie.data.idMovie, 'movie', true);
setXBMCWatched(selectedMovie.data.movieid, 'movie', true);
selectedMovie.data.watched = 1;
movieGrid.getView().refresh();
}
Expand All @@ -14,7 +14,7 @@ function setUnwatched() {
var selectedMovie = movieGrid.getSelectionModel().getSelected();

if (selectedMovie !== undefined && selectedMovie.data.watched !== 0) {
setXBMCWatched(selectedMovie.data.idMovie, 'movie', false);
setXBMCWatched(selectedMovie.data.movieid, 'movie', false);
selectedMovie.data.watched = 0;
movieGrid.getView().refresh();
}
Expand All @@ -39,7 +39,7 @@ function updateXBMCSet(setField) {
jsonrpc: '2.0',
method: 'VideoLibrary.SetMovieDetails',
params: {
movieid: selectedMovie.data.idMovie,
movieid: selectedMovie.data.movieid,
set: newValue
},
id: 'XWMM'
Expand All @@ -51,7 +51,7 @@ function updateXBMCSet(setField) {

setField.IsDirty = false;
setField.originalValue = newValue;
selectedMovie.data.strSet = newValue;
selectedMovie.data.set = newValue;
movieGrid.getView().refresh();
}

Expand Down Expand Up @@ -82,7 +82,7 @@ function updateXBMCAll() {
form = Ext.getCmp('MoviedetailPanel').getForm();
if (form.isDirty()) {
updateXBMCTables(form, 'movie',
Ext.getCmp('Moviegrid').getSelectionModel().getSelected().data.idMovie);
Ext.getCmp('Moviegrid').getSelectionModel().getSelected().data.movieid);
mesg = 'updating movie info';
}

Expand All @@ -95,7 +95,7 @@ function updateXBMCAll() {
form = Ext.getCmp('filedetailPanel').getForm();
if (form.isDirty()) {
updateXBMCTables(form, 'movie',
Ext.getCmp('Moviegrid').getSelectionModel().getSelected().data.idMovie);
Ext.getCmp('Moviegrid').getSelectionModel().getSelected().data.movieid);
mesg = 'updating additional info';
}
}
Expand Down Expand Up @@ -167,12 +167,12 @@ function loadMovieDetails(record) {
jsonrpc: '2.0',
method: 'VideoLibrary.GetMovieDetails',
params: {
movieid: record.data.idMovie,
movieid: record.data.movieid,
properties: [
'title', 'genre', 'year', 'rating', 'director', 'trailer', 'tagline', 'plot',
'plotoutline', 'originaltitle', 'playcount', 'writer', 'studio', 'mpaa',
'country', 'imdbnumber', 'runtime', 'streamdetails', 'top250', 'votes', 'set',
'fanart', 'thumbnail', 'file', 'sorttitle'
'fanart', 'thumbnail', 'file', 'sorttitle', 'tag'
]
},
id: 'XWMM'
Expand All @@ -181,6 +181,12 @@ function loadMovieDetails(record) {
XWMM.util.merge2Objects(record.data, response.moviedetails);

//fix up some data retrieved
record.data.genre = XWMM.util.convertArrayToList(response.moviedetails.genre);
record.data.director = XWMM.util.convertArrayToList(response.moviedetails.director);
record.data.writer = XWMM.util.convertArrayToList(response.moviedetails.writer);
record.data.studio = XWMM.util.convertArrayToList(response.moviedetails.studio);
record.data.country = XWMM.util.convertArrayToList(response.moviedetails.country);
record.data.tag = XWMM.util.convertArrayToList(response.moviedetails.tag);
record.data.fanart = XWMM.util.convertArtworkURL(response.moviedetails.fanart);
record.data.thumbnail = XWMM.util.convertArtworkURL(response.moviedetails.thumbnail);
record.data.rating = XWMM.util.convertRating(response.moviedetails.rating);
Expand Down Expand Up @@ -220,7 +226,7 @@ function saveMovieGenre() {
jsonrpc: '2.0',
method: 'VideoLibrary.SetMovieDetails',
params: {
movieid: selectedMovie.data.idMovie,
movieid: selectedMovie.data.movieid,
genre: genres
},
id: 'XWMM'
Expand All @@ -236,7 +242,7 @@ function saveMovieGenre() {
function updateMovieGenreGrid(record) {
var genreGrid = Ext.getCmp('genresGrid');
var genreIds = [];
var genres = splitStringList(record.data.Moviegenres, /[,\/\|]+/); // Split list separated with , / or |.
var genres = splitStringList(record.data.genre, /[,\/\|]+/); // Split list separated with , / or |.

var index;
for (var i = 0, genreCount = genres.length; i < genreCount; i++) {
Expand Down Expand Up @@ -266,7 +272,6 @@ function checkSet(value) {

var movieColumnModel = new Ext.grid.ColumnModel([
{ header: 'Title', dataIndex: 'Movietitle', id: 'title' },
{ header: '&#160;', dataIndex: 'strSet', width: 30, renderer: checkSet, tooltip: 'In Set' },
{ header: '&#160;', dataIndex: 'watched', width: 26, renderer: checkWatched, tooltip: 'Watched' },
{ header: 'Genre', dataIndex: 'strGenre', hidden: true }
{ header: '&#160;', dataIndex: 'set', width: 30, renderer: checkSet, tooltip: 'In Set' },
{ header: '&#160;', dataIndex: 'watched', width: 26, renderer: checkWatched, tooltip: 'Watched' }
]);
12 changes: 8 additions & 4 deletions movies/movie.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ var otherDetailsPanel = new Ext.FormPanel({

xtype: 'combo',
fieldLabel: 'Set',
name: 'strSet',
name: 'title',
emptyText: '-- None --',
displayField: 'strSet',
displayField: 'title',
mode: 'local',
triggerAction: 'all',
listeners: {
Expand All @@ -122,6 +122,10 @@ var otherDetailsPanel = new Ext.FormPanel({
}
}
}
},
{
fieldLabel: 'Tags',
name: 'tag',
}
]
});
Expand Down Expand Up @@ -181,7 +185,7 @@ var movieDetailsPanel = new Ext.FormPanel({
},
{
fieldLabel: 'Genres',
name: 'Moviegenres',
name: 'genre',
id:'moviegenres',
readOnly: true
}
Expand Down Expand Up @@ -324,7 +328,7 @@ var mainPanel = new Ext.Panel({
updateMovieGenreGrid(record);
Ext.getCmp('filedetailPanel').getForm().loadRecord(record);

storeActor.proxy.conn.xbmcParams.params.movieid = record.data.idMovie;
storeActor.proxy.conn.xbmcParams.params.movieid = record.data.movieid;
storeActor.load();
}
});
17 changes: 4 additions & 13 deletions movies/moviegenre.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
function genreConvert(value, record) {
return value.join(' / ');
}

var MovieRecord = Ext.data.Record.create([
{ name: 'idMovie', mapping: 'movieid' },
{ name: 'strFilename', mapping: 'file' },
{ name: 'movieid' },
{ name: 'Movietitle', mapping: 'title' },
{ name: 'Moviegenres', mapping: 'genre', convert: genreConvert },
{ name: 'strGenre' },
{ name: 'watched', mapping: 'playcount' },
{ name: 'MovieRelease', mapping: 'year' },
{ name: 'streamdetails' },
{ name: 'strSet', mapping: 'set' }
{ name: 'set' },
{ name: 'year' }
]);

var sortArticles = docCookies.getItem('sortArticles') === '1';
Expand All @@ -25,8 +17,7 @@ var storeMovie = new Ext.data.Store({
method: 'VideoLibrary.GetMovies',
params: {
properties: [
'title', 'genre', 'year', 'playcount',
'file', 'set', 'streamdetails'
'title', 'year', 'playcount', 'set'
],
sort: {
order: 'ascending',
Expand Down
16 changes: 4 additions & 12 deletions movies/movielist.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
function genreConvert(value, record) {
return value.join(' / ');
}

var MovieRecord = Ext.data.Record.create([
{ name: 'idMovie', mapping: 'movieid' },
{ name: 'strFilename', mapping: 'file' },
{ name: 'movieid' },
{ name: 'Movietitle', mapping: 'title' },
{ name: 'Moviegenres', mapping: 'genre', convert: genreConvert },
{ name: 'watched', mapping: 'playcount' },
{ name: 'MovieRelease', mapping: 'year' },
{ name: 'streamdetails' },
{ name: 'strSet', mapping: 'set' }
{ name: 'set' },
{ name: 'year' }
]);

var sortArticles = docCookies.getItem('sortArticles') === '1';
Expand All @@ -23,8 +16,7 @@ var storeMovie = new Ext.data.Store({
method: 'VideoLibrary.GetMovies',
params: {
properties: [
'title', 'genre', 'year', 'playcount',
'file', 'set', 'streamdetails'
'title', 'year', 'playcount', 'set'
],
sort: {
order: 'ascending',
Expand Down
16 changes: 4 additions & 12 deletions movies/movierecent.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
function genreConvert(value, record) {
return value.join(' / ');
}

var MovieRecord = Ext.data.Record.create([
{ name: 'idMovie', mapping: 'movieid' },
{ name: 'strFilename', mapping: 'file' },
{ name: 'movieid' },
{ name: 'Movietitle', mapping: 'title' },
{ name: 'Moviegenres', mapping: 'genre', convert: genreConvert },
{ name: 'watched', mapping: 'playcount' },
{ name: 'MovieRelease', mapping: 'year' },
{ name: 'streamdetails' },
{ name: 'strSet', mapping: 'set' }
{ name: 'set' },
{ name: 'year' }
]);

var sortArticles = docCookies.getItem('sortArticles') === '1';
Expand All @@ -23,8 +16,7 @@ var storeMovie = new Ext.data.Store({
method: 'VideoLibrary.GetMovies',
params: {
properties: [
'title', 'genre', 'year', 'playcount',
'file', 'set', 'streamdetails'
'title', 'year', 'playcount', 'set'
],
sort: {
order: 'descending',
Expand Down
26 changes: 13 additions & 13 deletions movies/movieset.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//------------ Movie All Sets (including orphans) ----------------

var MovieSetRecord = Ext.data.Record.create([
{name: 'idSet', mapping: 'setid', type: 'int'},
{name: 'strSet', mapping: 'title'}
{name: 'setid', type: 'int'},
{name: 'title'}
]);

var MovieSetStore = new Ext.data.GroupingStore({
sortInfo: {field: 'strSet', direction: 'ASC'},
sortInfo: {field: 'title', direction: 'ASC'},
//autoLoad: true,
proxy: new Ext.data.XBMCProxy({
url: '/jsonrpc',
Expand All @@ -18,13 +18,13 @@ var MovieSetStore = new Ext.data.GroupingStore({
});

var MoviesInSetcolModel = new Ext.grid.ColumnModel([
{header: '#', dataIndex: 'idMovie', hidden: true},
{header: '#', dataIndex: 'movieid', hidden: true},
{header: 'Movie Title', dataIndex: 'movieinset', width: 200}
]);


var MoviesInSetRecord = Ext.data.Record.create([
{name: 'idMovie', mapping: 'movieid'},
{name: 'movieid'},
{name: 'movieinset', mapping: 'title'}
]);

Expand Down Expand Up @@ -57,8 +57,8 @@ var MovieInSetGrid = new Ext.grid.GridPanel({

function onAddMovieSet(btn, ev) {
var u = new MovieSetMgmtGrid.store.recordType({
strSet: 'New Set',
idSet: '-1' // flag as new record
title: 'New Set',
setid: '-1' // flag as new record
});
editor.stopEditing();
MovieSetStore.insert(0, u);
Expand All @@ -73,7 +73,7 @@ function onDeleteMovieSet() {
MovieSetStore.remove(rec);
MoviesInSetStore.each( function (movieRecord)
{
xbmcJsonRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.SetMovieDetails", "params": {"movieid": '+ movieRecord.data.idMovie +', "set": ""}, "id": 1}');
xbmcJsonRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.SetMovieDetails", "params": {"movieid": '+ movieRecord.data.movieid +', "set": ""}, "id": 1}');
}, this);
MovieSetStore.reload();
}
Expand All @@ -82,13 +82,13 @@ var MovieSetEditor = new Ext.ux.grid.RowEditor({
saveText: 'Update',
listeners: {
afteredit: function(roweditor, changes, record, rowIndex) {
if (record.data.idSet === -1) {
if (record.data.setid === -1) {
//should add a bubble to tell user to add movies in the set
}
else {
MoviesInSetStore.each( function (movieRecord)
{
xbmcJsonRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.SetMovieDetails", "params": {"movieid": '+ movieRecord.data.idMovie +', "set": "'+ changes.strSet +'"}, "id": 1}');
xbmcJsonRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.SetMovieDetails", "params": {"movieid": '+ movieRecord.data.movieid +', "set": "'+ changes.title +'"}, "id": 1}');
}, this);
MovieSetStore.reload();
}
Expand All @@ -101,8 +101,8 @@ var MovieSetMgmtGrid = new Ext.grid.GridPanel({
width: 250,
height: 290,
columns: [
{header: '#', dataIndex: 'idSet', hidden: true},
{header: 'Set Name', width: 200, editor: new Ext.form.TextField({allowBlank: false}),dataIndex: 'strSet'}
{header: '#', dataIndex: 'setid', hidden: true},
{header: 'Set Name', width: 200, editor: new Ext.form.TextField({allowBlank: false}),dataIndex: 'title'}
],
clicksToEdit: 1,
title: 'Sets',
Expand All @@ -112,7 +112,7 @@ var MovieSetMgmtGrid = new Ext.grid.GridPanel({
singleSelect: true,
listeners : {
rowselect: function(sm, row, rec) {
MoviesInSetStore.proxy.conn.xbmcParams = {'jsonrpc': '2.0', 'method': 'VideoLibrary.GetMovieSetDetails', 'params': {'setid': rec.data.idSet, 'movies': {'properties': ['title']} }, 'id': 1};
MoviesInSetStore.proxy.conn.xbmcParams = {'jsonrpc': '2.0', 'method': 'VideoLibrary.GetMovieSetDetails', 'params': {'setid': rec.data.setid, 'movies': {'properties': ['title']} }, 'id': 1};
MoviesInSetStore.load();
}
}
Expand Down

0 comments on commit 0ebbce8

Please sign in to comment.