Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
telpalbrox committed Nov 3, 2015
0 parents commit 4b70f1b
Show file tree
Hide file tree
Showing 13 changed files with 488 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
indent_style = tab
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[package.json]
indent_style = space
indent_size = 2

[*.md]
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
/dist
.idea/
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# EliteTime
### Unnoficial desktop EliteTorrent.net client
This is a torrent stream client for EliteTorrent.net.

Proyect state: VERY ALPHA with the possibility of being abandoned

## Features
- Shows the latest torrents uploaded to the page
- Torrent browser with pagination

# TODO
- CSS
- Show torrents covers
- Show torrents info
- Show download info
- Improve code (some framework JS?)
- Show more page sections
- Reduce bugs
- Button for obtain magnet link

## Dev

```
$ npm install
```

### Run

```
$ npm start
```

### Build

```
$ npm run build
```

Builds the app for OS X, Linux, and Windows, using [electron-packager](https://github.com/maxogden/electron-packager).


## License

MIT © Alberto Luna
22 changes: 22 additions & 0 deletions README_ES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# EliteTime
### Cliente no ofcial de EliteTorrent.net
Esta aplicación es capaz de hacer stream de los torrents mostrados en la página EliteTorrent.net.

Esta aplicación se puede romper muy fácilmente si cambia algún id / clase / etiqueta de EliteTorrent.net.

Estado del proyecto: MUY ALPHA y con probabilidades de ser abandonado.

## Características
- Muestra los últimos torrents subidos a la página
- Buscador de torrents con paginación

# TODO
- CSS
- Mostrar carátulas de los torrents
- Mostrar información de los torrents
- Mostrar información de la descarga
- Mejorar código (¿usar algun framework JS?)
- Mostras más secciones de la página
- Reducir bugs
- Botón para obtener enlace magnet

46 changes: 46 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
'use strict';
const app = require('app');
const BrowserWindow = require('browser-window');

// report crashes to the Electron project
require('crash-reporter').start();

// adds debug features like hotkeys for triggering dev tools and reload
require('electron-debug')();

// prevent window being garbage collected
let mainWindow;

function onClosed() {
// dereference the window
// for multiple windows store them in an array
mainWindow = null;
}

function createMainWindow() {
const win = new BrowserWindow({
width: 1000,
height: 800
});

win.loadUrl(`file://${__dirname}/src/index.html`);
win.on('closed', onClosed);

return win;
}

app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});

app.on('activate-with-no-open-windows', () => {
if (!mainWindow) {
mainWindow = createMainWindow();
}
});

app.on('ready', () => {
mainWindow = createMainWindow();
});
21 changes: 21 additions & 0 deletions license
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) <%= name %> <<%= email %>> (<%= website %>)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
48 changes: 48 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"name": "elite-time",
"productName": "EliteTime",
"version": "0.0.1",
"description": "Unnoficial desktop EliteTorrent.net client",
"license": "MIT",
"repository": "user/repo",
"author": {
"name": "Alberto Luna",
"email": "[email protected]"
},
"engines": {
"node": ">=4"
},
"electronVersion": "0.34.1",
"scripts": {
"test": "xo",
"start": "electron .",
"build": "electron-packager . EliteTime --out=dist --ignore='^/dist$' --prune --asar --all --version=0.34.2"
},
"files": [
"index.js",
"index.html",
"index.css"
],
"keywords": [
"electron-app"
],
"dependencies": {
"axios": "^0.7.0",
"cheerio": "^0.19.0",
"electron-debug": "^0.3.0",
"normalize.css": "^3.0.3",
"peerflix": "^0.32.2"
},
"devDependencies": {
"electron-packager": "^5.0.0",
"electron-prebuilt": "^0.34.1",
"xo": "^0.10.0"
},
"xo": {
"esnext": true,
"envs": [
"node",
"browser"
]
}
}
149 changes: 149 additions & 0 deletions src/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
'use strict';
let axios = require('axios');
let peerflix = require('peerflix');
let os = require('os');
let EliteTorrent = require('./lib/EliteTorrent.js');
let engine, torrentListContainer, loadingContainer, playerContainer, paginationContainer;
let page = 0;
let nextPage, prevPage, searchQuery;

