feat(gui): trackers basic display

This commit is contained in:
Alexey Kasyanchuk 2018-08-15 12:38:19 +03:00
parent 17371bd8ff
commit 7cf5c17fe4
7 changed files with 42 additions and 12 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

View File

@ -11,6 +11,9 @@ import LinearProgress from 'material-ui/LinearProgress';
let rating = require('./rating'); let rating = require('./rating');
import scrollBack from './remember-scroll' import scrollBack from './remember-scroll'
import RutrackerIcon from './images/strategies/rutracker.png'
import NyaaIcon from './images/strategies/nyaa.jpg'
const contentIcon = (type, category, fill = 'grey') => { const contentIcon = (type, category, fill = 'grey') => {
if(category == 'xxx') if(category == 'xxx')
{ {
@ -358,6 +361,13 @@ export default class Torrent extends Component {
} }
</div> </div>
} }
<div>
{
torrent.info && torrent.info.trackers && torrent.info.trackers.includes('rutracker')
&&
<img src={RutrackerIcon} style={{height: 32}} />
}
</div>
</div> </div>
</a> </a>
} }

View File

@ -119,7 +119,7 @@ const expand = (sphinx) => {
}) })
sphinx.replaceValues = (table, values, options = {}, callback = () => {}) => new Promise((resolve) => { sphinx.replaceValues = (table, values, options = {}, callback = () => {}) => new Promise((resolve) => {
const {particial, key, merge, mergeCallback} = Object.assign({ const {particial, key, merge, mergeCallback, sphinxIndex} = Object.assign({
particial: true, particial: true,
key: 'id' key: 'id'
}, options) }, options)
@ -128,6 +128,10 @@ const expand = (sphinx) => {
let names = ''; let names = '';
let data = ''; let data = '';
const parseValues = (values) => { const parseValues = (values) => {
if(sphinxIndex)
for(const k in sphinxIndex)
values[k] = values[sphinxIndex[k]]
let valuesData = '' let valuesData = ''
names = '' names = ''
for(const val in values) for(const val in values)

View File

@ -116,13 +116,18 @@ module.exports = function (send, recive, dataDirectory, version, env)
return return
logT('tracker', 'found', name, 'on', tracker) logT('tracker', 'found', name, 'on', tracker)
this.sphinx.replaceValues('torrents', {hash, info: data}, {particial: true, key: 'hash', merge: ['info'], mergeCallback: (n, obj) => { this.sphinx.replaceValues('torrents', {hash, info: data}, {
particial: true,
key: 'hash',
sphinxIndex: {nameIndex: 'name'},
merge: ['info'],
mergeCallback: (n, obj) => {
if(n != 'info') if(n != 'info')
return return
if(!obj.trackers) if(!obj.trackers)
obj.trackers = [] obj.trackers = []
obj.trackers.push(name) obj.trackers.push(tracker)
obj.trackers = [...new Set(obj.trackers)] obj.trackers = [...new Set(obj.trackers)]
} }) } })
}) })
@ -149,6 +154,7 @@ module.exports = function (send, recive, dataDirectory, version, env)
trackersChecked: row.trackersChecked ? row.trackersChecked.getTime() : undefined, trackersChecked: row.trackersChecked ? row.trackersChecked.getTime() : undefined,
good: row.good, good: row.good,
bad: row.bad, bad: row.bad,
info: typeof row.info == 'string' && row.info.length > 0 ? JSON.parse(row.info) : undefined
} }
} }

View File

@ -14,7 +14,12 @@ module.exports = class Nyaa
async parse() async parse()
{ {
let html = await fetch('https://nyaa.si/' + (this.threadId ? `view/${this.threadId}` : (this.hash ? `?q=${this.hash}` : ''))) let html;
try {
html = await fetch('https://nyaa.si/' + (this.threadId ? `view/${this.threadId}` : (this.hash ? `?q=${this.hash}` : '')))
} catch(err) {
return
}
if(!html) if(!html)
return return
html = await html.text() html = await html.text()

View File

@ -14,7 +14,12 @@ module.exports = class Rutracker
async parse() async parse()
{ {
let html = await fetch('https://rutracker.org/forum/viewtopic.php?' + (this.threadId ? `t=${this.threadId}` : (this.hash ? `h=${this.hash}` : ''))) let html;
try {
html = await fetch('https://rutracker.org/forum/viewtopic.php?' + (this.threadId ? `t=${this.threadId}` : (this.hash ? `h=${this.hash}` : '')))
} catch(err) {
return
}
if(!html) if(!html)
return return
html = await html.text() html = await html.text()