-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
124 lines (105 loc) · 3.12 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
const {app, globalShortcut} = require('electron')
const {BrowserWindow} = require('electron')
const {ipcMain} = require('electron')
const {Menu} = require('electron')
const {session} = require('electron')
let mainWindow;
app.on('activate', () => {
if(mainWindow==null){
mainWindow = createMainWindow();
mainWindow.show();
}
console.log("activate");
});
function createMainWindow(){
const win = new BrowserWindow({
width: 900,
height: 650,
titleBarStyle:'hidden',
title: "Dreamfilm",
frame: false,
toolbar: false,
show: false,
});
app.commandLine.appendSwitch('--enable-experimental-web-platform-features');
// Load a remote URL
win.loadURL('file://'+__dirname+'/index.html');
win.once('ready-to-show', () => {
win.show();
});
// On mainwindow close, quit the app
win.on('closed', () => {
console.log('closed');
mainwindow = null;
});
return win;
}
app.on('ready', () => {
globalShortcut.register('CommandOrControl+H', () => {
app.hide();
});
var menu = Menu.buildFromTemplate([
{
label: 'Dreamfilm',
submenu: [
{label: 'About App', selector: 'orderFrontStandardAboutPanel:'},
{label: 'Quit', accelerator: 'CmdOrCtrl+Q', click: function() {app.quit();}}
]
}]);
Menu.setApplicationMenu(menu);
// Create the main window
mainWindow = createMainWindow();
mainWindow.on('app-command', (e, cmd) => {
// Navigate the window back when the user hits their mouse back button
if (cmd === 'browser-backward' && mainWindow.webContents.canGoBack()) {
mainWindow.webContents.goBack()
}
});
mainWindow.setMenu(menu);
// Open new window and play movie
ipcMain.on('play', (event, arg) => {
console.log("Laddar "+arg)
// Create a window to track the raw-movie url
var loaderWindow = new BrowserWindow({
width: 710,
height: 400,
titleBarStyle:'hidden',
title: "Spelar film",
show: false,
})
// Create a windows to show the movie
var playerWindow = new BrowserWindow({
width: 710,
height: 400,
titleBarStyle:'hidden',
title: "Spelar film",
show: true,
})
playerWindow.loadURL('file://'+__dirname+'/player/index.html',{
httpReferrer: 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36',
userAgent: 'http://www.dreamfilmhd.org/API/api.php',
});
loaderWindow.loadURL(arg.url,{
httpReferrer: 'http://dreamfilmhd.bz/'
});
var movie_url='';
loaderWindow.webContents.session.webRequest.onBeforeRequest((details, callback) => {
var url = details.url;
//Search for mp4
url = url.split('.');
if(url[url.length-1]=='mp4' || details.url.includes(".mp4") || details.url.includes("googlevideo.com")){
var first = (movie_url=='')? true : false;
movie_url = details.url;
console.log("Boom");
if(first){
playerWindow.webContents.send('url', {
url: movie_url,
viewInfo: arg.viewInfo
});
loaderWindow.close();
}
}
callback({});
})
});
})