mirror of
https://github.com/correl/Transmission-XBMC.git
synced 2024-11-24 19:19:56 +00:00
Beautify output from TorrentReactor
The data for <title> starts with a pretty long category in square brackets (eg. [Movies - DVD-R]) which makes the title uneasy to read in the results window. Also, added rev sorting by seeds.
This commit is contained in:
parent
bb4b001fb6
commit
ee44a01b76
1 changed files with 5 additions and 1 deletions
|
@ -1,8 +1,10 @@
|
||||||
import re
|
import re
|
||||||
import socket
|
import socket
|
||||||
from urllib2 import urlopen
|
from urllib2 import urlopen
|
||||||
|
from operator import itemgetter
|
||||||
from BeautifulSoup import BeautifulSoup, BeautifulStoneSoup
|
from BeautifulSoup import BeautifulSoup, BeautifulStoneSoup
|
||||||
|
|
||||||
|
|
||||||
socket.setdefaulttimeout(15)
|
socket.setdefaulttimeout(15)
|
||||||
|
|
||||||
class Search:
|
class Search:
|
||||||
|
@ -60,12 +62,14 @@ class TorrentReactor(Search):
|
||||||
soup = BeautifulStoneSoup(f.read())
|
soup = BeautifulStoneSoup(f.read())
|
||||||
for item in soup.findAll('item'):
|
for item in soup.findAll('item'):
|
||||||
(seeds, leechers) = re.findall('Status: (\d+) seeders, (\d+) leecher', item.description.text)[0]
|
(seeds, leechers) = re.findall('Status: (\d+) seeders, (\d+) leecher', item.description.text)[0]
|
||||||
|
title = re.findall(r'\[(?:[^\]])*\] (.*)', item.title.text)[0]
|
||||||
torrents.append({
|
torrents.append({
|
||||||
'url': item.enclosure['url'],
|
'url': item.enclosure['url'],
|
||||||
'name': item.title.text,
|
'name': title,
|
||||||
'seeds': int(seeds),
|
'seeds': int(seeds),
|
||||||
'leechers': int(leechers),
|
'leechers': int(leechers),
|
||||||
})
|
})
|
||||||
|
torrents = sorted(torrents, key=itemgetter('seeds'), reverse=True)
|
||||||
return torrents
|
return torrents
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Reference in a new issue