feat(gui): trackers basic display
This commit is contained in:
parent
17371bd8ff
commit
7cf5c17fe4
BIN
src/app/images/strategies/nyaa.jpg
Normal file
BIN
src/app/images/strategies/nyaa.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
BIN
src/app/images/strategies/rutracker.png
Normal file
BIN
src/app/images/strategies/rutracker.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 54 KiB |
@ -11,6 +11,9 @@ import LinearProgress from 'material-ui/LinearProgress';
|
||||
let rating = require('./rating');
|
||||
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') => {
|
||||
if(category == 'xxx')
|
||||
{
|
||||
@ -250,7 +253,7 @@ export default class Torrent extends Component {
|
||||
{
|
||||
const torrent = this.props.torrent;
|
||||
if(!torrent)
|
||||
return null // can try draw null torrent (for example on downloading not started)
|
||||
return null // can try draw null torrent (for example on downloading not started)
|
||||
|
||||
let torrentRating = -1
|
||||
if(torrent.good > 0 || torrent.bad > 0)
|
||||
@ -357,7 +360,14 @@ export default class Torrent extends Component {
|
||||
<div style={{marginLeft: 5, color: 'rgb(0, 188, 212)'}}>{this.state.downloadProgress && formatBytes(this.state.downloadProgress.downloadSpeed || 0, 0)}/s</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
<div>
|
||||
{
|
||||
torrent.info && torrent.info.trackers && torrent.info.trackers.includes('rutracker')
|
||||
&&
|
||||
<img src={RutrackerIcon} style={{height: 32}} />
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ const expand = (sphinx) => {
|
||||
})
|
||||
|
||||
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,
|
||||
key: 'id'
|
||||
}, options)
|
||||
@ -128,6 +128,10 @@ const expand = (sphinx) => {
|
||||
let names = '';
|
||||
let data = '';
|
||||
const parseValues = (values) => {
|
||||
if(sphinxIndex)
|
||||
for(const k in sphinxIndex)
|
||||
values[k] = values[sphinxIndex[k]]
|
||||
|
||||
let valuesData = ''
|
||||
names = ''
|
||||
for(const val in values)
|
||||
|
@ -116,14 +116,19 @@ module.exports = function (send, recive, dataDirectory, version, env)
|
||||
return
|
||||
|
||||
logT('tracker', 'found', name, 'on', tracker)
|
||||
this.sphinx.replaceValues('torrents', {hash, info: data}, {particial: true, key: 'hash', merge: ['info'], mergeCallback: (n, obj) => {
|
||||
if(n != 'info')
|
||||
return
|
||||
this.sphinx.replaceValues('torrents', {hash, info: data}, {
|
||||
particial: true,
|
||||
key: 'hash',
|
||||
sphinxIndex: {nameIndex: 'name'},
|
||||
merge: ['info'],
|
||||
mergeCallback: (n, obj) => {
|
||||
if(n != 'info')
|
||||
return
|
||||
|
||||
if(!obj.trackers)
|
||||
obj.trackers = []
|
||||
obj.trackers.push(name)
|
||||
obj.trackers = [...new Set(obj.trackers)]
|
||||
if(!obj.trackers)
|
||||
obj.trackers = []
|
||||
obj.trackers.push(tracker)
|
||||
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,
|
||||
good: row.good,
|
||||
bad: row.bad,
|
||||
info: typeof row.info == 'string' && row.info.length > 0 ? JSON.parse(row.info) : undefined
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,12 @@ module.exports = class Nyaa
|
||||
|
||||
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)
|
||||
return
|
||||
html = await html.text()
|
||||
|
@ -14,7 +14,12 @@ module.exports = class Rutracker
|
||||
|
||||
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)
|
||||
return
|
||||
html = await html.text()
|
||||
|
Loading…
Reference in New Issue
Block a user