.+?">(.+?).+?
Uploaded (.+?), Size (.+?), .+?.+? (\d+?) .+?
(\d+?) ''',
+ re.DOTALL).findall(response)
for title, link, date, size, seeds, leechers in result:
info = {}
num = num - 1
@@ -95,11 +97,11 @@ class ThePirateBaySe(Content.Content):
size = size.replace(' ', ' ')
date = self.stripHtml(date.replace(' ', ' '))
- #info
+ # info
info['label'] = info['title'] = self.unescape(title)
info['link'] = link
- info['plot'] = info['title']+'\r\n[I](%s) [S/L: %s/%s] [/I]\r\n%s' % (size, seeds, leechers, date)
+ info['plot'] = info['title'] + '\r\n[I](%s) [S/L: %s/%s] [/I]\r\n%s' % (size, seeds, leechers, date)
contentList.append((
int(int(self.sourceWeight) * (int(num))),
original_title, title, int(year), img, info,
diff --git a/resources/pyxbmct/addonwindow.py b/resources/pyxbmct/addonwindow.py
index 987ed1d..c4825e9 100644
--- a/resources/pyxbmct/addonwindow.py
+++ b/resources/pyxbmct/addonwindow.py
@@ -11,9 +11,12 @@
# PyXBMCt framework module
import os
-import xbmc, xbmcgui, xbmcaddon
-#_addon = xbmcaddon.Addon()
+import xbmc
+import xbmcgui
+
+
+# _addon = xbmcaddon.Addon()
_images = os.path.join(os.path.dirname(__file__), 'textures', 'default')
@@ -82,6 +85,7 @@ class Label(xbmcgui.ControlLabel):
Example:
self.label = Label('Status', angle=45)
"""
+
def __new__(cls, *args, **kwargs):
return super(Label, cls).__new__(cls, -10, -10, 1, 1, *args, **kwargs)
@@ -100,6 +104,7 @@ class FadeLabel(xbmcgui.ControlFadeLabel):
Example:
self.fadelabel = FadeLabel(textColor='0xFFFFFFFF')
"""
+
def __new__(cls, *args, **kwargs):
return super(FadeLabel, cls).__new__(cls, -10, -10, 1, 1, *args, **kwargs)
@@ -117,6 +122,7 @@ class TextBox(xbmcgui.ControlTextBox):
Example:
self.textbox = TextBox(textColor='0xFFFFFFFF')
"""
+
def __new__(cls, *args, **kwargs):
return super(TextBox, cls).__new__(cls, -10, -10, 1, 1, *args, **kwargs)
@@ -136,6 +142,7 @@ class Image(xbmcgui.ControlImage):
Example:
self.image = Image('d:\images\picture.jpg', aspectRatio=2)
"""
+
def __new__(cls, *args, **kwargs):
return super(Image, cls).__new__(cls, -10, -10, 1, 1, *args, **kwargs)
@@ -163,6 +170,7 @@ class Button(xbmcgui.ControlButton):
Example:
self.button = Button('Status', font='font14')
"""
+
def __new__(cls, *args, **kwargs):
textures = {'focusTexture': os.path.join(_images, 'Button', 'KeyboardKey.png'),
'noFocusTexture': os.path.join(_images, 'Button', 'KeyboardKeyNF.png')}
@@ -202,6 +210,7 @@ class RadioButton(xbmcgui.ControlRadioButton):
Example:
self.radiobutton = RadioButton('Status', font='font14')
"""
+
def __new__(cls, *args, **kwargs):
if int(xbmc.getInfoLabel('System.BuildVersion')[:2]) >= 13:
textures = {'focusTexture': os.path.join(_images, 'RadioButton', 'MenuItemFO.png'),
@@ -210,7 +219,7 @@ class RadioButton(xbmcgui.ControlRadioButton):
'noFocusOnTexture': os.path.join(_images, 'RadioButton', 'radiobutton-focus.png'),
'focusOffTexture': os.path.join(_images, 'RadioButton', 'radiobutton-nofocus.png'),
'noFocusOffTexture': os.path.join(_images, 'RadioButton', 'radiobutton-nofocus.png')}
- else: # This is for compatibility with Frodo and earlier versions.
+ else: # This is for compatibility with Frodo and earlier versions.
textures = {'focusTexture': os.path.join(_images, 'RadioButton', 'MenuItemFO.png'),
'noFocusTexture': os.path.join(_images, 'RadioButton', 'MenuItemNF.png'),
'TextureRadioFocus': os.path.join(_images, 'RadioButton', 'radiobutton-focus.png'),
@@ -242,6 +251,7 @@ class Edit(xbmcgui.ControlEdit):
example:
- self.edit = Edit('Status')
"""
+
def __new__(cls, *args, **kwargs):
textures = {'focusTexture': os.path.join(_images, 'Edit', 'button-focus.png'),
'noFocusTexture': os.path.join(_images, 'Edit', 'black-back2.png')}
@@ -272,6 +282,7 @@ class List(xbmcgui.ControlList):
Example:
self.cList = List('font14', space=5)
"""
+
def __new__(cls, *args, **kwargs):
textures = {'buttonTexture': os.path.join(_images, 'List', 'MenuItemNF.png'),
'buttonFocusTexture': os.path.join(_images, 'List', 'MenuItemFO.png')}
@@ -293,6 +304,7 @@ class Slider(xbmcgui.ControlSlider):
Example:
self.slider = Slider()
"""
+
def __new__(cls, *args, **kwargs):
textures = {'textureback': os.path.join(_images, 'Slider', 'osd_slider_bg.png'),
'texture': os.path.join(_images, 'Slider', 'osd_slider_nibNF.png'),
@@ -302,7 +314,6 @@ class Slider(xbmcgui.ControlSlider):
class _AbstractWindow(object):
-
"""
Top-level control window.
@@ -340,8 +351,8 @@ class _AbstractWindow(object):
self.x = pos_x
self.y = pos_y
else:
- self.x = 640 - self.width/2
- self.y = 360 - self.height/2
+ self.x = 640 - self.width / 2
+ self.y = 360 - self.height / 2
self.setGrid()
def setGrid(self):
@@ -351,8 +362,8 @@ class _AbstractWindow(object):
"""
self.grid_x = self.x
self.grid_y = self.y
- self.tile_width = self.width/self.columns
- self.tile_height = self.height/self.rows
+ self.tile_width = self.width / self.columns
+ self.tile_height = self.height / self.rows
def placeControl(self, control, row, column, rowspan=1, columnspan=1, pad_x=5, pad_y=5):
"""
@@ -478,9 +489,9 @@ class _AbstractWindow(object):
self.disconnect(ACTION_NAV_BACK)
"""
if type(event) == int:
- event_list = self.actions_connected
+ event_list = self.actions_connected
else:
- event_list = self.controls_connected
+ event_list = self.controls_connected
for index in range(len(event_list)):
if event == event_list[index][0]:
event_list.pop(index)
@@ -525,7 +536,6 @@ class _AbstractWindow(object):
class _AddonWindow(_AbstractWindow):
-
"""
Top-level control window.
@@ -570,12 +580,14 @@ class _AddonWindow(_AbstractWindow):
self.addControl(self.title_background)
self.setAnimation(self.title_background)
self.title_bar = xbmcgui.ControlLabel(-10, -10, 1, 1, title, alignment=ALIGN_CENTER, textColor='0xFFFFA500',
- font='font13_title')
+ font='font13_title')
self.addControl(self.title_bar)
self.setAnimation(self.title_bar)
self.window_close_button = xbmcgui.ControlButton(-100, -100, 60, 30, '',
- focusTexture=os.path.join(_images, 'AddonWindow', 'DialogCloseButton-focus.png'),
- noFocusTexture=os.path.join(_images, 'AddonWindow', 'DialogCloseButton.png'))
+ focusTexture=os.path.join(_images, 'AddonWindow',
+ 'DialogCloseButton-focus.png'),
+ noFocusTexture=os.path.join(_images, 'AddonWindow',
+ 'DialogCloseButton.png'))
self.addControl(self.window_close_button)
self.setAnimation(self.window_close_button)
@@ -614,9 +626,10 @@ class _AddonWindow(_AbstractWindow):
"""
self.grid_x = self.x + self.X_MARGIN + self.win_padding
self.grid_y = self.y + self.Y_MARGIN + self.Y_SHIFT + self.HEADER_HEIGHT + self.win_padding
- self.tile_width = (self.width - 2 * (self.X_MARGIN + self.win_padding))/self.columns
+ self.tile_width = (self.width - 2 * (self.X_MARGIN + self.win_padding)) / self.columns
self.tile_height = (
- self.height - self.HEADER_HEIGHT - self.Y_SHIFT - 2 * (self.Y_MARGIN + self.win_padding))/self.rows
+ self.height - self.HEADER_HEIGHT - self.Y_SHIFT - 2 * (
+ self.Y_MARGIN + self.win_padding)) / self.rows
def setWindowTitle(self, title=''):
"""
@@ -632,8 +645,8 @@ class _AddonWindow(_AbstractWindow):
"""Get window title."""
return self.title_bar.getLabel()
-class _FullWindow(xbmcgui.Window):
+class _FullWindow(xbmcgui.Window):
"""An abstract class to define window event processing."""
def onAction(self, action):
@@ -659,7 +672,6 @@ class _FullWindow(xbmcgui.Window):
class _DialogWindow(xbmcgui.WindowDialog):
-
"""An abstract class to define window event processing."""
def onAction(self, action):
@@ -718,8 +730,8 @@ class BlankDialogWindow(_DialogWindow, _AbstractWindow):
"""
pass
-class AddonFullWindow(_FullWindow, _AddonWindow):
+class AddonFullWindow(_FullWindow, _AddonWindow):
"""
Addon UI container with a solid background.
Control window is displayed on top of the main background image - self.main_bg.
diff --git a/resources/scrapers/cache.py b/resources/scrapers/cache.py
index cca4ca2..8d539d0 100644
--- a/resources/scrapers/cache.py
+++ b/resources/scrapers/cache.py
@@ -12,7 +12,6 @@ import xbmcgui
import Localization
from net import HTTP
-
try:
from sqlite3 import dbapi2 as sqlite
except:
@@ -33,7 +32,7 @@ class Cache:
def get(self, token, callback, *param):
cur = self.db.cursor()
- cur.execute('select expire,data from cache where id=? limit 1', (token, ))
+ cur.execute('select expire,data from cache where id=? limit 1', (token,))
row = cur.fetchone()
cur.close()
@@ -67,7 +66,7 @@ class Cache:
def expire(self, expire):
# with rtrCache_lock:
cur = self.db.cursor()
- cur.execute('delete from cache where addtime', (int(time.time()) - expire, ))
+ cur.execute('delete from cache where addtime', (int(time.time()) - expire,))
self.db.commit()
cur.close()
@@ -77,7 +76,7 @@ class Cache:
if os.path.getsize(self.filename) < size:
break
cur = self.db.cursor()
- cur.execute('select id from cache order by addtime asc limit ?', (step, ))
+ cur.execute('select id from cache order by addtime asc limit ?', (step,))
rows = cur.fetchall()
if not rows:
cur.close()
@@ -129,7 +128,7 @@ class Cache:
cur.execute('create table cache(id varchar(255) unique, addtime integer, expire integer, data blob)')
cur.execute('create index time on cache(addtime asc)')
cur.execute('create table db_ver(version real)')
- cur.execute('insert into db_ver(version) values(?)', (self.version, ))
+ cur.execute('insert into db_ver(version) values(?)', (self.version,))
self.db.commit()
cur.close()
@@ -137,7 +136,7 @@ class Cache:
scrapers = {'tvdb': 'TheTVDB.com', 'tmdb': 'TheMovieDB.org', 'kinopoisk': 'KinoPoisk.ru'}
ok = xbmcgui.Dialog().yesno(Localization.localize('Content Lists'),
Localization.localize('Do you want to preload full metadata?') + ' (%s)' % (
- scrapers[os.path.basename(self.filename).split('.')[0]]),
+ scrapers[os.path.basename(self.filename).split('.')[0]]),
Localization.localize('It is highly recommended!'))
if ok:
return self.download()
@@ -146,7 +145,7 @@ class Cache:
def download(self):
dirname = os.path.dirname(self.filename)
- zipname = os.path.basename(self.filename).replace('.db','') + '.zip'
+ zipname = os.path.basename(self.filename).replace('.db', '') + '.zip'
url = 'http://www.tat-store.ru/torrenter/' + zipname
self.http = HTTP()
response = self.http.fetch(url, download=os.path.join(dirname, zipname), progress=True)
diff --git a/resources/scrapers/kinopoisk/common.py b/resources/scrapers/kinopoisk/common.py
index a5ef6a2..ca74eef 100644
--- a/resources/scrapers/kinopoisk/common.py
+++ b/resources/scrapers/kinopoisk/common.py
@@ -27,10 +27,8 @@ import math
import difflib
import translit
-import LOGGER as Log
from HTTP import *
-
USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22'
# USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/534.51.22 (KHTML, like Gecko) Version/5.1.1 Safari/534.51.22'
ENCODING_PLEX = 'utf-8'
@@ -230,7 +228,7 @@ def scoreMediaTitleMatch(mediaName, mediaYear, title, altTitle, year, itemIndex)
elif yearDiff == 2:
yearPenalty = 25
score = score - yearPenalty
- #print str(mediaYear)+' '+str(year)+' '+str(yearPenalty)
+ # print str(mediaYear)+' '+str(year)+' '+str(yearPenalty)
# Compute title penalty.
titlePenalty = computeTitlePenalty(mediaName, title)
@@ -364,8 +362,8 @@ def computeTitlePenalty(mediaName, title):
penaltyAlt = penaltyAlt + int(penaltyPerPart * (1 - partDiffRatio))
i = i + 1
penalty = min(penalty, penaltyAlt)
- # print '++++++ DIFF("%s", "%s") = %g --> %d' % (mediaName.encode('utf8'), title.encode('utf8'), diffRatio, penalty)
- # Log.Debug('++++++ DIFF("%s", "%s") = %g --> %d' % (mediaName.encode('utf8'), title.encode('utf8'), diffRatio, penalty))
+ # print '++++++ DIFF("%s", "%s") = %g --> %d' % (mediaName.encode('utf8'), title.encode('utf8'), diffRatio, penalty)
+ # Log.Debug('++++++ DIFF("%s", "%s") = %g --> %d' % (mediaName.encode('utf8'), title.encode('utf8'), diffRatio, penalty))
return penalty
return 0
diff --git a/resources/scrapers/kinopoisk/pageparser.py b/resources/scrapers/kinopoisk/pageparser.py
index d6ea9ac..90125d4 100644
--- a/resources/scrapers/kinopoisk/pageparser.py
+++ b/resources/scrapers/kinopoisk/pageparser.py
@@ -32,9 +32,11 @@ import pluginsettings as S
import translit
+
+
# MATCHER_MOVIE_DURATION = re.compile('\s*(\d+).*?', re.UNICODE | re.DOTALL)
-#MATCHER_IMDB_RATING = re.compile('IMDb:\s*(\d+\.?\d*)\s*\(\s*([\s\d]+)\s*\)', re.UNICODE | re.DOTALL)
-#MATCHER_IMDB_RATING = re.compile('IMDb:\s*(\d+\.?\d*)\s?\((.*)\)', re.UNICODE)
+# MATCHER_IMDB_RATING = re.compile('IMDb:\s*(\d+\.?\d*)\s*\(\s*([\s\d]+)\s*\)', re.UNICODE | re.DOTALL)
+# MATCHER_IMDB_RATING = re.compile('IMDb:\s*(\d+\.?\d*)\s?\((.*)\)', re.UNICODE)
USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22'
'''
@@ -171,5 +173,3 @@ class PageParser:
results.append([itemKinoPoiskId, itemTitle, itemYear, itemScore])
return results
-
-
diff --git a/resources/scrapers/kinopoisk/translit.py b/resources/scrapers/kinopoisk/translit.py
index 11a8762..c597594 100644
--- a/resources/scrapers/kinopoisk/translit.py
+++ b/resources/scrapers/kinopoisk/translit.py
@@ -19,11 +19,9 @@ Simple transliteration
"""
# __id__ = __revision__ = "$Id: translit.py 102 2007-07-12 12:33:36Z the.pythy $"
-#__url__ = "$URL: https://pythy.googlecode.com/svn/tags/pytils/0_2_2/pytils/translit.py $"
+# __url__ = "$URL: https://pythy.googlecode.com/svn/tags/pytils/0_2_2/pytils/translit.py $"
import re
-import sys
-
TRANSTABLE = (
(u"'", u"'"),
diff --git a/resources/scrapers/kinopoisks.py b/resources/scrapers/kinopoisks.py
index 2a7f8c3..b32ccca 100644
--- a/resources/scrapers/kinopoisks.py
+++ b/resources/scrapers/kinopoisks.py
@@ -11,7 +11,6 @@ import kinopoisk.LOGGER
import kinopoisk.pageparser
import kinopoisk.common
-
GENRE = {
'anime': 1750,
'biography': 22,
@@ -295,7 +294,7 @@ class KinoPoisk:
"""
def __init__(self, language='ru'):
- dbname='kinopoisk.%s.db' % language
+ dbname = 'kinopoisk.%s.db' % language
self.cache = Cache(dbname, 1.0)
self.html = Clear()
@@ -463,8 +462,9 @@ class KinoPoisk:
if len(data) == 3:
i = 0
for mon in (
- u'января', u'февраля', u'марта', u'апреля', u'мая', u'июня', u'июля', u'августа', u'сентября',
- u'октября', u'ноября', u'декабря'):
+ u'января', u'февраля', u'марта', u'апреля', u'мая', u'июня', u'июля', u'августа',
+ u'сентября',
+ u'октября', u'ноября', u'декабря'):
i += 1
if mon == data[1]:
mon = str(i)
diff --git a/resources/scrapers/net.py b/resources/scrapers/net.py
index 87e1812..0b6cba2 100644
--- a/resources/scrapers/net.py
+++ b/resources/scrapers/net.py
@@ -12,10 +12,8 @@ import itertools
import xbmc
import xbmcgui
-import xbmcaddon
import xbmcvfs
-
RE = {
'content-disposition': re.compile('attachment;\sfilename="*([^"\s]+)"|\s')
}
@@ -34,7 +32,6 @@ class HTTP:
if not xbmcvfs.exists(self._dirname):
xbmcvfs.mkdir(self._dirname)
-
def fetch(self, request, **kwargs):
self.con, self.fd, self.progress, self.cookies, self.request = None, None, None, None, request
@@ -74,7 +71,6 @@ class HTTP:
return self.response
-
def _opener(self):
build = [urllib2.HTTPHandler()]
@@ -101,7 +97,6 @@ class HTTP:
urllib2.install_opener(urllib2.build_opener(*build))
-
def _fetch(self):
params = {} if self.request.params is None else self.request.params
@@ -130,7 +125,7 @@ class HTTP:
':'.join([self.request.auth_username, self.request.auth_password])).strip())
self.con = urllib2.urlopen(req, timeout=self.request.timeout)
- #self.con = urllib2.urlopen(req)
+ # self.con = urllib2.urlopen(req)
self.response.headers = self._headers(self.con.info())
if self.request.download:
@@ -141,7 +136,6 @@ class HTTP:
if self.request.cookies:
self.cookies.save(self.request.cookies)
-
def _download(self):
fd = open(self.request.download, 'wb')
if self.request.progress:
@@ -173,7 +167,6 @@ class HTTP:
self.response.filename = self.request.download
-
def _upload(self, upload, params):
res = []
boundary = mimetools.choose_boundary()
@@ -209,7 +202,6 @@ class HTTP:
result.append('')
return boundary, '\r\n'.join(result)
-
def _headers(self, raw):
headers = {}
for line in raw.headers:
@@ -221,7 +213,6 @@ class HTTP:
headers[tag] = value
return headers
-
def _progress(self, read, size, name):
res = []
if size < 0:
@@ -304,4 +295,3 @@ class HTTPResponse:
else:
args += ',body=None'
return '%s(%s)' % (self.__class__.__name__, args)
-
diff --git a/resources/scrapers/requests/utils.py b/resources/scrapers/requests/utils.py
index aa5c140..2442acf 100644
--- a/resources/scrapers/requests/utils.py
+++ b/resources/scrapers/requests/utils.py
@@ -383,7 +383,6 @@ def get_unicode_from_response(r):
except TypeError:
return r.content
-
# The unreserved URI characters (RFC 3986)
UNRESERVED_SET = frozenset(
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
@@ -519,6 +518,7 @@ def should_bypass_proxies(url):
return False
+
def get_environ_proxies(url):
"""Return a dict of environment proxies."""
if should_bypass_proxies(url):
@@ -600,7 +600,6 @@ def parse_header_links(value):
return links
-
# Null bytes; no need to recreate these on each call to guess_json_utf
_null = '\x00'.encode('ascii') # encoding to ASCII for Python 3
_null2 = _null * 2
@@ -613,26 +612,26 @@ def guess_json_utf(data):
# determine the encoding. Also detect a BOM, if present.
sample = data[:4]
if sample in (codecs.BOM_UTF32_LE, codecs.BOM32_BE):
- return 'utf-32' # BOM included
+ return 'utf-32' # BOM included
if sample[:3] == codecs.BOM_UTF8:
return 'utf-8-sig' # BOM included, MS style (discouraged)
if sample[:2] in (codecs.BOM_UTF16_LE, codecs.BOM_UTF16_BE):
- return 'utf-16' # BOM included
+ return 'utf-16' # BOM included
nullcount = sample.count(_null)
if nullcount == 0:
return 'utf-8'
if nullcount == 2:
- if sample[::2] == _null2: # 1st and 3rd are null
+ if sample[::2] == _null2: # 1st and 3rd are null
return 'utf-16-be'
if sample[1::2] == _null2: # 2nd and 4th are null
return 'utf-16-le'
- # Did not detect 2 valid UTF-16 ascii-range characters
+ # Did not detect 2 valid UTF-16 ascii-range characters
if nullcount == 3:
if sample[:3] == _null3:
return 'utf-32-be'
if sample[1:] == _null3:
return 'utf-32-le'
- # Did not detect a valid UTF-32 ascii-range character
+ # Did not detect a valid UTF-32 ascii-range character
return None
diff --git a/resources/scrapers/scrapers.py b/resources/scrapers/scrapers.py
index 39a036b..f590ad0 100644
--- a/resources/scrapers/scrapers.py
+++ b/resources/scrapers/scrapers.py
@@ -2,13 +2,11 @@
# -*- coding: utf-8 -*-
import re
-#import xbmc, xbmcgui, xbmcplugin, xbmcvfs
-import xbmcaddon
+# import xbmc, xbmcgui, xbmcplugin, xbmcvfs
from tvdb import TvDb
from tmdbs import TmDb
from kinopoisks import KinoPoisk
-
STATUS = {
'moder': (40501, 'FFFF0000'),
'check': (40502, 'FFFF0000'),
@@ -90,7 +88,7 @@ class Scrapers():
scraper = TvDb(language)
elif content == 'tmdb':
scraper = TmDb(language)
- else: #if content == 'kinopoisk':
+ else: # if content == 'kinopoisk':
scraper = KinoPoisk(language)
name, search, year = item['label'], item['search'], item['year']
diff --git a/resources/searchers/RuTrackerOrg.py b/resources/searchers/RuTrackerOrg.py
index ce91a7d..a44dba9 100644
--- a/resources/searchers/RuTrackerOrg.py
+++ b/resources/searchers/RuTrackerOrg.py
@@ -21,9 +21,6 @@
import urllib
import re
import sys
-import tempfile
-import os
-import time
import SearcherABC
@@ -66,7 +63,7 @@ class RuTrackerOrg(SearcherABC.SearcherABC):
def search(self, keyword):
filesList = []
- url='http://rutracker.org/forum/tracker.php?nm=' + urllib.quote_plus(keyword)
+ url = 'http://rutracker.org/forum/tracker.php?nm=' + urllib.quote_plus(keyword)
data = {'prev_my': '0',
'prev_new': '0',
@@ -79,11 +76,11 @@ class RuTrackerOrg(SearcherABC.SearcherABC):
response = self.makeRequest(url, data=data)
if None != response and 0 < len(response):
response = response.decode('cp1251').encode('utf8')
- #print response
+ # print response
if not self.check_login(response):
response = self.makeRequest(url, data=data)
response = response.decode('cp1251').encode('utf8')
- #print response
+ # print response
forums = [7, 187, 2090, 2221, 2091, 2092, 2093, 934, 505, 212, 2459, 1235, 185, 22, 941, 1666, 124, 1543,
376, 709, 1577, 511, 656, 93, 905, 1576, 101, 100, 103, 572, 1670, 2198, 2199, 313, 2201, 312,
2339, 314, 352, 549, 1213, 2109, 514, 2097, 4, 930, 2365, 1900, 521, 2258, 208, 539, 209, 484,
@@ -128,19 +125,19 @@ class RuTrackerOrg(SearcherABC.SearcherABC):
def getTorrentFile(self, url):
self.load_cookie()
- cookie=None
+ cookie = None
for cookie in self.cookieJar:
- if cookie.name=='bb_data' and cookie.domain=='.rutracker.org':
- cookie = 'bb_data=' + cookie.value + '; bb_dl=' + re.search('(\d+)$',url).group(1)
+ if cookie.name == 'bb_data' and cookie.domain == '.rutracker.org':
+ cookie = 'bb_data=' + cookie.value + '; bb_dl=' + re.search('(\d+)$', url).group(1)
break
if not cookie:
- cookie = self.login() + '; bb_dl=' + re.search('(\d+)$',url).group(1)
+ cookie = self.login() + '; bb_dl=' + re.search('(\d+)$', url).group(1)
referer = 'http://rutracker.org/forum/viewtopic.php?t=' + re.search('(\d+)$', url).group(1)
- headers=[('Cookie', cookie), ('Referer', referer)]
+ headers = [('Cookie', cookie), ('Referer', referer)]
content = self.makeRequest(url, headers=headers)
if not self.check_login(content):
- cookie = self.login() + '; bb_dl=' + re.search('(\d+)$',url).group(1)
+ cookie = self.login() + '; bb_dl=' + re.search('(\d+)$', url).group(1)
content = self.makeRequest(url, headers=[('Cookie', cookie), ('Referer', referer)])
return self.saveTorrentFile(url, content)
diff --git a/resources/searchers/T411FR.py b/resources/searchers/T411FR.py
index a5885b3..53764a6 100644
--- a/resources/searchers/T411FR.py
+++ b/resources/searchers/T411FR.py
@@ -19,9 +19,7 @@
'''
import re
-import os
import urllib
-import tempfile
import sys
import SearcherABC
@@ -63,25 +61,26 @@ class T411FR(SearcherABC.SearcherABC):
))'''
headers = {('Origin', 'http://t411.io'),
- ('User-Agent',
- 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 YaBrowser/14.10.2062.12061 Safari/537.36'),
- ('Referer', 'http://t411.io/'),('X-NewRelic-ID','x='),
- ('X-Requested-With','XMLHttpRequest'),}
+ ('User-Agent',
+ 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 YaBrowser/14.10.2062.12061 Safari/537.36'),
+ ('Referer', 'http://t411.io/'), ('X-NewRelic-ID', 'x='),
+ ('X-Requested-With', 'XMLHttpRequest'), }
def search(self, keyword):
filesList = []
- url='http://www.t411.io/torrents/search/?search=%s' % urllib.quote_plus(keyword.decode('utf-8').encode('cp1251'))
- url+='&order=seeders&type=desc'
+ url = 'http://www.t411.io/torrents/search/?search=%s' % urllib.quote_plus(
+ keyword.decode('utf-8').encode('cp1251'))
+ url += '&order=seeders&type=desc'
response = self.makeRequest(url, headers=self.headers)
if None != response and 0 < len(response):
- #self.cookieJar.save(ignore_discard=True)
- #self.check_login(response)
- #print response
+ # self.cookieJar.save(ignore_discard=True)
+ # self.check_login(response)
+ # print response
regex = '''
.+?.+? .+?.+? .+? .+?
.+? .+?
(.+?) .+?
(\d+) .+?
(\d+) '''
for (title, link, size, seeds, leechers) in re.compile(regex, re.DOTALL).findall(response):
- title=self.clear_title(title)
+ title = self.clear_title(title)
image = sys.modules["__main__"].__root__ + self.searchIcon
- link = 'http://www.t411.io/torrents/download/?id='+link
+ link = 'http://www.t411.io/torrents/download/?id=' + link
filesList.append((
int(int(self.sourceWeight) * int(seeds)),
int(seeds), int(leechers), size,
@@ -92,11 +91,11 @@ class T411FR(SearcherABC.SearcherABC):
return filesList
def clear_title(self, s):
- return self.stripHtml(self.unescape(s)).replace(' ',' ').replace(' ',' ').strip()
+ return self.stripHtml(self.unescape(s)).replace(' ', ' ').replace(' ', ' ').strip()
def check_login(self, response=None):
if None != response and 0 < len(response):
- #print response
+ # print response
if re.compile('
.+?
(.+?) .+?
(.+?) .+?class="sd">(\d+).+?class="lc">(\d+)'''
for (forum, title, link, size, seeds, leechers) in re.compile(regex, re.DOTALL).findall(response):
- #if int(forum) not in bad_forums:
- title=self.clear_title(title)
+ # if int(forum) not in bad_forums:
+ title = self.clear_title(title)
image = sys.modules["__main__"].__root__ + self.searchIcon
- link = 'http://tfile.me/forum/download.php?id='+link
+ link = 'http://tfile.me/forum/download.php?id=' + link
filesList.append((
int(int(self.sourceWeight) * int(seeds)),
int(seeds), int(leechers), size,
@@ -94,11 +92,11 @@ class TFileME(SearcherABC.SearcherABC):
return filesList
def clear_title(self, s):
- return self.stripHtml(self.unescape(s)).replace(' ',' ').replace(' ',' ').strip()
+ return self.stripHtml(self.unescape(s)).replace(' ', ' ').replace(' ', ' ').strip()
def check_login(self, response=None):
if None != response and 0 < len(response):
- #print response
+ # print response
if re.compile('
.+?">(.+?).+?
Uploaded .+?, Size (.+?), .+?.+? (\d+?) .+?
(\d+?) ',
re.DOTALL).findall(response)
for (title, link, size, seeds, leechers) in dat:
- torrentTitle = title #"%s [S\L: %s\%s]" % (title, seeds, leechers)
+ torrentTitle = title # "%s [S\L: %s\%s]" % (title, seeds, leechers)
size = size.replace(' ', ' ')
image = sys.modules["__main__"].__root__ + self.searchIcon
if not re.match('^https?\://.+', link) and not re.match('^magnet\:.+', link):
@@ -86,4 +85,4 @@ class ThePirateBaySe(SearcherABC.SearcherABC):
self.__class__.__name__ + '::' + link,
image,
))
- return filesList
\ No newline at end of file
+ return filesList
diff --git a/resources/searchers/unused/KinoZalTV.py b/resources/searchers/unused/KinoZalTV.py
index 2f46539..e78d886 100644
--- a/resources/searchers/unused/KinoZalTV.py
+++ b/resources/searchers/unused/KinoZalTV.py
@@ -19,9 +19,7 @@
'''
import re
-import os
import urllib
-import tempfile
import sys
import SearcherABC
@@ -64,7 +62,8 @@ class KinoZalTV(SearcherABC.SearcherABC):
def search(self, keyword):
filesList = []
- url='http://kinozal.tv/browse.php?s=%s&g=0&c=0&v=0&d=0&w=0&t=1&f=0' % urllib.quote_plus(keyword.decode('utf-8').encode('cp1251'))
+ url = 'http://kinozal.tv/browse.php?s=%s&g=0&c=0&v=0&d=0&w=0&t=1&f=0' % urllib.quote_plus(
+ keyword.decode('utf-8').encode('cp1251'))
headers = {('Origin', 'http://kinozal.tv'),
('User-Agent',
@@ -74,8 +73,8 @@ class KinoZalTV(SearcherABC.SearcherABC):
response = self.makeRequest(url, headers=headers)
if None != response and 0 < len(response):
response = response.decode('cp1251').encode('utf-8')
- #print response
- bad_forums = [2,1,23,32,40,41]
+ # print response
+ bad_forums = [2, 1, 23, 32, 40, 41]
regex = '''onclick="cat\((\d+)\);".+?
(.+?) .+?
(.+?) .+?class='sl_s'>(\d+).+?class='sl_p'>(\d+)'''
for (forum, topic, title, size, seeds, leechers) in re.compile(regex, re.DOTALL).findall(response):
if int(forum) not in bad_forums:
@@ -102,10 +101,10 @@ class KinoZalTV(SearcherABC.SearcherABC):
self.timeout(5)
content = self.makeRequest(url)
- #print content
+ # print content
if not self.check_login(content):
content = self.makeRequest(url)
- #print content
+ # print content
return self.saveTorrentFile(url, content)
@@ -113,7 +112,7 @@ class KinoZalTV(SearcherABC.SearcherABC):
data = {
'password': 'torrenter',
'username': 'torrenterpl',
- 'returnto:':''
+ 'returnto:': ''
}
self.makeRequest(
'http://kinozal.tv/takelogin.php',
@@ -121,11 +120,11 @@ class KinoZalTV(SearcherABC.SearcherABC):
)
self.cookieJar.save(ignore_discard=True)
for cookie in self.cookieJar:
- uid,passed=None,None
+ uid, passed = None, None
if cookie.name == 'uid':
- uid=cookie.value
+ uid = cookie.value
if cookie.name == 'pass':
- passed=cookie.value
+ passed = cookie.value
if uid and passed:
- return 'uid=' + uid+'; pass='+ passed
- return False
\ No newline at end of file
+ return 'uid=' + uid + '; pass=' + passed
+ return False
diff --git a/resources/skins/DialogXml.py b/resources/skins/DialogXml.py
index dc1b127..ad29c21 100644
--- a/resources/skins/DialogXml.py
+++ b/resources/skins/DialogXml.py
@@ -1,28 +1,35 @@
# -*- coding: utf-8 -*-
-import xbmcgui, Localization, sys, xbmc
+import sys
+
+import xbmcgui
+import Localization
+import xbmc
KEY_BUTTON_BACK = 275
KEY_KEYBOARD_ESC = 61467
ACTION_PREVIOUS_MENU = 10
ACTION_NAV_BACK = 92
+
+
class DialogXml(xbmcgui.WindowXMLDialog):
def onInit(self):
print "onInit(): Window Initialized"
- localize=Localization.localize
- color='[COLOR %s]%s[/COLOR]'
+ localize = Localization.localize
+ color = '[COLOR %s]%s[/COLOR]'
self.movie_label = self.getControl(32)
self.movie_label.setText(self.movieInfo['desc'])
if self.movieInfo.get('views'):
self.view_label = self.getControl(34)
- self.view_label.setLabel(color % ('blue', localize('Views:'))+self.movieInfo['views'])
+ self.view_label.setLabel(color % ('blue', localize('Views:')) + self.movieInfo['views'])
self.view_label = self.getControl(35)
self.ratingcolor = 'green'
self.ratingint = int(self.movieInfo['rating'])
- if(self.ratingint < 70):
+ if (self.ratingint < 70):
self.ratingcolor = 'red'
- self.view_label.setLabel(color % ('blue', localize('Rating:'))+color % (self.ratingcolor, self.movieInfo['rating']))
+ self.view_label.setLabel(
+ color % ('blue', localize('Rating:')) + color % (self.ratingcolor, self.movieInfo['rating']))
self.movie_label = self.getControl(1)
self.movie_label.setLabel(self.movieInfo['title'])
@@ -43,7 +50,7 @@ class DialogXml(xbmcgui.WindowXMLDialog):
self.setFocus(self.getControl(22))
def onAction(self, action):
- buttonCode = action.getButtonCode()
+ buttonCode = action.getButtonCode()
if (action == ACTION_NAV_BACK or action == ACTION_PREVIOUS_MENU):
self.close()
if (buttonCode == KEY_BUTTON_BACK or buttonCode == KEY_KEYBOARD_ESC):
@@ -61,18 +68,16 @@ class DialogXml(xbmcgui.WindowXMLDialog):
def RunPlugin(self, action):
if self.link:
- exec_str='XBMC.RunPlugin(%s)' % \
- ('%s?action=%s&url=%s') % \
- (sys.argv[0], action, self.link)
+ exec_str = 'XBMC.RunPlugin(%s)' % \
+ ('%s?action=%s&url=%s') % \
+ (sys.argv[0], action, self.link)
xbmc.executebuiltin(exec_str)
-
def onFocus(self, controlID):
- #print "onFocus(): control %i" % controlID
+ # print "onFocus(): control %i" % controlID
pass
-
def doModal(self, movieInfo, url):
self.movieInfo = movieInfo
- self.link=url
- xbmcgui.WindowXMLDialog.doModal(self)
\ No newline at end of file
+ self.link = url
+ xbmcgui.WindowXMLDialog.doModal(self)
diff --git a/resources/utorrent/dopal/core.py b/resources/utorrent/dopal/core.py
index 5ae0227..ae0b9b8 100644
--- a/resources/utorrent/dopal/core.py
+++ b/resources/utorrent/dopal/core.py
@@ -842,7 +842,7 @@ class AzureusConnection(AzureusLink):
raise NoEstablishedConnectionError
from xml.dom.minidom import parseString
- from dopal.xmlutils import normalise_xml_structure, get_text_content
+ from dopal.xmlutils import normalise_xml_structure
# First step, convert the method data to XML.
xml_data = remote_method_call_as_xml(method_name, method_args,
@@ -1018,7 +1018,6 @@ class ExtendedAzureusConnection(AzureusConnection):
return dopal.utils.parse_azureus_version_string(az_version)
-
# Use of this name is deprecated, and this alias will be removed in later
# versions of DOPAL.
ReusableAzureusConnection = ExtendedAzureusConnection
diff --git a/resources/utorrent/dopal/objects.py b/resources/utorrent/dopal/objects.py
index b1e7935..34c551a 100644
--- a/resources/utorrent/dopal/objects.py
+++ b/resources/utorrent/dopal/objects.py
@@ -22,7 +22,7 @@ from dopal.core import ExtendedAzureusConnection
from dopal.errors import AzMethodError, InvalidObjectIDError, \
RemoteMethodError, StaleObjectReferenceError, ConnectionlessObjectError, \
NonRefreshableConnectionlessObjectError, MissingRemoteAttributeError, \
- NonRefreshableIncompleteObjectError, NonRefreshableObjectError
+ NonRefreshableObjectError
import dopal.utils
@@ -487,7 +487,6 @@ class RemoteAttributesMixin(object):
text = "'%s' object has no attribute '%s'"
raise AttributeError, text % (type(self).__name__, name)
-
def __setattr__(self, name, value):
if self.__protect_remote_attributes__ and not name.startswith('__'):
if name in self.__remote_attribute_names__:
diff --git a/resources/utorrent/net.py b/resources/utorrent/net.py
index f59bfc3..58ae6ea 100644
--- a/resources/utorrent/net.py
+++ b/resources/utorrent/net.py
@@ -18,7 +18,6 @@ import xbmc
import xbmcgui
import xbmcvfs
-
os.sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__))))
import dopal.main
@@ -51,7 +50,6 @@ class HTTP:
if not xbmcvfs.exists(self._dirname):
xbmcvfs.mkdir(self._dirname)
-
def fetch(self, request, **kwargs):
self.con, self.fd, self.progress, self.cookies, self.request = None, None, None, None, request
@@ -91,7 +89,6 @@ class HTTP:
return self.response
-
def _opener(self):
build = [urllib2.HTTPHandler()]
@@ -118,7 +115,6 @@ class HTTP:
urllib2.install_opener(urllib2.build_opener(*build))
-
def _fetch(self):
params = {} if self.request.params is None else self.request.params
@@ -153,7 +149,7 @@ class HTTP:
if self.request.download:
self._download()
else:
- if not self.response.headers.get('content-encoding')=='gzip':
+ if not self.response.headers.get('content-encoding') == 'gzip':
self.response.body = self.con.read()
else:
buf = StringIO(self.con.read())
@@ -163,7 +159,6 @@ class HTTP:
if self.request.cookies:
self.cookies.save(self.request.cookies)
-
def _download(self):
fd = open(self.request.download, 'wb')
if self.request.progress:
@@ -195,7 +190,6 @@ class HTTP:
self.response.filename = self.request.download
-
def _upload(self, upload, params):
res = []
boundary = mimetools.choose_boundary()
@@ -231,7 +225,6 @@ class HTTP:
result.append('')
return boundary, '\r\n'.join(result)
-
def _headers(self, raw):
headers = {}
for line in raw.headers:
@@ -243,7 +236,6 @@ class HTTP:
headers[tag] = value
return headers
-
def _progress(self, read, size, name):
res = []
if size < 0:
@@ -756,11 +748,11 @@ class Transmission:
return True if res else None
def setprio_simple_multi(self, menu):
- id=menu[0][0]
- prio=menu[0][1]
- res=None
+ id = menu[0][0]
+ prio = menu[0][1]
+ res = None
- inds=[]
+ inds = []
for hash, action, ind in menu:
inds.append(int(ind))
@@ -857,72 +849,72 @@ class Deluge:
self.login = login
self.password = password
- self.url = ['http://','https://'][int(url)] + host
+ self.url = ['http://', 'https://'][int(url)] + host
if port:
self.url += ':' + str(port)
self.http = HTTP()
def get_info(self):
- obj = self.action({"method":"web.update_ui",
- "params":[[],{}],"id":1})
+ obj = self.action({"method": "web.update_ui",
+ "params": [[], {}], "id": 1})
return obj
def list(self):
- obj=self.get_info()
+ obj = self.get_info()
if obj is None:
return False
res = []
- if len(obj['result'].get('torrents'))>0:
+ if len(obj['result'].get('torrents')) > 0:
for k in obj['result'].get('torrents').keys():
- r=obj['result']['torrents'][k]
- add={
- 'id': str(k),
- 'status': self.get_status(r['state']),
- 'name': r['name'],
- 'size': r['total_wanted'],
- 'progress': round(r['progress'], 2),
- 'download': r['total_done'],
- 'upload': r['total_uploaded'],
- 'upspeed': r['upload_payload_rate'],
- 'downspeed': r['download_payload_rate'],
- 'ratio': round(r['ratio'], 2),
- 'eta': r['eta'],
- 'peer': r['total_peers'],
- 'seed': r['num_seeds'],
- 'leech': r['num_peers'],
- 'add': r['time_added'],
- 'dir': r['save_path']
+ r = obj['result']['torrents'][k]
+ add = {
+ 'id': str(k),
+ 'status': self.get_status(r['state']),
+ 'name': r['name'],
+ 'size': r['total_wanted'],
+ 'progress': round(r['progress'], 2),
+ 'download': r['total_done'],
+ 'upload': r['total_uploaded'],
+ 'upspeed': r['upload_payload_rate'],
+ 'downspeed': r['download_payload_rate'],
+ 'ratio': round(r['ratio'], 2),
+ 'eta': r['eta'],
+ 'peer': r['total_peers'],
+ 'seed': r['num_seeds'],
+ 'leech': r['num_peers'],
+ 'add': r['time_added'],
+ 'dir': r['save_path']
}
- if len(r['files'])>1: add['dir']=os.path.join(r['save_path'],r['name'])
+ if len(r['files']) > 1: add['dir'] = os.path.join(r['save_path'], r['name'])
res.append(add)
return res
def listdirs(self):
- obj = self.action({"method":"core.get_config","params":[],"id":5})
+ obj = self.action({"method": "core.get_config", "params": [], "id": 5})
if obj is None:
return False
try:
res = [obj['result'].get('download_location')]
except:
- res=[None]
+ res = [None]
return res, res
def listfiles(self, id):
obj = self.get_info()
- i=0
+ i = 0
if obj is None:
return None
res = []
- obj=obj['result']['torrents'][id]
- #print str(obj)
- if len(obj['files'])==1:
- strip_path=None
+ obj = obj['result']['torrents'][id]
+ # print str(obj)
+ if len(obj['files']) == 1:
+ strip_path = None
else:
- strip_path=obj['name']
+ strip_path = obj['name']
for x in obj['files']:
if x['size'] >= 1024 * 1024 * 1024:
@@ -934,17 +926,18 @@ class Deluge:
else:
size = str(x['size']) + 'B'
if strip_path:
- path=x['path'].lstrip(strip_path).lstrip('/')
+ path = x['path'].lstrip(strip_path).lstrip('/')
else:
- path=x['path']
+ path = x['path']
if x.get('progress'):
- percent=int(x['progress']*100)
- elif obj.get('file_progress') and len(obj['file_progress'])>=i:
- percent=int(obj['file_progress'][i]*100)
- else:percent=0
+ percent = int(x['progress'] * 100)
+ elif obj.get('file_progress') and len(obj['file_progress']) >= i:
+ percent = int(obj['file_progress'][i] * 100)
+ else:
+ percent = 0
- i+=1
+ i += 1
res.append([path, percent, x['index'], size])
return res
@@ -953,24 +946,26 @@ class Deluge:
obj = self.get_info()
if obj is None:
return None
- res=obj['result']['torrents'][id]['file_priorities']
+ res = obj['result']['torrents'][id]['file_priorities']
return res
def add(self, torrent, dirname):
- torrentFile=os.path.join(self.http._dirname,'deluge.torrent')
+ torrentFile = os.path.join(self.http._dirname, 'deluge.torrent')
if self.action({'method': 'core.add_torrent_file',
'params': [torrentFile,
- base64.b64encode(torrent), {"download_path": dirname}],"id":3}) is None:
+ base64.b64encode(torrent), {"download_path": dirname}], "id": 3}) is None:
return None
return True
def add_url(self, torrent, dirname):
if re.match("^magnet\:.+$", torrent):
- if self.action({'method': 'core.add_torrent_magnet', 'params':[torrent,
- {'download_path': dirname}],"id":3}) is None:
+ if self.action({'method': 'core.add_torrent_magnet', 'params': [torrent,
+ {'download_path': dirname}],
+ "id": 3}) is None:
return None
else:
- if self.action({"method": "core.add_torrent_url", "params":[torrent, {'download_path': dirname}],"id":3}) is None:
+ if self.action({"method": "core.add_torrent_url", "params": [torrent, {'download_path': dirname}],
+ "id": 3}) is None:
return None
return True
@@ -979,48 +974,48 @@ class Deluge:
def setprio(self, id, ind):
i = -1
- prios=self.get_prio(id)
+ prios = self.get_prio(id)
for p in prios:
- i=i+1
- if p==1:
+ i = i + 1
+ if p == 1:
prios.pop(i)
- prios.insert(i,0)
+ prios.insert(i, 0)
prios.pop(int(ind))
- prios.insert(int(ind),7)
+ prios.insert(int(ind), 7)
- if self.action({"method": "core.set_torrent_file_priorities", "params":[id, prios],"id":6}) is None:
- return None
+ if self.action({"method": "core.set_torrent_file_priorities", "params": [id, prios], "id": 6}) is None:
+ return None
return True
def setprio_simple(self, id, prio, ind):
- prios=self.get_prio(id)
+ prios = self.get_prio(id)
- if ind!=None:
+ if ind != None:
prios.pop(int(ind))
if prio == '3':
- prios.insert(int(ind),7)
+ prios.insert(int(ind), 7)
elif prio == '0':
- prios.insert(int(ind),0)
+ prios.insert(int(ind), 0)
- if self.action({"method": "core.set_torrent_file_priorities", "params":[id, prios],"id":6}) is None:
+ if self.action({"method": "core.set_torrent_file_priorities", "params": [id, prios], "id": 6}) is None:
return None
return True
def setprio_simple_multi(self, menu):
- id=menu[0][0]
- prios=self.get_prio(id)
+ id = menu[0][0]
+ prios = self.get_prio(id)
for hash, action, ind in menu:
prios.pop(int(ind))
if action == '3':
- prios.insert(int(ind),7)
+ prios.insert(int(ind), 7)
elif action == '0':
- prios.insert(int(ind),0)
+ prios.insert(int(ind), 0)
- if self.action({"method": "core.set_torrent_file_priorities", "params":[id, prios],"id":6}) is None:
+ if self.action({"method": "core.set_torrent_file_priorities", "params": [id, prios], "id": 6}) is None:
return None
def action(self, request):
@@ -1034,8 +1029,8 @@ class Deluge:
return None
else:
response = self.http.fetch(self.url + '/json', method='POST', params=jsobj,
- headers={'X-Requested-With': 'XMLHttpRequest', 'Cookie': cookie,
- 'Content-Type': 'application/json; charset=UTF-8'})
+ headers={'X-Requested-With': 'XMLHttpRequest', 'Cookie': cookie,
+ 'Content-Type': 'application/json; charset=UTF-8'})
if response.error:
return None
@@ -1049,23 +1044,23 @@ class Deluge:
return obj
def action_simple(self, action, id):
- actions = {'start': {"method":"core.resume_torrent","params":[[id]],"id":4},
- 'stop': {"method":"core.pause_torrent","params":[[id]],"id":4},
- 'remove': {"method":"core.remove_torrent","params":[id, False],"id":4},
- 'removedata': {"method":"core.remove_torrent", "params":[id, True],"id":4}}
+ actions = {'start': {"method": "core.resume_torrent", "params": [[id]], "id": 4},
+ 'stop': {"method": "core.pause_torrent", "params": [[id]], "id": 4},
+ 'remove': {"method": "core.remove_torrent", "params": [id, False], "id": 4},
+ 'removedata': {"method": "core.remove_torrent", "params": [id, True], "id": 4}}
obj = self.action(actions[action])
return True if obj else None
def get_auth(self):
- params=json.dumps({"method":"auth.login","params":[self.password],"id":0})
+ params = json.dumps({"method": "auth.login", "params": [self.password], "id": 0})
response = self.http.fetch(self.url + '/json', method='POST', params=params, gzip=True,
- headers={'X-Requested-With': 'XMLHttpRequest',
- 'Content-Type': 'application/json; charset=UTF-8'})
+ headers={'X-Requested-With': 'XMLHttpRequest',
+ 'Content-Type': 'application/json; charset=UTF-8'})
if response.error:
return None
- auth=json.loads(response.body)
- if auth["result"]==False:
+ auth = json.loads(response.body)
+ if auth["result"] == False:
return False
else:
r = re.compile('_session_id=([^;]+);').search(response.headers.get('set-cookie', ''))
@@ -1118,7 +1113,7 @@ class Vuze:
'download': float(getattr(getattr(r, 'stats'), 'downloaded')),
'upload': getattr(getattr(r, 'stats'), 'uploaded'),
# 'upspeed': r['rateUpload'],
- #'downspeed': r['rateDownload'],
+ # 'downspeed': r['rateDownload'],
'ratio': float(r.stats.share_ratio) / 1000,
'eta': getattr(getattr(r, 'stats'), 'eta'),
'peer': getattr(getattr(r, 'scrape_result'), 'non_seed_count') + getattr(getattr(r, 'scrape_result'),