document.body.onload = function() {
torrentListContainer = document.querySelector('#torrent-list-container');
let torrentSearchForm = document.querySelector('#search-torrent');
let torrentTitleInput = document.querySelector('#torrent-form-title');
loadingContainer = document.querySelector('#loading');
loadingContainer.style.display = 'none';
playerContainer = document.querySelector('#player');
paginationContainer = document.querySelector('#pagination-container');
nextPage = document.querySelector('#next-page');
prevPage = document.querySelector('#prev-page');
nextPage.addEventListener('click', nextPageHandler);
prevPage.addEventListener('click', prevPageHandler);
torrentSearchForm.addEventListener('submit', (event) => {
event.preventDefault();
if(!torrentTitleInput.value) {
createLastDownloads();
return false;
}
paginationContainer.style.display = 'block';
searchQuery = torrentTitleInput.value;
page = 1;
prevPage.disabled = true;
EliteTorrent.search(torrentTitleInput.value, page).then((downloads => {
tooglePagination();
createTorrentResults(downloads);
}));
return false;
});

createLastDownloads();
};

function createTorrentResults(downloads) {
torrentListContainer.removeChild(document.querySelector('#torrent-list'));
if(!downloads.length) {
let notResultsElement = document.createElement('h1');
notResultsElement.appendChild(document.createTextNode('No hay resultados'));
notResultsElement.id = 'torrent-list';
return torrentListContainer.appendChild(notResultsElement);
}
torrentListContainer.appendChild(createTorrentList(downloads));
}

function createLastDownloads() {
page = 0;
paginationContainer.style.display = 'none';
let torrentListElement = document.querySelector('#torrent-list');
if(torrentListElement) {
torrentListContainer.removeChild(torrentListElement);
}
EliteTorrent.getLastDownloads().then(downloads => {
torrentListContainer.appendChild(createTorrentList(downloads));
}).catch(err => {
console.error(err);
});
}

function createTorrentList(torrents) {
let torrentList = document.createElement('ul');
torrentList.id = 'torrent-list';
for (let torrent of torrents) {
torrentList.appendChild(createTorrentListItem(torrent));
}
return torrentList;
}

function createTorrentListItem(torrent) {
let torrentElement = document.createElement('li');
let link = document.createElement('a');
link.setAttribute('href', '#');
link.innerHTML = torrent.name;
link.addEventListener('click', torrentClickHandler(torrent.id));
torrentElement.appendChild(link);
return torrentElement;
}

function torrentClickHandler(id) {
return function torrentClick() {
loadingContainer.style.display = 'block';
EliteTorrent.getTorrent(id).then(torrent => {
if(engine) {
engine.destroy();
}
if(playerContainer.childNodes[0]) {
playerContainer.removeChild(playerContainer.childNodes[0]);
}

engine = peerflix(torrent.magnet, {
tmp: os.tmpdir()
});

engine.server.on('listening', function () {
loadingContainer.style.display = 'none';
if (engine) {
console.log('http://127.0.0.1:' + engine.server.address().port + '/');
var video = document.createElement('video');
video.id = 'torrent-video';
video.src = 'http://127.0.0.1:' + engine.server.address().port;
video.autoPlay = true;
video.controls = true;
document.querySelector('#player').appendChild(video);
}
});
}).catch(err => {
console.error(err);
});
};
}

function nextPageHandler() {
tooglePagination();
prevPage.disabled = false;
page++;
EliteTorrent.search(searchQuery, page).then((downloads => {
createTorrentResults(downloads);
}));
console.log(page);
}

function prevPageHandler() {
tooglePagination();
if(page < 1) {
prevPage.disabled = true;
return;
}
page--;
EliteTorrent.search(searchQuery, page).then((downloads => {
createTorrentResults(downloads);
}));
console.log(page);
}

function tooglePagination() {
prevPage.disabled = true;
nextPage.disabled = true;
setTimeout(() => {
prevPage.disabled = page < 1;
nextPage.disabled = false;
}, 2500);
}
4 changes: 4 additions & 0 deletions src/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"use strict";
module.exports = {
"url": "http://www.elitetorrent.net"
};
23 changes: 23 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>EliteTime</title>
<link rel="stylesheet" href="../node_modules/normalize.css/normalize.css">
<link rel="stylesheet" href="styles/index.css">
</head>
<body>
<div id="player"></div>
<h1 id="loading">Cargando...</h1>
<form id="search-torrent">
<label for="torrent-form-title">Search torrent</label>
<input id="torrent-form-title" type="text" name="torrent-title">
<input type="submit">
</form>
<div id="torrent-list-container"></div>
<div id="pagination-container">
<input type="button" id="prev-page" value="Página anterior"> <input type="button" id="next-page" value="Página siguiente">
</div>
<script src="app.js"></script>
</body>
</html>
Loading

0 comments on commit 4b70f1b

Please sign in to comment.