-
-
Notifications
You must be signed in to change notification settings - Fork 509
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added favorites for xtream live streams
- Loading branch information
Showing
19 changed files
with
301 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ preload.js | |
shared/*.js | ||
playwright-report | ||
.nx | ||
server.js | ||
|
||
# dependencies | ||
/node_modules | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<html> | ||
<head> | ||
<title>{{it.title}}</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<style> | ||
body { | ||
font-family: Arial, sans-serif; | ||
margin: 0; | ||
padding: 0; | ||
box-sizing: border-box; | ||
} | ||
header { | ||
width: 100%; | ||
background-color: #f8f9fa; | ||
padding: 10px 0; | ||
text-align: center; | ||
} | ||
header h1 { | ||
margin: 0; | ||
font-size: 24px; | ||
} | ||
.button-container { | ||
display: flex; | ||
justify-content: center; | ||
gap: 20px; | ||
margin-top: 20px; | ||
} | ||
button { | ||
padding: 10px 20px; | ||
border: none; | ||
border-radius: 5px; | ||
font-size: 16px; | ||
cursor: pointer; | ||
color: white; | ||
} | ||
.up-channel { | ||
background-color: #007bff; | ||
} | ||
.down-channel { | ||
background-color: #28a745; | ||
} | ||
footer { | ||
margin-top: 30px; | ||
text-align: center; | ||
} | ||
footer p { | ||
font-size: 14px; | ||
color: #6c757d; | ||
} | ||
</style> | ||
<script> | ||
// AJAX isteği yapmak için fetch API kullanımı | ||
function callAjax(url) { | ||
fetch(url) | ||
.then(response => { | ||
if (!response.ok) { | ||
throw new Error('Network response was not ok'); | ||
} | ||
return response.json(); | ||
}) | ||
.then(data => { | ||
console.log('Success:', data); | ||
alert('AJAX request successful! Check console for data.'); | ||
}) | ||
.catch((error) => { | ||
console.error('There was a problem with your fetch operation:', error); | ||
}); | ||
} | ||
</script> | ||
</head> | ||
<body> | ||
<header> | ||
<h1>{{it.headerText}}</h1> | ||
</header> | ||
|
||
<div class="button-container"> | ||
<button class="up-channel" onclick="callAjax('{{it.upChannelUrl}}')">{{it.upChannelText}}</button> | ||
<button class="down-channel" onclick="callAjax('{{it.downChannelUrl}}')">{{it.downChannelText}}</button> | ||
</div> | ||
|
||
<footer> | ||
<p>{{it.footer}}</p> | ||
</footer> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import { IncomingMessage, ServerResponse } from "http"; | ||
import { REMOTE_CONTROL_CHANGE_CHANNEL } from "../shared/ipc-commands"; | ||
|
||
const http = require('http'); | ||
const Sqrl = require('squirrelly'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
export class Server { | ||
/** Server instance */ | ||
server: any; | ||
/** Api instance */ | ||
api: any; | ||
|
||
/** | ||
* Creates a new server instance | ||
* @param port port number | ||
* @param api application instance | ||
*/ | ||
constructor(_api: any) { | ||
this.api = _api; | ||
this.server = http.createServer(this.requestListener.bind(this)); | ||
} | ||
|
||
updateSettings() { | ||
if (this.api.settings.remoteControl && !this.server.listening) { | ||
this.server.listen(this.api.settings.remoteControlPort); | ||
} else if (this.server.listening && !this.api.settings.remoteControl) { | ||
this.server.close(); | ||
} | ||
} | ||
|
||
async getTranslation() { | ||
const language = this.api.settings && this.api.settings.language ? this.api.settings.language : 'en'; | ||
const languageFileContent = await fs.promises.readFile(path.join(__dirname, `../src/assets/i18n/${language}.json`), 'utf-8'); | ||
return JSON.parse(languageFileContent); | ||
} | ||
|
||
getTranslationValue(key: string, translation: any, defaultValue: string) { | ||
if (translation && translation.REMOTE_CONTROL) { | ||
const translationValue = translation.REMOTE_CONTROL[key]; | ||
if (translationValue) { | ||
return translationValue; | ||
} | ||
} | ||
return defaultValue; | ||
} | ||
|
||
async requestListener(request: IncomingMessage, response: ServerResponse) { | ||
const currentPage = request.url?.split('?')[0]?.split('/').splice(-1)[0]; | ||
const translation = await this.getTranslation(); | ||
switch (currentPage) { | ||
case '': { | ||
const indexFile = await fs.promises.readFile(path.join(__dirname, './remote-control/', 'index.sqrl'), 'utf-8'); | ||
const renderedHtml = Sqrl.render(indexFile, { | ||
headerText: this.getTranslationValue('HEADER', translation, 'Remote Control'), | ||
upChannelText: this.getTranslationValue('UP_CHANNEL', translation, 'Up Channel'), | ||
downChannelText: this.getTranslationValue('DOWN_CHANNEL', translation, 'Down Channel'), | ||
upChannelUrl: '/upChannel', | ||
downChannelUrl: '/downChannel', | ||
title: this.getTranslationValue('TITLE', translation, 'IPTVNator'), | ||
footer: this.getTranslationValue('FOOTER', translation, 'IPTVNator') | ||
}); | ||
response.writeHead(200, { 'Content-Type': 'text/html' }); | ||
response.end(renderedHtml); | ||
break; | ||
} | ||
case 'upChannel': { | ||
this.api.mainWindow.webContents.send(REMOTE_CONTROL_CHANGE_CHANNEL, { type: 'up' }); | ||
response.writeHead(200, { 'Content-Type': 'text/html' }); | ||
response.end('Up Channel'); | ||
break; | ||
} | ||
case 'downChannel': { | ||
this.api.mainWindow.webContents.send(REMOTE_CONTROL_CHANGE_CHANNEL, { type: 'down' }); | ||
response.writeHead(200, { 'Content-Type': 'text/html' }); | ||
response.end('Down Channel'); | ||
break; | ||
} | ||
default: | ||
response.writeHead(404, { 'Content-Type': 'text/html' }); | ||
response.end('404'); | ||
break; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.