Skip to content

Commit e94d854

Browse files
committed
Merge branch 'facundo91-master'
2 parents 3b104c3 + d74a54a commit e94d854

File tree

18 files changed

+178
-112
lines changed

18 files changed

+178
-112
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Want to report a bug, request a feature, contribute to or translate Butter? Chec
1818

1919
If you're comfortable getting up and running from a `git clone`, this method is for you.
2020

21-
After you clone the GitHub repository, you will need to build a number of assets using grunt.
21+
After you clone the GitHub repository, you will need to build a number of assets using gulp.
2222

2323
The [master](https://github.com/butterproject/butter-desktop) branch which contains the latest release.
2424

@@ -41,7 +41,7 @@ Keep track of Butter development and community activity.
4141
* Join in discussions on the [Butter Forum](https://www.reddit.com/r/ButterProject)
4242
* Connect with us on IRC at `#butterproject` on freenode ([web access](http://webchat.freenode.net/?channels=butterproject))
4343

44-
##Screenshots
44+
## Screenshots
4545
![Butter](https://cloud.githubusercontent.com/assets/8317250/10714437/b1e1dc8c-7b32-11e5-9c25-d9fbd5b2f3bd.png)
4646
![Debugging Butter](https://cloud.githubusercontent.com/assets/8317250/10714430/add70234-7b32-11e5-9be7-1de539d865ba.png)
4747

gulpfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const parsePlatforms = () => {
6262
// returns an array of paths with the node_modules to include in builds
6363
const parseReqDeps = () => {
6464
return new Promise((resolve, reject) => {
65-
exec('npm ls --production=true --parseable=true', (error, stdout, stderr) => {
65+
exec('npm ls --production=true --parseable=true', {maxBuffer: 1024 * 500}, (error, stdout, stderr) => {
6666
if (error || stderr) {
6767
reject(error || stderr);
6868
} else {

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
},
3636
"chromium-args": "--enable-node-worker",
3737
"dependencies": {
38-
"butter-provider": "git+https://github.com/butterproviders/butter-provider",
38+
"butter-provider": "0.6.0",
3939
"butter-provider-ccc": "git+https://github.com/butterproviders/butter-provider-ccc",
4040
"butter-provider-youtube": "git+https://github.com/butterproviders/butter-provider-youtube",
4141
"butter-provider-vodo": "git+https://github.com/butterproviders/butter-provider-vodo",
@@ -45,7 +45,7 @@
4545
"async": "2.x.x",
4646
"bonjour": "^3.5.0",
4747
"chromecasts": "1.9.0",
48-
"defer-request": "0.0.2",
48+
"defer-request": "0.0.3",
4949
"dlnacasts": "0.1.0",
5050
"i18n": "0.x.x",
5151
"iconv-lite": "0.x.x",
@@ -67,15 +67,15 @@
6767
"rimraf": "2.x.x",
6868
"sanitizer": "0.x.x",
6969
"semver": "5.x.x",
70-
"send": "0.14.1",
70+
"send": "0.14.2",
7171
"strike-api": "0.2.0",
7272
"tar": "2.2.1",
7373
"temp": "0.x.x",
7474
"webtorrent-health": "1.x.x",
75-
"trakt.tv": "2.x.x",
76-
"trakt.tv-ondeck": "0.x.x",
77-
"trakt.tv-matcher": "1.x.x",
78-
"trakt.tv-images": "1.x.x",
75+
"trakt.tv": "5.0.1",
76+
"trakt.tv-ondeck": "5.0.1",
77+
"trakt.tv-matcher": "5.0.0",
78+
"trakt.tv-images": "5.0.0",
7979
"underscore": "1.x.x",
8080
"urijs": "1.x.x",
8181
"webtorrent": "^0.98.0"

src/app/app.js

Lines changed: 65 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ App.addInitializer(function (options) {
100100

101101
var width = parseInt(localStorage.width ? localStorage.width : Settings.defaultWidth);
102102
var height = parseInt(localStorage.height ? localStorage.height : Settings.defaultHeight);
103+
var isMaximized = Boolean(parseInt(localStorage.isMaximized));
103104
var x = parseInt(localStorage.posX ? localStorage.posX : -1);
104105
var y = parseInt(localStorage.posY ? localStorage.posY : -1);
105106

@@ -128,8 +129,13 @@ App.addInitializer(function (options) {
128129
}
129130

130131
win.zoomLevel = zoom;
131-
win.resizeTo(width, height);
132-
win.moveTo(x, y);
132+
133+
if (isMaximized) {
134+
win.maximize();
135+
} else {
136+
win.resizeTo(width, height);
137+
win.moveTo(x, y);
138+
}
133139
});
134140

135141
var initTemplates = function () {
@@ -152,7 +158,9 @@ var initApp = function () {
152158
var mainWindow = new App.View.MainWindow();
153159

154160
// -m argument to open minimized to tray
155-
if (nw.App.fullArgv.indexOf('-m') === -1) {
161+
var isStartMinimized = nw.App.fullArgv.indexOf('-m') !== -1;
162+
163+
if (!isStartMinimized) {
156164
win.show();
157165
}
158166

@@ -213,35 +221,6 @@ var delCache = function () {
213221
win.close(true);
214222
};
215223

216-
win.on('resize', function (width, height) {
217-
localStorage.width = Math.round(width);
218-
localStorage.height = Math.round(height);
219-
});
220-
221-
win.on('move', function (x, y) {
222-
localStorage.posX = Math.round(x);
223-
localStorage.posY = Math.round(y);
224-
});
225-
226-
win.on('enter-fullscreen', function () {
227-
App.vent.trigger('window:focus');
228-
});
229-
230-
// Wipe the tmpFolder when closing the app (this frees up disk space)
231-
win.on('close', function () {
232-
if (App.settings.deleteTmpOnClose) {
233-
deleteFolder(App.settings.tmpLocation);
234-
}
235-
if (fs.existsSync(path.join(data_path, 'logs.txt'))) {
236-
fs.unlinkSync(path.join(data_path, 'logs.txt'));
237-
}
238-
try {
239-
delCache();
240-
} catch (e) {
241-
win.close(true);
242-
}
243-
});
244-
245224
String.prototype.capitalize = function () {
246225
return this.charAt(0).toUpperCase() + this.slice(1);
247226
};
@@ -656,6 +635,60 @@ if (nw.App.fullArgv.indexOf('-f') !== -1) {
656635
win.enterFullscreen();
657636
}
658637

638+
// nwjs window events
639+
win.on('focus', function () { //hack to make it somehow work
640+
win.setAlwaysOnTop(true);
641+
win.setAlwaysOnTop(Settings.alwaysOnTop);
642+
});
643+
644+
win.on('resize', function (width, height) {
645+
localStorage.width = Math.round(width);
646+
localStorage.height = Math.round(height);
647+
});
648+
649+
win.on('move', function (x, y) {
650+
localStorage.posX = Math.round(x);
651+
localStorage.posY = Math.round(y);
652+
});
653+
654+
win.on('enter-fullscreen', function () {
655+
win.focus();
656+
});
657+
658+
win.on('minimize', function () {
659+
if (Settings.minimizeToTray) {
660+
minimizeToTray();
661+
}
662+
});
663+
664+
win.on('maximize', function () {
665+
localStorage.isMaximized = 1;
666+
$('.os-max').addClass('os-is-max');
667+
});
668+
669+
win.on('restore', function () {
670+
if (Boolean(parseInt(localStorage.isMaximized))) {
671+
localStorage.isMaximized = 0;
672+
}
673+
674+
$('.os-max').removeClass('os-is-max');
675+
});
676+
677+
// Wipe the tmpFolder when closing the app (this frees up disk space)
678+
win.on('close', function () {
679+
if (App.settings.deleteTmpOnClose) {
680+
deleteFolder(App.settings.tmpLocation);
681+
}
682+
if (fs.existsSync(path.join(data_path, 'logs.txt'))) {
683+
fs.unlinkSync(path.join(data_path, 'logs.txt'));
684+
}
685+
try {
686+
delCache();
687+
} catch (e) {
688+
win.close(true);
689+
}
690+
});
691+
659692
nw.App.on('open', function (cmd) {
660693
var file;
661694
if (os.platform() === 'win32') {
@@ -682,19 +715,6 @@ nw.App.on('open', function (cmd) {
682715
}
683716
});
684717

685-
win.on('minimize', function () {
686-
if (Settings.minimizeToTray) {
687-
minimizeToTray();
688-
}
689-
});
690-
691-
// When win.focus() doesn't do it's job right, play dirty.
692-
App.vent.on('window:focus', function () {
693-
win.setAlwaysOnTop(true);
694-
win.focus();
695-
win.setAlwaysOnTop(Settings.alwaysOnTop);
696-
});
697-
698718
// On uncaught exceptions, log to console.
699719
process.on('uncaughtException', function (err) {
700720
try {
6.71 KB
Loading

src/app/lib/providers/opensubtitles.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
openSRT = new OS({
88
useragent: Settings.opensubtitles.useragent + ' v' + (Settings.version || 1),
99
username: Settings.opensubtitlesUsername,
10-
password: Settings.opensubtitlesPassword
10+
password: Settings.opensubtitlesPassword,
11+
ssl: true
1112
});
1213
};
1314

src/app/lib/providers/trakttv.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
this.client = new Trakt({
66
client_id: Settings.trakttv.client_id,
77
client_secret: Settings.trakttv.client_secret,
8-
plugins: ['ondeck', 'matcher', 'images'],
8+
plugins: {
9+
ondeck: require('trakt.tv-ondeck'),
10+
matcher: require('trakt.tv-matcher'),
11+
images: require('trakt.tv-images')
12+
},
913
options: {
1014
images: {
1115
smallerImages: true,

src/app/lib/vendor/videojshooks.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,8 @@ vjs.TextTrack.prototype.load = function () {
284284
.replace(/(- |==|sync).*[\s\S].*[\s\S].*[\s\S].*[\s\S].*\.(com|org|net|edu)/ig, '') // various teams
285285
.replace(/[^0-9][\s\S][^0-9\W].*[\s\S].*[\s\S].*opensubtitles.*/ig, ''); // opensubs "contact us" ads
286286

287+
strings = Common.sanitize(strings); // xss-style attacks
288+
strings = strings.replace(/--\&gt\;/g, '-->'); // restore srt format
287289
callback(strings);
288290
};
289291

src/app/lib/views/browser/item.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
ui: {
2020
covers: '.cover-imgs',
21+
defaultCover: '.cover',
2122
bookmarkIcon: '.actions-favorites',
2223
watchedIcon: '.actions-watched'
2324
},
@@ -135,7 +136,7 @@
135136
var posterCache = new Image();
136137
posterCache.src = poster;
137138

138-
this.ui.covers.append(`<img class="cover-overlay"/>`);
139+
this.ui.covers.append(`<div class="cover-overlay"></div>`);
139140

140141
posterCache.onload = function () {
141142
posterCache.onload = () => {};
@@ -149,11 +150,14 @@
149150
posterCache.src = c.toDataURL();
150151
}
151152

152-
this.ui.covers.children(-1).attr('src', posterCache.src).addClass('fadein');
153+
this.ui.covers.children(-1).css('background-image', 'url('+posterCache.src+')').addClass('fadein').delay(600).queue(_ => {
154+
this.ui.defaultCover.addClass('empty');
155+
});
153156
}.bind(this);
154157

155158
posterCache.onerror = function (e) {
156159
this.ui.covers.empty();
160+
this.ui.defaultCover.removeClass('empty');
157161
}.bind(this);
158162
},
159163

src/app/lib/views/browser/list.js

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,9 @@
262262

263263
onLoaded: function () {
264264
App.vent.trigger('list:loaded');
265-
this.checkEmpty();
266265
var self = this;
267-
this.addloadmore();
266+
267+
this.completerow();
268268

269269
if (typeof (this.ui.spinner) === 'object') {
270270
this.ui.spinner.hide();
@@ -298,23 +298,34 @@
298298
}
299299
},
300300

301+
completerow: function () {
302+
var elms = this.addloadmore();
303+
elms += this.addghosts();
304+
305+
$('.ghost, #load-more-item').remove();
306+
$('.items').append(elms);
307+
308+
this.showloadmore();
309+
},
310+
311+
addghosts: function () {
312+
return '<div class="ghost"></div>'.repeat(10);
313+
},
314+
301315
addloadmore: function () {
302-
var self = this;
316+
return '<div id="load-more-item" class="load-more"><span class="status-loadmore">' + i18n.__('Load More') + '</span><div id="loading-more-animi" class="loading-container"><div class="ball"></div><div class="ball1"></div></div></div>';
317+
},
303318

304-
// maxResults to hide load-more on providers that return hasMore=true no matter what.
305-
var currentPage = Math.ceil(this.collection.length / 50);
306-
var maxResults = currentPage * 50;
319+
showloadmore: function () {
320+
var self = this;
307321

308322
switch (App.currentview) {
309323
case 'movies':
310324
case 'shows':
311325
case 'anime':
312326
if ($('.items').children().last().attr('id') !== 'load-more-item') {
313-
$('#load-more-item').remove();
314327
if (this.collection.hasMore && !this.collection.filter.keywords && this.collection.state !== 'error' && this.collection.length !== 0) {
315-
$('.items').append('<div id="load-more-item" class="load-more"><span class="status-loadmore">' + i18n.__('Load More') + '</span><div id="loading-more-animi" class="loading-container"><div class="ball"></div><div class="ball1"></div></div></div>');
316-
317-
$('#load-more-item').click(function () {
328+
$('#load-more-item').css('display', 'inline-block').click(function () {
318329
$('#load-more-item').off('click');
319330
self.collection.fetchMore();
320331
});

0 commit comments

Comments
 (0)