Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 331298825e | |||
| 4719117504 | |||
| c0c33b8859 | |||
| 1922cf5b87 | |||
| fa5b7a3249 | |||
| 60f65152cb | |||
| d34b74e505 | |||
| 600173c959 | |||
| 49fd73aaf9 | |||
| ffa0f07daf | |||
| dc9f73961e | |||
| bbcd955f28 | |||
| c6cc529d54 | |||
| a4094cb795 | |||
| 1c7e2e794e |
@@ -1,6 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
privateDownloadLocation: '/media/torrents-zfs',
|
||||||
ldap: {
|
ldap: {
|
||||||
url: 'ldap://10.1.0.55:389',
|
url: 'ldap://10.1.0.55:389',
|
||||||
bindDN: 'cn=ldapclient service,ou=people,dc=theta42,dc=com',
|
bindDN: 'cn=ldapclient service,ou=people,dc=theta42,dc=com',
|
||||||
@@ -21,5 +22,6 @@ module.exports = {
|
|||||||
port: 9091,
|
port: 9091,
|
||||||
username: 'william',
|
username: 'william',
|
||||||
password: '__IN SRECREST FILE__',
|
password: '__IN SRECREST FILE__',
|
||||||
|
statusUpdateInterval: 500,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
4
conf/development.js
Normal file
4
conf/development.js
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
};
|
||||||
@@ -2,8 +2,7 @@
|
|||||||
|
|
||||||
const ps = require('./pubsub.js');
|
const ps = require('./pubsub.js');
|
||||||
const {Torrent} = require('>/models');
|
const {Torrent} = require('>/models');
|
||||||
|
const conf = require('>/conf');
|
||||||
console.log('here!!!!!!!!!!!!!')
|
|
||||||
|
|
||||||
let statusLock = false;
|
let statusLock = false;
|
||||||
setInterval(async function(){
|
setInterval(async function(){
|
||||||
@@ -17,9 +16,4 @@ setInterval(async function(){
|
|||||||
// console.error('status interval error', error)
|
// console.error('status interval error', error)
|
||||||
}
|
}
|
||||||
statusLock = false
|
statusLock = false
|
||||||
}, 10000, statusLock);
|
}, conf.transmission.statusUpdateInterval, statusLock);
|
||||||
|
|
||||||
|
|
||||||
// ps.subscribe(/./g, function(...args){
|
|
||||||
// console.log('event', args);
|
|
||||||
// });
|
|
||||||
|
|||||||
@@ -11,10 +11,6 @@ var userLUR = new LRUCache({
|
|||||||
maxAge: 60000,
|
maxAge: 60000,
|
||||||
});
|
});
|
||||||
|
|
||||||
const client = new Client({
|
|
||||||
url: conf.url,
|
|
||||||
});
|
|
||||||
|
|
||||||
const user_parse = function(data){
|
const user_parse = function(data){
|
||||||
if(data[conf.userNameAttribute]){
|
if(data[conf.userNameAttribute]){
|
||||||
data.username = data[conf.userNameAttribute];
|
data.username = data[conf.userNameAttribute];
|
||||||
@@ -31,6 +27,10 @@ User.backing = "LDAP";
|
|||||||
|
|
||||||
User.list = async function(){
|
User.list = async function(){
|
||||||
try{
|
try{
|
||||||
|
const client = new Client({
|
||||||
|
url: conf.url,
|
||||||
|
});
|
||||||
|
|
||||||
await client.bind(conf.bindDN, conf.bindPassword);
|
await client.bind(conf.bindDN, conf.bindPassword);
|
||||||
|
|
||||||
const res = await client.search(conf.userBase, {
|
const res = await client.search(conf.userBase, {
|
||||||
@@ -49,6 +49,10 @@ User.list = async function(){
|
|||||||
|
|
||||||
User.listDetail = async function(){
|
User.listDetail = async function(){
|
||||||
try{
|
try{
|
||||||
|
const client = new Client({
|
||||||
|
url: conf.url,
|
||||||
|
});
|
||||||
|
|
||||||
await client.bind(conf.bindDN, conf.bindPassword);
|
await client.bind(conf.bindDN, conf.bindPassword);
|
||||||
|
|
||||||
const res = await client.search(conf.userBase, {
|
const res = await client.search(conf.userBase, {
|
||||||
@@ -86,7 +90,11 @@ User.get = async function(data, key){
|
|||||||
data.searchValue = data.searchValue || data.uid;
|
data.searchValue = data.searchValue || data.uid;
|
||||||
|
|
||||||
let filter = `(&${conf.userFilter}(${data.searchKey}=${data.searchValue}))`;
|
let filter = `(&${conf.userFilter}(${data.searchKey}=${data.searchValue}))`;
|
||||||
if(userLUR.get(filter)) return userLUR.get(filter)
|
if(userLUR.get(filter)) return userLUR.get(filter);
|
||||||
|
|
||||||
|
const client = new Client({
|
||||||
|
url: conf.url,
|
||||||
|
});
|
||||||
|
|
||||||
await client.bind(conf.bindDN, conf.bindPassword);
|
await client.bind(conf.bindDN, conf.bindPassword);
|
||||||
const res = await client.search(conf.userBase, {
|
const res = await client.search(conf.userBase, {
|
||||||
@@ -131,6 +139,10 @@ User.login = async function(data){
|
|||||||
|
|
||||||
let user = await this.get(data.uid || data[conf.userNameAttribute] || data.username);
|
let user = await this.get(data.uid || data[conf.userNameAttribute] || data.username);
|
||||||
|
|
||||||
|
const client = new Client({
|
||||||
|
url: conf.url,
|
||||||
|
});
|
||||||
|
|
||||||
await client.bind(user.dn, data.password);
|
await client.bind(user.dn, data.password);
|
||||||
|
|
||||||
await client.unbind();
|
await client.unbind();
|
||||||
|
|||||||
@@ -3,13 +3,9 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
async up(queryInterface, Sequelize) {
|
async up(queryInterface, Sequelize) {
|
||||||
await queryInterface.createTable('Torrents', {
|
await queryInterface.createTable('Torrents', {
|
||||||
id: {
|
|
||||||
allowNull: false,
|
|
||||||
autoIncrement: true,
|
|
||||||
primaryKey: true,
|
|
||||||
type: Sequelize.INTEGER
|
|
||||||
},
|
|
||||||
hashString: {
|
hashString: {
|
||||||
|
primaryKey: true,
|
||||||
|
allowNull: false,
|
||||||
type: Sequelize.STRING
|
type: Sequelize.STRING
|
||||||
},
|
},
|
||||||
magnetLink: {
|
magnetLink: {
|
||||||
|
|||||||
@@ -36,12 +36,18 @@ module.exports = (sequelize, DataTypes, Model) => {
|
|||||||
// console.log('instance', instance)
|
// console.log('instance', instance)
|
||||||
await this.build(data).validate();
|
await this.build(data).validate();
|
||||||
// console.log('validate', val);
|
// console.log('validate', val);
|
||||||
|
data.isPrivate = data.isPrivate === 'true' ? true : false;
|
||||||
|
|
||||||
let res = await tr_client.addUrl(data.magnetLink);
|
let options = {
|
||||||
|
'download-dir': data.isPrivate ? `${conf.privateDownloadLocation}/${data.added_by}` : undefined,
|
||||||
|
};
|
||||||
|
|
||||||
|
let res = await tr_client.addUrl(data.magnetLink, options);
|
||||||
|
|
||||||
return await super.create({
|
return await super.create({
|
||||||
magnetLink: data.magnetLink,
|
magnetLink: data.magnetLink,
|
||||||
hashString: res.hashString,
|
hashString: res.hashString,
|
||||||
|
isPrivate: data.isPrivate,
|
||||||
name: res.name,
|
name: res.name,
|
||||||
added_by: data.added_by,
|
added_by: data.added_by,
|
||||||
status: 0,
|
status: 0,
|
||||||
@@ -53,12 +59,21 @@ module.exports = (sequelize, DataTypes, Model) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async getTorrentData(noUpdate){
|
static async migrate(hashString, username){
|
||||||
try{
|
try{
|
||||||
let res = ( await tr_client.get(this.hashString, [
|
let exists = await this.findByPk(hashString);
|
||||||
|
|
||||||
|
if(exists){
|
||||||
|
console.log('torrent in DB, skipping')
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
|
||||||
|
let res = ( await tr_client.get(hashString, [
|
||||||
"eta", "percentDone", "status", "rateDownload",
|
"eta", "percentDone", "status", "rateDownload",
|
||||||
"errorString", "hashString", 'name',
|
"errorString", "hashString", 'name',
|
||||||
'downloadDir',
|
'downloadDir',
|
||||||
|
'addedDate',
|
||||||
|
'magnetLink',
|
||||||
'files', //array of files
|
'files', //array of files
|
||||||
'filesStats', // array of files with status
|
'filesStats', // array of files with status
|
||||||
'isFinished',
|
'isFinished',
|
||||||
@@ -68,9 +83,38 @@ module.exports = (sequelize, DataTypes, Model) => {
|
|||||||
'sizeWhenDone',
|
'sizeWhenDone',
|
||||||
]) ).torrents[0];
|
]) ).torrents[0];
|
||||||
|
|
||||||
|
// console.log('date:', res.addedDate, new Date(res.addedDate*1000), 'res:', res)
|
||||||
|
|
||||||
|
let instance = await this.build({createdAt: new Date(res.addedDate*1000), ...res, added_by: username});
|
||||||
|
await instance.save();
|
||||||
|
return {...res, ...instance.dataValues};
|
||||||
|
}catch(error){
|
||||||
|
console.error('migrate error', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async getTorrentData(noUpdate){
|
||||||
|
try{
|
||||||
|
|
||||||
if(this.percentDone === 1) return this.dataValues
|
if(this.percentDone === 1) return this.dataValues
|
||||||
|
|
||||||
|
let res = ( await tr_client.get(this.hashString, [
|
||||||
|
"eta", "percentDone", "status", "rateDownload",
|
||||||
|
"errorString", "hashString", 'name',
|
||||||
|
'downloadDir',
|
||||||
|
'dateCreated',
|
||||||
|
'files', //array of files
|
||||||
|
'filesStats', // array of files with status
|
||||||
|
'isFinished',
|
||||||
|
'isStalled',
|
||||||
|
'peers',
|
||||||
|
'peersConnected', // array of peers,
|
||||||
|
'sizeWhenDone',
|
||||||
|
]) ).torrents[0];
|
||||||
|
|
||||||
await this.update(res);
|
await this.update(res);
|
||||||
if(noUpdate) await this.save();
|
if(noUpdate) await this.save();
|
||||||
|
|
||||||
return {...res, ...this.dataValues};
|
return {...res, ...this.dataValues};
|
||||||
}catch(error){
|
}catch(error){
|
||||||
if(error.code === 'ECONNREFUSED'){
|
if(error.code === 'ECONNREFUSED'){
|
||||||
@@ -100,6 +144,11 @@ module.exports = (sequelize, DataTypes, Model) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Torrent.init({
|
Torrent.init({
|
||||||
|
hashString: {
|
||||||
|
type: DataTypes.STRING,
|
||||||
|
allowNull: false,
|
||||||
|
primaryKey: true
|
||||||
|
},
|
||||||
magnetLink: {
|
magnetLink: {
|
||||||
type: DataTypes.STRING,
|
type: DataTypes.STRING,
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
@@ -112,7 +161,6 @@ module.exports = (sequelize, DataTypes, Model) => {
|
|||||||
type: DataTypes.BOOLEAN,
|
type: DataTypes.BOOLEAN,
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
},
|
},
|
||||||
hashString: DataTypes.STRING,
|
|
||||||
name: DataTypes.STRING,
|
name: DataTypes.STRING,
|
||||||
added_by: {
|
added_by: {
|
||||||
type: DataTypes.STRING,
|
type: DataTypes.STRING,
|
||||||
@@ -137,6 +185,9 @@ module.exports = (sequelize, DataTypes, Model) => {
|
|||||||
type: DataTypes.NUMBER,
|
type: DataTypes.NUMBER,
|
||||||
allowNull: true,
|
allowNull: true,
|
||||||
},
|
},
|
||||||
|
createdAt: {
|
||||||
|
type: DataTypes.DATE
|
||||||
|
},
|
||||||
}, {
|
}, {
|
||||||
sequelize,
|
sequelize,
|
||||||
modelName: 'Torrent',
|
modelName: 'Torrent',
|
||||||
|
|||||||
2126
package-lock.json
generated
2126
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -7,7 +7,7 @@
|
|||||||
var make = function( element ){
|
var make = function( element ){
|
||||||
|
|
||||||
//construct array
|
//construct array
|
||||||
function makeArray( input ){
|
function makeArray( input , index ){
|
||||||
|
|
||||||
var result = [];
|
var result = [];
|
||||||
|
|
||||||
@@ -25,6 +25,20 @@
|
|||||||
configurable: true
|
configurable: true
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
Object.defineProperty( result, "__jq_index", {
|
||||||
|
value: index,
|
||||||
|
writable: true,
|
||||||
|
enumerable: false,
|
||||||
|
configurable: true
|
||||||
|
} );
|
||||||
|
|
||||||
|
function removeEmpty(){
|
||||||
|
if(result.__jq_empty){
|
||||||
|
result.__jq_empty.remove();
|
||||||
|
delete result.__jq_empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
result.splice = function(inputValue, ...args){
|
result.splice = function(inputValue, ...args){
|
||||||
//splice does all the heavy lifting by interacting with the DOM elements.
|
//splice does all the heavy lifting by interacting with the DOM elements.
|
||||||
|
|
||||||
@@ -88,6 +102,7 @@
|
|||||||
|
|
||||||
//if there are fields to add to the array, add them
|
//if there are fields to add to the array, add them
|
||||||
if( toAdd.length > 0 ){
|
if( toAdd.length > 0 ){
|
||||||
|
removeEmpty()
|
||||||
|
|
||||||
//$.each( toAdd, function( key, value ){
|
//$.each( toAdd, function( key, value ){
|
||||||
for(var I = 0; I < toAdd.length; I++){
|
for(var I = 0; I < toAdd.length; I++){
|
||||||
@@ -176,7 +191,7 @@
|
|||||||
result.indexOf = function( key, value ){
|
result.indexOf = function( key, value ){
|
||||||
if( !value ){
|
if( !value ){
|
||||||
value = arguments[0];
|
value = arguments[0];
|
||||||
key = this.__index;
|
key = this.__jq_index;
|
||||||
}
|
}
|
||||||
for ( var index = 0; index < this.length; ++index ) {
|
for ( var index = 0; index < this.length; ++index ) {
|
||||||
if( this[index][key] === value ){
|
if( this[index][key] === value ){
|
||||||
@@ -200,7 +215,7 @@
|
|||||||
if( !update ){
|
if( !update ){
|
||||||
update = arguments[1];
|
update = arguments[1];
|
||||||
value = arguments[0];
|
value = arguments[0];
|
||||||
key = this.__index;
|
key = this.__jq_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
var index = this.indexOf( key, value );
|
var index = this.indexOf( key, value );
|
||||||
@@ -226,7 +241,7 @@
|
|||||||
if( type === 'object' ){
|
if( type === 'object' ){
|
||||||
result.push( value );
|
result.push( value );
|
||||||
}else if( type === 'string' ){
|
}else if( type === 'string' ){
|
||||||
Object.defineProperty( result, "__index", {
|
Object.defineProperty( result, "__jq_index", {
|
||||||
value: value,
|
value: value,
|
||||||
writable: true,
|
writable: true,
|
||||||
enumerable: false,
|
enumerable: false,
|
||||||
@@ -248,19 +263,23 @@
|
|||||||
|
|
||||||
var $this = $( element );
|
var $this = $( element );
|
||||||
var repeatId = $this.attr( 'jq-repeat' );
|
var repeatId = $this.attr( 'jq-repeat' );
|
||||||
|
var index = $this.attr( 'jq-repeat-index' );
|
||||||
var tempId = repeatId + 'Template';
|
var tempId = repeatId + 'Template';
|
||||||
var templateId = $( '#' + tempId ).html();
|
var templateId = $( '#' + tempId ).html();
|
||||||
|
var empty = $(`[jq-repeat-defualt="${repeatId}"]`);
|
||||||
|
|
||||||
|
|
||||||
$this.removeAttr( 'jq-repeat' );
|
$this.removeAttr( 'jq-repeat' );
|
||||||
|
$this.removeAttr( 'jq-repeat-index' );
|
||||||
var template = element.outerHTML
|
var template = element.outerHTML
|
||||||
|
|
||||||
$this.replaceWith( '<script type="x-tmpl-mustache" id="' + tempId + '" class="jq-repeat-' + repeatId + ' " jq-repeat-index="holder"><\/script>' );
|
$this.replaceWith( '<script type="x-tmpl-mustache" id="' + tempId + '" class="jq-repeat-' + repeatId + ' " jq-repeat-index="holder"><\/script>' );
|
||||||
|
|
||||||
Mustache.parse(templateId); // optional, speeds up future uses
|
Mustache.parse(templateId); // optional, speeds up future uses
|
||||||
|
|
||||||
|
$.scope[repeatId] = makeArray($.scope[repeatId], index);
|
||||||
$.scope[repeatId] = makeArray($.scope[repeatId]);
|
$.scope[repeatId].__rq_template = template;
|
||||||
$.scope[repeatId].__rq_template = template
|
$.scope[repeatId].__jq_empty = empty;
|
||||||
};
|
};
|
||||||
|
|
||||||
$( document ).ready( function(){
|
$( document ).ready( function(){
|
||||||
|
|||||||
@@ -8,6 +8,9 @@
|
|||||||
<script src="/__static/js/app.js"></script>
|
<script src="/__static/js/app.js"></script>
|
||||||
|
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
|
.ui-dialog{
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
.ui-dialog .ui-dialog-title{
|
.ui-dialog .ui-dialog-title{
|
||||||
width: unset;
|
width: unset;
|
||||||
}
|
}
|
||||||
@@ -52,6 +55,8 @@
|
|||||||
|
|
||||||
<!--
|
<!--
|
||||||
Dialog boxes to be displayed
|
Dialog boxes to be displayed
|
||||||
|
|
||||||
|
Login Dialog
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<div id="tbp_proxy_login_dialog" title="SSO Login">
|
<div id="tbp_proxy_login_dialog" title="SSO Login">
|
||||||
@@ -99,59 +104,94 @@
|
|||||||
#tbp_proxy_torrent_dialog{
|
#tbp_proxy_torrent_dialog{
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#tbp_proxy_torrent_dialog progress{
|
#tbp_proxy_torrent_dialog progress{
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 2em;
|
height: 2em;
|
||||||
}
|
}
|
||||||
|
|
||||||
#tbp_proxy_torrent_dialog ul{
|
#tbp_proxy_torrent_dialog ul{
|
||||||
max-height: 400px;
|
height: 400px;
|
||||||
overflow-y: scroll;
|
/*overflow-y: scroll;*/
|
||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
padding-left: 0;
|
padding-left: 0;
|
||||||
|
margin-top: 0;
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#tbp_proxy_torrent_dialog li{
|
#tbp_proxy_torrent_dialog li{
|
||||||
padding-left: 1em;
|
padding-left: 1em;
|
||||||
padding-right: 1em;
|
padding-right: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#tbp_proxy_torrent_dialog li p{
|
||||||
|
margin: .3em;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<div id="tbp_proxy_torrent_dialog" title="Torrents">
|
<div id="tbp_proxy_torrent_dialog" title="Torrents">
|
||||||
<ul>
|
<ul>
|
||||||
<li jq-repeat="tbp_proxy_torrent_dialog_torrents">{{name}}
|
<li jq-repeat="tbp_proxy_torrent_dialog_torrents" jq-repeat-index="hashString">
|
||||||
<br />
|
<p>
|
||||||
|
<b>{{name}}</b> - <i>{{statusText}}</i>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Is <b>{{sizeWhenDone}}</b>
|
||||||
|
saved to <b>{{downloadDir}}</b>
|
||||||
|
added by <b>{{added_by}}</b>
|
||||||
|
<b>{{createdAtString}}</b>
|
||||||
|
</p>
|
||||||
|
|
||||||
{{^isFinished}}
|
{{^isFinished}}
|
||||||
|
<p>
|
||||||
<progress id="file" max="100" value="{{percentDone}}">{{percentDone}}%</progress>
|
<progress id="file" max="100" value="{{percentDone}}">{{percentDone}}%</progress>
|
||||||
<br />
|
</p>
|
||||||
<b>{{statusText}}</b> @ <b>{{rateDownload}}</b> finishing <b>{{eta}}</b>
|
|
||||||
<br />
|
|
||||||
{{^isActive}}
|
|
||||||
<button class="ui-button ui-widget ui-corner-all" onclick="app.torrent.start({{id}})">
|
|
||||||
<span class="ui-icon ui-icon-play"></span> Start
|
|
||||||
</button>
|
|
||||||
{{/isActive}}
|
|
||||||
|
|
||||||
{{#isActive}}
|
{{#isActive}}
|
||||||
<button class="ui-button ui-widget ui-corner-all" onclick="app.torrent.stop({{id}})">
|
<p>
|
||||||
|
<b>{{rateDownload}}</b>
|
||||||
|
Finishing <b>{{eta}}</b>
|
||||||
|
From <b>{{peersConnected}}</b> Peers
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<button class="ui-button ui-widget ui-corner-all" onclick="app.torrent.stop({{hashString}})">
|
||||||
<span class="ui-icon ui-icon-pause"></span>Pause
|
<span class="ui-icon ui-icon-pause"></span>Pause
|
||||||
</button>
|
</button>
|
||||||
{{/isActive}}
|
{{/isActive}}
|
||||||
|
|
||||||
|
{{^isActive}}
|
||||||
|
<button class="ui-button ui-widget ui-corner-all" onclick="app.torrent.start({{hashString}})">
|
||||||
|
<span class="ui-icon ui-icon-play"></span> Start
|
||||||
|
</button>
|
||||||
|
{{/isActive}}
|
||||||
|
|
||||||
<button class="ui-button ui-widget ui-corner-all" onclick="
|
<button class="ui-button ui-widget ui-corner-all" onclick="
|
||||||
app.torrent.destroy({{id}}, function(error, data){
|
app.torrent.destroy({{hashString}}, function(error, data){
|
||||||
$.scope.tbp_proxy_torrent_dialog_torrents.splice({{__id}}, 1);
|
$.scope.tbp_proxy_torrent_dialog_torrents.splice({{__id}}, 1);
|
||||||
});
|
});
|
||||||
">
|
">
|
||||||
<span class="ui-icon ui-icon-closethick"></span>Delete
|
<span class="ui-icon ui-icon-closethick"></span>Delete
|
||||||
</button>
|
</button>
|
||||||
|
</p>
|
||||||
{{/isFinished}}
|
{{/isFinished}}
|
||||||
|
|
||||||
|
{{#errorString}}
|
||||||
|
<p>
|
||||||
|
<b>{{errorString}}</b>
|
||||||
|
</p>
|
||||||
|
{{/errorString}}
|
||||||
|
|
||||||
{{#isFinished}}
|
{{#isFinished}}
|
||||||
<br /> Done! <a href="https://stuff.718it.biz/torrents/{{name}}" target="_blank"> HTTP Link</a>
|
<p>
|
||||||
|
Done! <a href="https://stuff.718it.biz/torrents/{{name}}" target="_blank"> HTTP Link</a>
|
||||||
|
</p>
|
||||||
{{/isFinished}}
|
{{/isFinished}}
|
||||||
<hr />
|
<hr />
|
||||||
</li>
|
</li>
|
||||||
|
<li jq-repeat-defualt="tbp_proxy_torrent_dialog_torrents">
|
||||||
|
<h3> No Torrents...</h3>
|
||||||
|
<hr width="300pt" />
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -180,7 +220,8 @@
|
|||||||
<form action="torrent" method="post" onsubmit="formAJAX(this)" evalAJAX="
|
<form action="torrent" method="post" onsubmit="formAJAX(this)" evalAJAX="
|
||||||
app.publish('torrent:add', {...data, __noSocket: true});
|
app.publish('torrent:add', {...data, __noSocket: true});
|
||||||
$('#tbp_proxy_torrent_add_dialog').dialog('close');
|
$('#tbp_proxy_torrent_add_dialog').dialog('close');
|
||||||
openDialog($('#tbp_proxy_torrent_dialog'))
|
openDialog($('#tbp_proxy_torrent_dialog'));
|
||||||
|
savePrivateState(data, this);
|
||||||
">
|
">
|
||||||
<p>
|
<p>
|
||||||
<label for="_name">Name:</label>
|
<label for="_name">Name:</label>
|
||||||
@@ -195,16 +236,20 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<legend>Public Download:</legend>
|
<label for="hashString">Hash:</label>
|
||||||
|
<br />
|
||||||
<label for="radio-1" title="The download will appare in the communal download folder">Public</label>
|
<input type="text" name="hashString" value="{{{hashString}}}" readonly/>
|
||||||
<input type="radio" name="isPrivate" id="radio-1" value="true" checked readonly/>
|
|
||||||
|
|
||||||
<label for="radio-2" title="Only you(and the admins) will be able to see this download">Private</label>
|
|
||||||
<input type="radio" name="isPrivate" id="radio-2" value="false" readonly/>
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
<label for="isPrivate-false" title="The download will appare in the communal download folder">Public:</label>
|
||||||
|
<input type="radio" name="isPrivate" id="isPrivate-false" value="false" />
|
||||||
|
|
||||||
|
<label for="isPrivate-true" title="Only you(and the admins) will be able to see this download">Private:</label>
|
||||||
|
<input type="radio" name="isPrivate" id="isPrivate-true" value="true" />
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p style="display:none">
|
||||||
<legend>Start on add:</legend>
|
<legend>Start on add:</legend>
|
||||||
|
|
||||||
<label for="isStart-1" title="The download will appare in the communal download folder">Yes</label>
|
<label for="isStart-1" title="The download will appare in the communal download folder">Yes</label>
|
||||||
@@ -216,7 +261,7 @@
|
|||||||
|
|
||||||
<hr />
|
<hr />
|
||||||
<button type="submit">Start Download</button>
|
<button type="submit">Start Download</button>
|
||||||
<button onclick="$('#tbp_proxy_torrent_add_dialog').dialog('close')">Cancel</button>
|
<button type="reset" onclick="$('#tbp_proxy_torrent_add_dialog').dialog('close')">Cancel</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -224,14 +269,14 @@
|
|||||||
|
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
The bar injected at the top of the page
|
Injected Header bar
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<div id="tbp_proxy_header_right">
|
<div id="tbp_proxy_header_right">
|
||||||
<span id="tbp_proxy_torrent_dialog_opener" class="tbp_proxy_is_authed">
|
<span id="tbp_proxy_torrent_dialog_opener" class="tbp_proxy_is_authed">
|
||||||
<img src="/__static/img/Transmission_Icon.svg" height="22" width="22" style="margin-right: .3em;" />
|
<img src="/__static/img/Transmission_Icon.svg" height="22" width="22" style="margin-right: .3em;" />
|
||||||
<span jq-repeat="tbp_proxy_torrent_dialog_opener_status">
|
<span jq-repeat="tbp_proxy_torrent_dialog_opener_status">
|
||||||
<b> <span class="ui-icon ui-icon-arrowthick-1-n"></span>{{downloadSpeed}} <span class="ui-icon ui-icon-arrowthick-1-s"></span>{{uploadSpeed}}</b>
|
<b> <span class="ui-icon ui-icon-arrowthick-1-s"></span>{{downloadSpeed}} <span class="ui-icon ui-icon-arrowthick-1-n"></span>{{uploadSpeed}}</b>
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
<button id="tbp_proxy_login_dialog_opener" class="tbp_proxy_not_authed ui-button ui-corner-all ui-widget">Login</button>
|
<button id="tbp_proxy_login_dialog_opener" class="tbp_proxy_not_authed ui-button ui-corner-all ui-widget">Login</button>
|
||||||
@@ -242,84 +287,109 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
var commonDialogOptions = {
|
var commonDialogOptions = {
|
||||||
position: { my: "left top", at: "left bottom", of: '#tbp_proxy_header_right' },
|
position: { my: 'left top', at: 'left bottom', of: '#tbp_proxy_header_right' },
|
||||||
autoOpen: false,
|
autoOpen: false,
|
||||||
resizable: false,
|
resizable: false,
|
||||||
closeOnEscape: true,
|
closeOnEscape: true,
|
||||||
draggable: false,
|
draggable: false,
|
||||||
width: 'auto',
|
// maxWidth: document.body.clientWidth,
|
||||||
|
// width: 'auto',
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Login Button and dialog*/
|
/* Login Button and dialog*/
|
||||||
$( "#tbp_proxy_login_dialog" ).dialog(commonDialogOptions);
|
$('#tbp_proxy_login_dialog').dialog(commonDialogOptions);
|
||||||
|
|
||||||
$( "#tbp_proxy_login_dialog_opener" ).on( "click", function() {
|
$('#tbp_proxy_login_dialog_opener').on('click', function() {
|
||||||
// https://stackoverflow.com/a/6500385
|
openDialog($('#tbp_proxy_login_dialog'));
|
||||||
$( "#tbp_proxy_login_dialog" ).parent().css({position:"fixed", 'margin-right': "2em", 'margin-top': '3em'}).end().dialog( "open" );
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/* Torrent list button and dialog */
|
/* Torrent list button and dialog */
|
||||||
$( "#tbp_proxy_torrent_dialog" ).dialog(commonDialogOptions);
|
$('#tbp_proxy_torrent_dialog').dialog(commonDialogOptions);
|
||||||
|
|
||||||
$( "#tbp_proxy_torrent_dialog_opener" ).on( "click", function() {
|
$('#tbp_proxy_torrent_dialog_opener').on('click', function() {
|
||||||
$( "#tbp_proxy_torrent_dialog" ).parent().css({position:"fixed", 'margin-right': "2em", 'margin-top': '3em'}).end().dialog( "open" );
|
if($('#tbp_proxy_torrent_dialog').dialog('isOpen')){
|
||||||
|
$('#tbp_proxy_torrent_dialog').dialog('close')
|
||||||
|
}else{
|
||||||
|
openDialog($('#tbp_proxy_torrent_dialog'));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/* Torrent add button and dialog */
|
/* Torrent add button and dialog */
|
||||||
$( "#tbp_proxy_torrent_add_dialog" ).dialog({
|
$('#tbp_proxy_torrent_add_dialog').dialog(commonDialogOptions);
|
||||||
modal: true,
|
|
||||||
height: 300,
|
|
||||||
...commonDialogOptions
|
|
||||||
});
|
|
||||||
|
|
||||||
$("body").on('click', 'img.718link', function(el){
|
|
||||||
// magnetLink
|
|
||||||
$.scope.torrentAdd.update({
|
|
||||||
magnetLink: $(this).data('link'),
|
|
||||||
name: (new URLSearchParams($(this).data('link'))).get('dn')
|
|
||||||
});
|
|
||||||
$('#tbp_proxy_torrent_add_dialog').parent().css({position:"fixed", 'margin-right': "2em", 'margin-top': '3em'}).end().dialog('open');
|
|
||||||
});
|
|
||||||
|
|
||||||
$('a').each(function(idx, el){
|
|
||||||
var $el = $(el);
|
|
||||||
if($el.attr('href') && $el.attr('href').match("magnet:?")){
|
|
||||||
$el.before('<img class="tbp_proxy_is_authed 718link" src="/__static/img/Transmission_Icon.svg" height=24 width=24 data-link="'+$el.attr('href')+'"/>')
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/* Enable tooltips*/
|
/* Enable tooltips*/
|
||||||
$('#tbp_proxy_header').tooltip({
|
$('#tbp_proxy_header').tooltip({
|
||||||
track: true
|
track: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.auth.isLoggedIn(function(error, data){
|
||||||
|
if(data){
|
||||||
|
|
||||||
|
$('body').on('click', 'img.718link', function(event){
|
||||||
|
// magnetLink
|
||||||
|
let magnetLinkParams = new URLSearchParams($(this).data('link'));
|
||||||
|
|
||||||
|
$.scope.torrentAdd.update({
|
||||||
|
magnetLink: $(this).data('link'),
|
||||||
|
name: magnetLinkParams.get('dn'),
|
||||||
|
hashString: magnetLinkParams.get('magnet:?xt').split(':').pop().toLowerCase(),
|
||||||
|
});
|
||||||
|
|
||||||
|
if(localStorage.getItem('isPrivate') === 'true'){
|
||||||
|
$('#isPrivate-true').prop('checked', true);
|
||||||
|
}else{
|
||||||
|
$('#isPrivate-false').prop('checked', true);
|
||||||
|
}
|
||||||
|
|
||||||
|
openDialog($('#tbp_proxy_torrent_add_dialog'));
|
||||||
|
});
|
||||||
|
|
||||||
|
// Look for
|
||||||
|
$('a').each(function(idx, el){
|
||||||
|
var $el = $(el);
|
||||||
|
if($el.attr('href') && $el.attr('href').match('magnet:?')){
|
||||||
|
$el.before(`<img class="tbp_proxy_is_authed 718link" src="/__static/img/Transmission_Icon.svg" height=24 width=24 data-link="${$el.attr('href')}"/>`)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
app.subscribe('torrent:add', function(data, topic){
|
app.subscribe('torrent:add', function(data, topic){
|
||||||
console.log('sub', topic, data)
|
|
||||||
$.scope.tbp_proxy_torrent_dialog_torrents.unshift(app.torrent.parseTorrnetItem(data))
|
$.scope.tbp_proxy_torrent_dialog_torrents.unshift(app.torrent.parseTorrnetItem(data))
|
||||||
});
|
});
|
||||||
|
|
||||||
app.subscribe('torrent:server:status', function(data, topic){
|
app.subscribe('torrent:server:status', function(data, topic){
|
||||||
app.torrent.isDown = false
|
app.torrent.isDown = false
|
||||||
$('#tbp_proxy_torrent_dialog_opener').css('background', "lightseagreen")
|
$('#tbp_proxy_torrent_dialog_opener').css('background', 'lightseagreen')
|
||||||
$.scope.tbp_proxy_torrent_dialog_opener_status.update(app.torrent.parseServerStatus(data));
|
$.scope.tbp_proxy_torrent_dialog_opener_status.update(app.torrent.parseServerStatus(data));
|
||||||
});
|
});
|
||||||
|
|
||||||
app.subscribe(`app:api:error:555`, function(data, topics){
|
app.subscribe('app:api:error:555', function(data, topics){
|
||||||
console.log('we down')
|
|
||||||
app.torrent.isDown = true
|
app.torrent.isDown = true
|
||||||
$('#tbp_proxy_torrent_dialog_opener').css('background', "red")
|
$('#tbp_proxy_torrent_dialog_opener').css('background', 'red')
|
||||||
});
|
});
|
||||||
|
|
||||||
app.subscribe('torrent:server:status:down', function(data, topic){
|
app.subscribe('torrent:server:status:down', function(data, topic){
|
||||||
app.torrent.isDown = true
|
app.torrent.isDown = true
|
||||||
$('#tbp_proxy_torrent_dialog_opener').css('background', "red")
|
$('#tbp_proxy_torrent_dialog_opener').css('background', 'red')
|
||||||
});
|
});
|
||||||
|
|
||||||
listTorrents();
|
listTorrents();
|
||||||
setInterval(refreshTorrents, 5000)
|
setInterval(refreshTorrents, 1000);
|
||||||
|
app.torrent.migrate();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function savePrivateState(data){
|
||||||
|
localStorage.setItem('isPrivate', data.isPrivate);
|
||||||
|
if(data.isPrivate){
|
||||||
|
$('#isPrivate-true').prop('checked', true);
|
||||||
|
} else {
|
||||||
|
$('#isPrivate-false').prop('checked', true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function humanFileSize(size) {
|
function humanFileSize(size) {
|
||||||
var i = size == 0 ? 0 : Math.floor(Math.log(size) / Math.log(1024));
|
var i = size == 0 ? 0 : Math.floor(Math.log(size) / Math.log(1024));
|
||||||
@@ -327,18 +397,21 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function openDialog($el){
|
function openDialog($el){
|
||||||
|
// https://stackoverflow.com/a/6500385
|
||||||
$el.parent().css({
|
$el.parent().css({
|
||||||
position:"fixed", 'margin-right': "2em", 'margin-top': '3em'
|
position: 'fixed',
|
||||||
|
'margin-right': '2em',
|
||||||
|
'margin-top': '3em'
|
||||||
}).end().dialog('open');
|
}).end().dialog('open');
|
||||||
}
|
}
|
||||||
|
|
||||||
function listTorrents(){
|
function listTorrents(){
|
||||||
app.torrent.list(function(err, data){
|
app.torrent.list(function(err, data){
|
||||||
for(let torrent of data.results){
|
for(let torrent of data.results){
|
||||||
$.scope.tbp_proxy_torrent_dialog_torrents.unshift(app.torrent.parseTorrnetItem(torrent))
|
$.scope.tbp_proxy_torrent_dialog_torrents.push(app.torrent.parseTorrnetItem(torrent))
|
||||||
app.torrent.get(function(error, torrent){
|
if(torrent.percentDone !== 1) app.torrent.get(function(error, torrent){
|
||||||
$.scope.tbp_proxy_torrent_dialog_torrents.update('id', torrent.result.id, app.torrent.parseTorrnetItem(torrent.result))
|
$.scope.tbp_proxy_torrent_dialog_torrents.update('hashString', torrent.result.hashString, app.torrent.parseTorrnetItem(torrent.result))
|
||||||
} , torrent.id, true)
|
} , torrent.hashString, true)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -347,8 +420,8 @@
|
|||||||
for(let torrent of $.scope.tbp_proxy_torrent_dialog_torrents){
|
for(let torrent of $.scope.tbp_proxy_torrent_dialog_torrents){
|
||||||
if(!torrent.isFinished){
|
if(!torrent.isFinished){
|
||||||
app.torrent.get(function(error, torrent){
|
app.torrent.get(function(error, torrent){
|
||||||
$.scope.tbp_proxy_torrent_dialog_torrents.update('id', torrent.result.id, app.torrent.parseTorrnetItem(torrent.result))
|
$.scope.tbp_proxy_torrent_dialog_torrents.update('hashString', torrent.result.hashString, app.torrent.parseTorrnetItem(torrent.result))
|
||||||
} , torrent.id, true)
|
} , torrent.hashString, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -356,13 +429,11 @@
|
|||||||
app.torrent = (function(app){
|
app.torrent = (function(app){
|
||||||
let isDown = false;
|
let isDown = false;
|
||||||
|
|
||||||
$( document ).on( "ajaxSend", function(event, ajax, res, ...args) {
|
// Dont spam the server if its not online
|
||||||
console.log('right?', res.url, res.url.startsWith('/__api/torrent'), app.torrent.isDown)
|
$(document).on('ajaxSend', function(event, ajax, res, ...args) {
|
||||||
if(res.url.startsWith('/__api/torrent') && isDown){
|
if(res.url.startsWith('/__api/torrent') && isDown){
|
||||||
ajax.abort()
|
ajax.abort();
|
||||||
}
|
}
|
||||||
// $( ".log" ).text( "Triggered ajaxStart handler." );
|
|
||||||
// throw new Error('go')
|
|
||||||
});
|
});
|
||||||
|
|
||||||
statusMap = [
|
statusMap = [
|
||||||
@@ -377,7 +448,6 @@
|
|||||||
'Unknown', // 8
|
'Unknown', // 8
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
function list(callback, username) {
|
function list(callback, username) {
|
||||||
app.api.get('torrent', function(error, data){
|
app.api.get('torrent', function(error, data){
|
||||||
if(error) return;
|
if(error) return;
|
||||||
@@ -385,29 +455,29 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function get(callback, id, forceUpdate){
|
function get(callback, hashString, forceUpdate){
|
||||||
app.api.get(`torrent/${id}?${forceUpdate ? 'latest': '' }`, function(error, data){
|
app.api.get(`torrent/${hashString}?${forceUpdate ? 'latest': '' }`, function(error, data){
|
||||||
if(error) return;
|
if(error) return;
|
||||||
callback(null, data)
|
callback(null, data)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function start(id, callback){
|
function start(hashString, callback){
|
||||||
app.api.post(`torrent/${id}/start`, function(error, data){
|
app.api.post(`torrent/${hashString}/start`, function(error, data){
|
||||||
if(error) return;
|
if(error) return;
|
||||||
callback(null, data)
|
callback(null, data)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function stop(id, callback){
|
function stop(hashString, callback){
|
||||||
app.api.post(`torrent/${id}/stop`, function(error, data){
|
app.api.post(`torrent/${hashString}/stop`, function(error, data){
|
||||||
if(error) return;
|
if(error) return;
|
||||||
callback(null, data)
|
callback(null, data)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function destroy(id, callback){
|
function destroy(hashString, callback){
|
||||||
app.api.delete(`torrent/${id}`, function(error, data){
|
app.api.delete(`torrent/${hashString}`, function(error, data){
|
||||||
if(error) return;
|
if(error) return;
|
||||||
callback(null, data)
|
callback(null, data)
|
||||||
});
|
});
|
||||||
@@ -418,7 +488,7 @@
|
|||||||
...data,
|
...data,
|
||||||
"downloadSpeed": humanFileSize(data.downloadSpeed)+'/s',
|
"downloadSpeed": humanFileSize(data.downloadSpeed)+'/s',
|
||||||
"uploadSpeed": humanFileSize(data.uploadSpeed)+'/s',
|
"uploadSpeed": humanFileSize(data.uploadSpeed)+'/s',
|
||||||
/* "activeTorrentCount": 11,
|
/* 'activeTorrentCount": 11,
|
||||||
"cumulative-stats": {
|
"cumulative-stats": {
|
||||||
"downloadedBytes": 2925927098021,
|
"downloadedBytes": 2925927098021,
|
||||||
"filesAdded": 80609,
|
"filesAdded": 80609,
|
||||||
@@ -452,29 +522,26 @@
|
|||||||
"isFinished": torrent.isFinished || percentDone === 100,
|
"isFinished": torrent.isFinished || percentDone === 100,
|
||||||
"createdAtString": moment(torrent.createdAt).fromNow(),
|
"createdAtString": moment(torrent.createdAt).fromNow(),
|
||||||
|
|
||||||
// "isFinished": false,
|
|
||||||
// "isStalled": false,
|
|
||||||
// "name": "reacher.s02e06.1080p.web.h264-successfulcrab[EZTVx.to].mkv",
|
|
||||||
// "hashString": "4794a0915cada6c491eb5c910e1f4a0da727cac8",
|
|
||||||
// "status": 4,
|
|
||||||
// "id": 1,
|
|
||||||
|
|
||||||
// "peersConnected": 50,
|
|
||||||
// "added_by": "wmantly",
|
|
||||||
// "errorString": "",
|
|
||||||
|
|
||||||
// "downloadDir": "/media/torrents",
|
|
||||||
// "files": [],
|
|
||||||
// "peers": [],
|
|
||||||
// "magnetLink": "magnet:?xt=urn:btih:4794A0915CADA6C491EB5C910E1F4A0DA727CAC8&dn=Reacher+S02E06+1080p+WEB+H264-SuccessfulCrab&tr=http%3A%2F%2Fp4p.arenabg.com%3A1337%2Fannounce&tr=udp%3A%2F%2F47.ip-51-68-199.eu%3A6969%2Fannounce&tr=udp%3A%2F%2F9.rarbg.me%3A2780%2Fannounce&tr=udp%3A%2F%2F9.rarbg.to%3A2710%2Fannounce&tr=udp%3A%2F%2F9.rarbg.to%3A2730%2Fannounce&tr=udp%3A%2F%2F9.rarbg.to%3A2920%2Fannounce&tr=udp%3A%2F%2Fopen.stealth.si%3A80%2Fannounce&tr=udp%3A%2F%2Fopentracker.i2p.rocks%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.cyberia.is%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.dler.org%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.internetwarriors.net%3A1337%2Fannounce&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=udp%3A%2F%2Ftracker.pirateparty.gr%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.tiny-vps.com%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.torrent.eu.org%3A451%2Fannounce",
|
|
||||||
// "isPrivate": false,
|
|
||||||
// "createdAt": "2024-01-05T21:18:30.607Z",
|
|
||||||
// "updatedAt": "2024-01-05T21:32:54.493Z"
|
|
||||||
// "torrent_id": "454",
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {list, get, start, stop, destroy, parseTorrnetItem, parseServerStatus, isDown};
|
function migrate(){
|
||||||
|
let torrents = JSON.parse(window.localStorage.getItem('torrents') || '{}').list || [];
|
||||||
|
|
||||||
|
if(torrents.length){
|
||||||
|
console.log(`Migrating ${torrents.length}`)
|
||||||
|
for(let torrent of torrents){
|
||||||
|
app.api.post(`torrent/${torrent.hashString}`, {}, function(error, torrent) {
|
||||||
|
if(Object.keys(torrent).length){
|
||||||
|
$.scope.tbp_proxy_torrent_dialog_torrents.unshift(app.torrent.parseTorrnetItem(torrent))
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
localStorage.removeItem('torrents',);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {list, get, start, stop, destroy, migrate, parseTorrnetItem, parseServerStatus, isDown};
|
||||||
})(app);
|
})(app);
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -22,7 +22,12 @@ const proxyTarget = {
|
|||||||
target: 'https://piratebay.party',
|
target: 'https://piratebay.party',
|
||||||
host: 'piratebay.party',
|
host: 'piratebay.party',
|
||||||
// target: 'http://172.16.0.1',
|
// target: 'http://172.16.0.1',
|
||||||
|
// target: 'http://piratebayo3klnzokct3wt5yyxb2vpebbuyjl7m623iaxmqhsd52coid.onion',
|
||||||
// host: 'piratebayo3klnzokct3wt5yyxb2vpebbuyjl7m623iaxmqhsd52coid.onion'
|
// host: 'piratebayo3klnzokct3wt5yyxb2vpebbuyjl7m623iaxmqhsd52coid.onion'
|
||||||
|
// target: 'https://thepiratebay.org',
|
||||||
|
// host: 'thepiratebay.org',
|
||||||
|
// target: 'https://www2.thepiratebay3.to',
|
||||||
|
// host: 'www2.thepiratebay3.to'
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateRegexForDomain(domain) {
|
function generateRegexForDomain(domain) {
|
||||||
@@ -38,12 +43,13 @@ function generateRegexForDomain(domain) {
|
|||||||
router.all("/*", proxy({
|
router.all("/*", proxy({
|
||||||
target: proxyTarget.target,
|
target: proxyTarget.target,
|
||||||
agent: proxyTarget.target.startsWith('https') ? https.globalAgent : http.globalAgent,
|
agent: proxyTarget.target.startsWith('https') ? https.globalAgent : http.globalAgent,
|
||||||
secure: false,
|
secure: true,
|
||||||
autoRewrite: true,
|
autoRewrite: true,
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
followRedirects: true,
|
followRedirects: true,
|
||||||
headers: {
|
headers: {
|
||||||
host: proxyTarget.host
|
host: proxyTarget.host,
|
||||||
|
'Accept-Encoding': 'gzip',
|
||||||
},
|
},
|
||||||
selfHandleResponse: true, // so that the onProxyRes takes care of sending the response
|
selfHandleResponse: true, // so that the onProxyRes takes care of sending the response
|
||||||
onProxyRes: function(proxyRes, req, res){
|
onProxyRes: function(proxyRes, req, res){
|
||||||
@@ -54,7 +60,7 @@ router.all("/*", proxy({
|
|||||||
console.log('403')
|
console.log('403')
|
||||||
var url = (req.protocol + '://' + req.get('host') + req.originalUrl);
|
var url = (req.protocol + '://' + req.get('host') + req.originalUrl);
|
||||||
proxyRes.headers['location'] = url.replace(/\??ckattempt\=\d+/, '');
|
proxyRes.headers['location'] = url.replace(/\??ckattempt\=\d+/, '');
|
||||||
proxyRes.statusCode == 307
|
proxyRes.statusCode = 307;
|
||||||
|
|
||||||
return res.end()
|
return res.end()
|
||||||
}
|
}
|
||||||
@@ -74,6 +80,7 @@ router.all("/*", proxy({
|
|||||||
});
|
});
|
||||||
|
|
||||||
proxyRes.on('end', function(){
|
proxyRes.on('end', function(){
|
||||||
|
// console.log("proxyRes.headers['content-encoding']", proxyRes.headers['content-encoding']);
|
||||||
body = proxyRes.headers['content-encoding'] === 'gzip' ? zlib.gunzipSync(body).toString('utf8') : body;
|
body = proxyRes.headers['content-encoding'] === 'gzip' ? zlib.gunzipSync(body).toString('utf8') : body;
|
||||||
body = proxyRes.headers['content-encoding'] === 'br' ? zlib.brotliDecompressSync(body).toString('utf8') : body;
|
body = proxyRes.headers['content-encoding'] === 'br' ? zlib.brotliDecompressSync(body).toString('utf8') : body;
|
||||||
if(proxyRes.statusCode === 200 &&
|
if(proxyRes.statusCode === 200 &&
|
||||||
|
|||||||
@@ -8,7 +8,10 @@ router.get('/', async function(req, res, next){
|
|||||||
res.json({results: await Torrent.findAll({
|
res.json({results: await Torrent.findAll({
|
||||||
where:{added_by: req.query.username || req.user.username},
|
where:{added_by: req.query.username || req.user.username},
|
||||||
limit: req.query.limit,
|
limit: req.query.limit,
|
||||||
offset: req.query.offset
|
offset: req.query.offset,
|
||||||
|
order: [
|
||||||
|
['createdAt', 'DESC'],
|
||||||
|
],
|
||||||
})});
|
})});
|
||||||
}catch(error){
|
}catch(error){
|
||||||
next(error);
|
next(error);
|
||||||
@@ -23,6 +26,14 @@ router.post("/", async function(req, res, next){
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
router.post("/:hashString", async function(req, res, next){
|
||||||
|
try{
|
||||||
|
res.json(await Torrent.migrate(req.params.hashString, req.user.username))
|
||||||
|
}catch(error){
|
||||||
|
next(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
router.get('/server', async function(req, res, next){
|
router.get('/server', async function(req, res, next){
|
||||||
try{
|
try{
|
||||||
res.json(await Torrent.trClient.sessionStats())
|
res.json(await Torrent.trClient.sessionStats())
|
||||||
@@ -31,9 +42,9 @@ router.get('/server', async function(req, res, next){
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get("/:id", async function(req, res, next){
|
router.get("/:hashString", async function(req, res, next){
|
||||||
try{
|
try{
|
||||||
let torrent = await Torrent.findByPk(req.params.id);
|
let torrent = await Torrent.findByPk(req.params.hashString);
|
||||||
if('latest' in req.query){
|
if('latest' in req.query){
|
||||||
torrent = await torrent.getTorrentData();
|
torrent = await torrent.getTorrentData();
|
||||||
}
|
}
|
||||||
@@ -43,9 +54,9 @@ router.get("/:id", async function(req, res, next){
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
router.delete("/:id", async function(req, res, next){
|
router.delete("/:hashString", async function(req, res, next){
|
||||||
try{
|
try{
|
||||||
let torrent = await Torrent.findByPk(req.params.id);
|
let torrent = await Torrent.findByPk(req.params.hashString);
|
||||||
|
|
||||||
res.json({result: torrent, activity: await torrent.destroy()});
|
res.json({result: torrent, activity: await torrent.destroy()});
|
||||||
}catch(error){
|
}catch(error){
|
||||||
@@ -53,9 +64,9 @@ router.delete("/:id", async function(req, res, next){
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
router.post("/:id/stop", async function(req, res, next){
|
router.post("/:hashString/stop", async function(req, res, next){
|
||||||
try{
|
try{
|
||||||
let torrent = await Torrent.findByPk(req.params.id);
|
let torrent = await Torrent.findByPk(req.params.hashString);
|
||||||
|
|
||||||
res.json({result: torrent, activity: await torrent.stop()});
|
res.json({result: torrent, activity: await torrent.stop()});
|
||||||
}catch(error){
|
}catch(error){
|
||||||
@@ -63,9 +74,9 @@ router.post("/:id/stop", async function(req, res, next){
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
router.post("/:id/start", async function(req, res, next){
|
router.post("/:hashString/start", async function(req, res, next){
|
||||||
try{
|
try{
|
||||||
let torrent = await Torrent.findByPk(req.params.id);
|
let torrent = await Torrent.findByPk(req.params.hashString);
|
||||||
|
|
||||||
res.json({result: torrent, activity: await torrent.start()});
|
res.json({result: torrent, activity: await torrent.start()});
|
||||||
}catch(error){
|
}catch(error){
|
||||||
|
|||||||
Reference in New Issue
Block a user