Skip to content

Commit

Permalink
Resolves #38 - Bug that prevented to kill the process on any platform…
Browse files Browse the repository at this point in the history
… except macOS fixed. Improved title bar for macOS.
  • Loading branch information
marcosrg9 committed Nov 26, 2022
1 parent 0956b12 commit d5a1d80
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 55 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ msi-packager.js
package-lock.json
*.js
!renderers/main/injection.js
!renderers/main/offline_banner.js
!renderers/main/offline_banner.js
!renderers/main/titleBar.js
37 changes: 18 additions & 19 deletions README.es-ES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

# **YouTube TV**
[![Downloads](https://img.shields.io/github/downloads/marcosrg9/YouTubeTV/total.svg?color=FF0000&label=Total%20downloads)](https://github.com/marcosrg9/YouTubeTV/releases/)
[![Downloads](https://img.shields.io/github/downloads/marcosrg9/YouTubeTV/v2.3.4/total.svg?color=blue&label=2.3.4%20Downloads)](https://github.com/marcosrg9/YouTubeTV/releases/tag/v2.3.4)
[![Downloads](https://img.shields.io/github/downloads/marcosrg9/YouTubeTV/v2.4.1/total.svg?color=blue&label=2.4.1%20Downloads)](https://github.com/marcosrg9/YouTubeTV/releases/tag/v2.4.1)

Cliente de YouTube TV sencillo para escritorio basado en [electron](https://www.electronjs.org/). Puede conectar un dispositivo compatible, como un teléfono o un equipo con Google Chrome y enviar los vídeos a la aplicación para visualizarlos.
Cliente de YouTube TV sencillo para escritorio basado en [electron](https://www.electronjs.org/). Puede conectar un dispositivo compatible, como un teléfono o un equipo con Google Chrome y enviar los vídeos a la aplicación para visualizarlos, igual que en ChromeCast o televisores inteligentes con YouTube.

<img src="./readme/demo_player.png" width="600px">

Expand Down Expand Up @@ -33,19 +33,17 @@ Si ya tiene instalado electron de forma global, podrá iniciar la app con ```ele
## 📦 Builds
El proyecto se puede descargar compilado y listo para su uso. Disponible para Linux, macOS y Windows. En arquitecturas x86, x64 y ARM.

**⚠️ Nota: La arquitectura de 32 bits ya no es soportada para Linux, y se planea eliminar el soporte para Windows en el futuro.**

| Platform | Architecture | Link |
|---------------|:----------------:|:------:|
| Windows | x32/x64 | [Descargar](https://github.com/marcosrg9/YouTubeTV/releases/download/v2.3.4/YouTube.TV-2.3.4.exe) |
| Linux (Deb) | x64 | [Descargar](https://github.com/marcosrg9/YouTubeTV/releases/download/v2.3.4/YouTube.TV-2.3.4-amd64.deb) |
| Linux (Deb) | ARM64 | [Descargar](https://github.com/marcosrg9/YouTubeTV/releases/download/v2.3.4/YouTube.TV-2.3.4-arm64.deb) |
| Linux (Deb) | ARMv7l | [Descargar](https://github.com/marcosrg9/YouTubeTV/releases/download/v2.3.4/YouTube.TV-2.3.4-armv7l.deb) |
| Linux (RPM) | x64 | [Descargar](https://github.com/marcosrg9/YouTubeTV/releases/download/v2.3.4/YouTube.TV-2.3.4-x86_64.rpm) |
| Linux (RPM) | ARMv7l | [Descargar](https://github.com/marcosrg9/YouTubeTV/releases/download/v2.3.4/YouTube.TV-2.3.4-armv7l.rpm) |
| Linux (RPM) | ARM64 | [Descargar](https://github.com/marcosrg9/YouTubeTV/releases/download/v2.3.4/YouTube.TV-2.3.4-aarch64.rpm) |
| macOS | Intel (x64) | [Descargar](https://github.com/marcosrg9/YouTubeTV/releases/download/v2.3.4/YouTube.TV-2.3.4.dmg) |
| macOs | Apple Chip (ARM) | [Descargar](https://github.com/marcosrg9/YouTubeTV/releases/download/v2.3.4/YouTube.TV-2.3.4-arm64.dmg) |
| Windows | x32/x64 | [Descargar](https://github.com/marcosrg9/YouTubeTV/releases/download/v2.4.1/YouTube_TV-2.4.1.exe) |
| Linux (Deb) | x64 | [Descargar](https://github.com/marcosrg9/YouTubeTV/releases/download/v2.4.1/YouTube_TV-2.4.1-amd64.deb) |
| Linux (Deb) | ARM64 | [Descargar](https://github.com/marcosrg9/YouTubeTV/releases/download/v2.4.1/YouTube_TV-2.4.1-arm64.deb) |
| Linux (Deb) | ARMv7l | [Descargar](https://github.com/marcosrg9/YouTubeTV/releases/download/v2.4.1/YouTube_TV-2.4.1-armv7l.deb) |
| Linux (RPM) | x64 | [Descargar](https://github.com/marcosrg9/YouTubeTV/releases/download/v2.4.1/YouTube_TV-2.4.1-x86_64.rpm) |
| Linux (RPM) | ARMv7l | [Descargar](https://github.com/marcosrg9/YouTubeTV/releases/download/v2.4.1/YouTube_TV-2.4.1-armv7l.rpm) |
| Linux (RPM) | ARM64 | [Descargar](https://github.com/marcosrg9/YouTubeTV/releases/download/v2.4.1/YouTube_TV-2.4.1-aarch64.rpm) |
| macOS | Intel (x64) | [Descargar](https://github.com/marcosrg9/YouTubeTV/releases/download/v2.4.1/YouTube_TV-2.4.1.dmg) |
| macOs | Apple Chip (ARM) | [Descargar](https://github.com/marcosrg9/YouTubeTV/releases/download/v2.4.1/YouTube_TV-2.4.1-arm64.dmg) |

[Todas las builds](https://github.com/marcosrg9/YouTubeTV/releases/latest)

Expand All @@ -58,12 +56,13 @@ El proyecto se puede descargar compilado y listo para su uso. Disponible para Li

No comprobado en Windows y macOS para plataformas ARM, excepto linux ARM para Raspberry (armv7l).

## 🔌 Mensaje fuera de conexión – [Última actualización – 2.3.4]

Cuando YouTube TV carga sin conexión, mostrará un mensaje indicando que no es posible conectarse con los servidores de YouTube.

Cuando el renderizador detecte conectividad, lo volverá a intentar nuevamente.
<img src="./readme/offline_message_es.png" with="300px">
## ⚡️ Últimos cambios [2.4.0/2.4.1]
### **2.4.1**
- Error solucionado por el cual el proceso de YouTube TV no se cerraba completamente en plataformas que no fueran macOS.
- La barra de título es transparente (solo para macOS).
- La barra de título de la ventana de configuración no cargaba el título en español.
### **2.4.0**
- YouTube TV almacena parámetros del estado de la ventana principal de forma persistente, tales como posición, tamaño, pantalla completa y visibilidad del cursor.

## 🔧 Configuración

Expand Down
37 changes: 19 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

# **YouTube TV**
[![Downloads](https://img.shields.io/github/downloads/marcosrg9/YouTubeTV/total.svg?color=FF0000&label=Total%20downloads)](https://github.com/marcosrg9/YouTubeTV/releases/)
[![Downloads](https://img.shields.io/github/downloads/marcosrg9/YouTubeTV/v2.3.4/total.svg?color=blue&label=2.3.4%20Downloads)](https://github.com/marcosrg9/YouTubeTV/releases/tag/v2.3.4)
[![Downloads](https://img.shields.io/github/downloads/marcosrg9/YouTubeTV/latest/total.svg?color=blue&label=2.4.1%20Downloads)](https://github.com/marcosrg9/YouTubeTV/releases/tag/v2.4.1)

Simple YouTube TV Client for desktop based on [electron](https://www.electronjs.org/). It can connect with a compatible device, like a phone or a computer with Google Chrome and send videos to the application to visualize them.
Simple YouTube TV Client for desktop based on [electron](https://www.electronjs.org/). You can connect a compatible device such as a phone or computer with Google Chrome and send videos to the app for viewing, just like on ChromeCast or smart TVs with YouTube.

<img src="./readme/demo_player.png" width="600px">

Expand All @@ -28,20 +28,19 @@ It can use ```npm start``` or else ```npx electron .``` .
If you already have electron installed globally, you can start the app with ```electron .```

## 📦 Builds
The project can be downloaded already built and ready to use. Available for Linux, macOS and Windows. On x86, x84 and ARM architectures.\
**⚠️ Note: The 32-bit architecture is no longer supported on Linux, and support for Windows is planned to be removed in the future.**
The project can be downloaded already built and ready to use. Available for Linux, macOS and Windows. On x86, x84 and ARM architectures.

| Platform | Architecture | Link |
|---------------|:----------------:|:------:|
| Windows | x32/x64 | [Download](https://github.com/marcosrg9/YouTubeTV/releases/download/v2.3.4/YouTube.TV-2.3.4.exe) |
| Linux (Deb) | x64 | [Download](https://github.com/marcosrg9/YouTubeTV/releases/download/v2.3.4/YouTube.TV-2.3.4-amd64.deb) |
| Linux (Deb) | ARM64 | [Download](https://github.com/marcosrg9/YouTubeTV/releases/download/v2.3.4/YouTube.TV-2.3.4-arm64.deb) |
| Linux (Deb) | ARMv7l | [Download](https://github.com/marcosrg9/YouTubeTV/releases/download/v2.3.4/YouTube.TV-2.3.4-armv7l.deb) |
| Linux (RPM) | x64 | [Download](https://github.com/marcosrg9/YouTubeTV/releases/download/v2.3.4/YouTube.TV-2.3.4-x86_64.rpm) |
| Linux (RPM) | ARMv7l | [Download](https://github.com/marcosrg9/YouTubeTV/releases/download/v2.3.4/YouTube.TV-2.3.4-armv7l.rpm) |
| Linux (RPM) | ARM64 | [Download](https://github.com/marcosrg9/YouTubeTV/releases/download/v2.3.4/YouTube.TV-2.3.4-aarch64.rpm) |
| macOS | Intel (x64) | [Download](https://github.com/marcosrg9/YouTubeTV/releases/download/v2.3.4/YouTube.TV-2.3.4.dmg) |
| macOs | Apple Chip (ARM) | [Download](https://github.com/marcosrg9/YouTubeTV/releases/download/v2.3.4/YouTube.TV-2.3.4-arm64.dmg) |
| Windows | x32/x64 | [Download](https://github.com/marcosrg9/YouTubeTV/releases/download/v2.4.1/YouTube_TV-2.4.1.exe) |
| Linux (Deb) | x64 | [Download](https://github.com/marcosrg9/YouTubeTV/releases/download/v2.4.1/YouTube_TV-2.4.1-amd64.deb) |
| Linux (Deb) | ARM64 | [Download](https://github.com/marcosrg9/YouTubeTV/releases/download/v2.4.1/YouTube_TV-2.4.1-arm64.deb) |
| Linux (Deb) | ARMv7l | [Download](https://github.com/marcosrg9/YouTubeTV/releases/download/v2.4.1/YouTube_TV-2.4.1-armv7l.deb) |
| Linux (RPM) | x64 | [Download](https://github.com/marcosrg9/YouTubeTV/releases/download/v2.4.1/YouTube_TV-2.4.1-x86_64.rpm) |
| Linux (RPM) | ARMv7l | [Download](https://github.com/marcosrg9/YouTubeTV/releases/download/v2.4.1/YouTube_TV-2.4.1-armv7l.rpm) |
| Linux (RPM) | ARM64 | [Download](https://github.com/marcosrg9/YouTubeTV/releases/download/v2.4.1/YouTube_TV-2.4.1-aarch64.rpm) |
| macOS | Intel (x64) | [Download](https://github.com/marcosrg9/YouTubeTV/releases/download/v2.4.1/YouTube_TV-2.4.1.dmg) |
| macOs | Apple Chip (ARM) | [Download](https://github.com/marcosrg9/YouTubeTV/releases/download/v2.4.1/YouTube_TV-2.4.1-arm64.dmg) |

[All builds](https://github.com/marcosrg9/YouTubeTV/releases/latest)

Expand All @@ -53,11 +52,13 @@ The project can be downloaded already built and ready to use. Available for Linu

Not tested on Windows and macOS for ARM platforms, except for ARM Linux for Raspberry (armv7l).

## 🔌 Offline message – [Last update – 2.3.4]
When YouTube TV loads offline, it will display a message indicating that it has been unable to connect to YouTube's servers.

When the renderer detects connectivity, it will try again.
<img src="./readme/offline_message_en.png" with="300px">
## ⚡️ Last changes [2.4.0/2.4.1]
### **2.4.1**
- Fixed bug where the YouTube TV process would not close completely on platforms other than macOS.
- The title bar is transparent (macOS only).
- The title bar of the window did not load the Spanish title.
### **2.4.0**
- YouTube TV persistently stores parameters of the main window state, such as position, size, full screen and cursor visibility.

## 🔧 Configuration

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "youtube-tv-electron",
"name": "youtube-tv",
"productName": "YouTube TV",
"version": "2.4.0",
"description": "Cliente de YouTube TV sencillo para escritorio basado en electron.",
"version": "2.4.1",
"description": "Simple YouTube TV client for desktop based on electron.",
"main": "main.js",
"scripts": {
"start": "electron main.js",
Expand Down
Binary file modified readme/demo_player.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 0 additions & 2 deletions renderers/main/injection.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,4 @@ loadConnectionEvents();
// Escucha las peticiones de consultas al localStorage.
listenLocalStorageQueries();

// Indica al proceso principal que el código se ha cargado.

console.log('JavaScript enhancements loaded at', new Date(Date.now()).toISOString());
51 changes: 39 additions & 12 deletions renderers/main/main.renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ export class Renderer {
/** JavaScript injection code */
private jsic: string = '';

/** JavaScript injection title bar styles */
private titleBar: string = '';

constructor() {

// Set app menu to null.
Expand All @@ -61,7 +64,7 @@ export class Renderer {

this.url = '__DFT__';

this.window.webContents.on('dom-ready', this.injectJSCode.bind(this) );
this.window.webContents.on('dom-ready', () => this.injectJSCode.bind(this));

this.setAccelerators();

Expand All @@ -77,9 +80,7 @@ export class Renderer {
}
})
})
.on('window-all-closed', () => {
if (platform() === 'darwin') app.quit();
})
.on('window-all-closed', () => { app.quit() })
}

/** Create a new renderer window. */
Expand All @@ -88,7 +89,7 @@ export class Renderer {
this.window = new BrowserWindow({
width: 1230,
height: 720,
titleBarStyle: 'default',
titleBarStyle: platform() === 'darwin' ? 'hiddenInset' : 'default',
fullscreen: false,
fullscreenable: true,
title: 'YouTube TV',
Expand All @@ -105,16 +106,34 @@ export class Renderer {

}

/** Inject a JavaScript code into the renderer process to patch events and add some features. */
private async injectJSCode() {
/**
* Inject a JavaScript code into the renderer process to patch events and add some features.
* @param script Type of script to be injected.
* */
private async injectJSCode(script: 'all' | 'patchs' | 'titlebar' = 'all') {

try {

if (this.jsic === '') {
this.jsic = await readFile(join(__dirname, 'injection.js'), { encoding: 'utf8' });
}

this.window.webContents.executeJavaScript(this.jsic);

if (platform() === 'darwin' && this.titleBar === '') {
this.titleBar = await readFile(join(__dirname, 'titleBar.js'), { encoding: 'utf8' });

}

if (script === 'all') {
this.window.webContents.executeJavaScript(this.jsic);
platform() === 'darwin' ? this.window.webContents.executeJavaScript(this.titleBar) : false;

} else if (script === 'patchs') {
this.window.webContents.executeJavaScript(this.jsic);

} else if (script === 'titlebar') {
platform() === 'darwin' ? this.window.webContents.executeJavaScript(this.titleBar) : false;

}

} catch (error) {
debugger;
Expand Down Expand Up @@ -280,7 +299,7 @@ export class Renderer {
}
})
.catch(err => {
// If the data is not valid or not available, set the default resolution.
// If the data is invalid or not available, set the default resolution.
this.setResEmulator(3840, 2160);
})

Expand All @@ -297,10 +316,14 @@ export class Renderer {
if (value === '__DFT__') url = '';

this.window.loadURL(this._url + url, { userAgent: this.userAgent })
.then(() => {
this.injectJSCode();
})
.catch(async() => {

ipcMain.once('restored', () => { this.url = value });

this.injectJSCode('titlebar');
const offline = await readFile(join(__dirname, 'offline_banner.js'), { encoding: 'utf8' });
this.window.webContents.executeJavaScript(offline);

Expand All @@ -314,11 +337,15 @@ export class Renderer {
this.window.fullScreen = true;

this.window.webContents.loadURL(this._url + value, { userAgent: this.userAgent })
.then(() => {
this.injectJSCode();
})
// This should never happen...
.catch(async() => {

ipcMain.once('restored', () => { this.url = value });

ipcMain.once('restored', () => { this.urlByDial = value });

this.injectJSCode('titlebar');
const offline = await readFile(join(__dirname, 'offline_banner.js'), { encoding: 'utf8' });
this.window.webContents.executeJavaScript(offline);

Expand Down
15 changes: 15 additions & 0 deletions renderers/main/titleBar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const loadDraggableTittleBar = () => {

const titlebar = document.createElement('div');

titlebar.id = 'draggable_titlebar';

titlebar.style.width = '100%';
titlebar.style.height = '35px';
titlebar.style['-webkit-app-region'] = 'drag';

document.body.appendChild(titlebar);

}

loadDraggableTittleBar();
2 changes: 2 additions & 0 deletions renderers/settings/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ <h4 id="maxRes" style="margin-bottom: 3px;">Resolución máxima</h4>

const opts = document.querySelector('#res').options;

document.title = msg.settings;

for (let i = 0; i < opts.length; i++) {

opts[i].innerText = opts[i].innerText.replace('Hasta', msg.upto)
Expand Down

0 comments on commit d5a1d80

Please sign in to comment.