log update

pull/1/head
DiMartinoXBMC 2015-12-23 18:26:19 +03:00
parent 32196e5876
commit de2323f7af
13 changed files with 589 additions and 655 deletions

File diff suppressed because it is too large Load Diff

View File

@ -39,11 +39,11 @@ class Content:
cookieJar = None cookieJar = None
baseurl = '' baseurl = ''
def __del__(self): #def __del__(self):
print '!!!!!!!!!!!!!!!!!! DIED !!! '+self.__class__.__name__ # print '!!!!!!!!!!!!!!!!!! DIED !!! '+self.__class__.__name__
def __init__(self): #def __init__(self):
print '!!!!!!!!!!!!!!!!!! BORN '+self.__class__.__name__ # print '!!!!!!!!!!!!!!!!!! BORN '+self.__class__.__name__
def isTracker(self): def isTracker(self):
return 'Never seen' return 'Never seen'
@ -188,13 +188,13 @@ class Content:
response = opener.open(url, encodedData) response = opener.open(url, encodedData)
except urllib2.HTTPError as e: except urllib2.HTTPError as e:
if e.code == 404: if e.code == 404:
print '[makeRequest]: Not Found! HTTP Error, e.code=' + str(e.code) self.log('[makeRequest]: Not Found! HTTP Error, e.code=' + str(e.code))
return return
elif e.code in [503]: elif e.code in [503]:
print '[makeRequest]: Denied, HTTP Error, e.code=' + str(e.code) self.log('[makeRequest]: Denied, HTTP Error, e.code=' + str(e.code))
return return
else: else:
print '[makeRequest]: HTTP Error, e.code=' + str(e.code) self.log('[makeRequest]: HTTP Error, e.code=' + str(e.code))
return return
if response.info().get('Content-Encoding') == 'gzip': if response.info().get('Content-Encoding') == 'gzip':
buf = StringIO(response.read()) buf = StringIO(response.read())

18
Core.py
View File

@ -41,10 +41,10 @@ class Core:
language = {0: 'en', 1: 'ru', 2: 'ru'}.get(int(__settings__.getSetting("language"))) language = {0: 'en', 1: 'ru', 2: 'ru'}.get(int(__settings__.getSetting("language")))
scrapperDB_ver = {'en':'1.1', 'ru':'1.3'} scrapperDB_ver = {'en':'1.1', 'ru':'1.3'}
print 'SYS ARGV: ' + str(sys.argv) log('SYS ARGV: ' + str(sys.argv))
def __init__(self): def __init__(self):
print '!!!!!!!!!!!!!!!!!! BORN '+self.__class__.__name__ #print '!!!!!!!!!!!!!!!!!! BORN '+self.__class__.__name__
if len(self.userStorageDirectory) == 0: if len(self.userStorageDirectory) == 0:
download_dir = get_download_dir() download_dir = get_download_dir()
else: else:
@ -243,7 +243,7 @@ class Core:
if 0 != len(torrentUrl): if 0 != len(torrentUrl):
self.Downloader = Downloader.Torrent(self.userStorageDirectory, torrentUrl) self.Downloader = Downloader.Torrent(self.userStorageDirectory, torrentUrl)
else: else:
print self.__plugin__ + " Unexpected access to method Anteoloader() without torrent content" log(self.__plugin__ + " Unexpected access to method Anteoloader() without torrent content")
#if self.Downloader: #if self.Downloader:
# x=self.Downloader.getContentList() # x=self.Downloader.getContentList()
# print str(x) # print str(x)
@ -578,7 +578,7 @@ class Core:
try: try:
self.contenterObject[contenter] = getattr(__import__(contenter), contenter)() self.contenterObject[contenter] = getattr(__import__(contenter), contenter)()
except Exception, e: except Exception, e:
print 'Unable to use contenter: ' + contenter + ' at ' + ' Content(). Exception: ' + str(e) log('Unable to use contenter: ' + contenter + ' at ' + ' Content(). Exception: ' + str(e))
if not subcategory: if not subcategory:
if not category and not provider: if not category and not provider:
@ -678,7 +678,7 @@ class Core:
try: try:
self.contenterObject[contenter] = getattr(__import__(contenter), contenter)() self.contenterObject[contenter] = getattr(__import__(contenter), contenter)()
except Exception, e: except Exception, e:
print 'Unable to use contenter: ' + contenter + ' at ' + ' Content(). Exception: ' + str(e) log('Unable to use contenter: ' + contenter + ' at ' + ' Content(). Exception: ' + str(e))
if provider: if provider:
for cat in self.Contenters.get_activedic().keys(): for cat in self.Contenters.get_activedic().keys():
@ -904,7 +904,7 @@ class Core:
try: try:
self.Content = getattr(__import__(contenter), contenter)() self.Content = getattr(__import__(contenter), contenter)()
except Exception, e: except Exception, e:
print 'Unable to use contenter: ' + contenter + ' at ' + ' ActionInfo(). Exception: ' + str(e) log('Unable to use contenter: ' + contenter + ' at ' + ' ActionInfo(). Exception: ' + str(e))
movieInfo=self.Content.get_info(infolink) movieInfo=self.Content.get_info(infolink)
if movieInfo: if movieInfo:
@ -1293,13 +1293,13 @@ class Core:
if 0 != len(torrentUrl): if 0 != len(torrentUrl):
self.Player = TorrentPlayer(userStorageDirectory=self.userStorageDirectory, torrentUrl=torrentUrl, params=params) self.Player = TorrentPlayer(userStorageDirectory=self.userStorageDirectory, torrentUrl=torrentUrl, params=params)
else: else:
print self.__plugin__ + " Unexpected access to method playTorrent() without torrent content" log(self.__plugin__ + " Unexpected access to method playTorrent() without torrent content")
elif self.torrent_player == '2': elif self.torrent_player == '2':
from Anteoloader import AnteoPlayer from Anteoloader import AnteoPlayer
if 0 != len(torrentUrl): if 0 != len(torrentUrl):
self.Player = AnteoPlayer(userStorageDirectory=self.userStorageDirectory, torrentUrl=torrentUrl, params=params) self.Player = AnteoPlayer(userStorageDirectory=self.userStorageDirectory, torrentUrl=torrentUrl, params=params)
else: else:
print self.__plugin__ + " Unexpected access to method playTorrent() without torrent content" log(self.__plugin__ + " Unexpected access to method playTorrent() without torrent content")
elif self.torrent_player == '1': elif self.torrent_player == '1':
__ASsettings__ = xbmcaddon.Addon(id='script.module.torrent.ts') __ASsettings__ = xbmcaddon.Addon(id='script.module.torrent.ts')
folder=__ASsettings__.getSetting("folder") folder=__ASsettings__.getSetting("folder")
@ -1336,7 +1336,7 @@ class Core:
localFile.close() localFile.close()
return torrentFile return torrentFile
except: except:
print 'Unable to save torrent file from "' + url + '" to "' + torrentFile + '" in Torrent::saveTorrent' log('Unable to save torrent file from "' + url + '" to "' + torrentFile + '" in Torrent::saveTorrent')
return return
def playSTRM(self, params={}): def playSTRM(self, params={}):

View File

@ -24,7 +24,7 @@ import sys
import Libtorrent import Libtorrent
import AceStream import AceStream
import Anteoloader import Anteoloader
from functions import log
class Torrent(): class Torrent():
__settings__ = sys.modules["__main__"].__settings__ __settings__ = sys.modules["__main__"].__settings__
@ -136,6 +136,6 @@ class Torrent():
def dump(self, obj): def dump(self, obj):
for attr in dir(obj): for attr in dir(obj):
try: try:
print "'%s':'%s'," % (attr, getattr(obj, attr)) log("'%s':'%s'," % (attr, getattr(obj, attr)))
except: except:
pass pass

View File

@ -116,15 +116,14 @@ class Libtorrent:
localFile.write(content) localFile.write(content)
localFile.close() localFile.close()
except Exception, e: except Exception, e:
print 'Unable to save torrent file from "' + torrentUrl + '" to "' + torrentFile + '" in Torrent::saveTorrent' + '. Exception: ' + str( log('Unable to save torrent file from "' + torrentUrl + '" to "' + torrentFile + '" in Torrent::saveTorrent' + '. Exception: ' + str(e))
e)
return return
if xbmcvfs.exists(torrentFile): if xbmcvfs.exists(torrentFile):
try: try:
e=self.lt.bdecode(xbmcvfs.File(torrentFile,'rb').read()) e=self.lt.bdecode(xbmcvfs.File(torrentFile,'rb').read())
self.torrentFileInfo = self.lt.torrent_info(e) self.torrentFileInfo = self.lt.torrent_info(e)
except Exception, e: except Exception, e:
print 'Exception: ' + str(e) log('Exception: ' + str(e))
xbmcvfs.delete(torrentFile) xbmcvfs.delete(torrentFile)
return return
baseName = file_encode(os.path.basename(self.getFilePath())) baseName = file_encode(os.path.basename(self.getFilePath()))
@ -503,7 +502,7 @@ class Libtorrent:
# print str(s.pieces) # print str(s.pieces)
#except: #except:
else: else:
print 'debug error' log('debug error')
pass pass
def get_debug_info(self, info): def get_debug_info(self, info):
@ -534,6 +533,6 @@ class Libtorrent:
def dump(self, obj): def dump(self, obj):
for attr in dir(obj): for attr in dir(obj):
try: try:
print "'%s':'%s'," % (attr, getattr(obj, attr)) log("'%s':'%s'," % (attr, getattr(obj, attr)))
except: except:
pass pass

View File

@ -48,11 +48,11 @@ class SearcherABC:
socket.setdefaulttimeout(10+(10*int(timeout_multi))) socket.setdefaulttimeout(10+(10*int(timeout_multi)))
def __del__(self): #def __del__(self):
print '!!!!!!!!!!!!!!!!!! DIED !!! '+self.__class__.__name__ # print '!!!!!!!!!!!!!!!!!! DIED !!! '+self.__class__.__name__
def __init__(self): #def __init__(self):
print '!!!!!!!!!!!!!!!!!! BORN '+self.__class__.__name__ # print '!!!!!!!!!!!!!!!!!! BORN '+self.__class__.__name__
def search(self, keyword): def search(self, keyword):
''' '''

View File

@ -23,7 +23,7 @@ import sys
import xbmcaddon import xbmcaddon
import xbmc import xbmc
import xbmcgui import xbmcgui
from functions import getParameters, HistoryDB, Searchers from functions import getParameters, HistoryDB, Searchers, log
from resources.pyxbmct.addonwindow import * from resources.pyxbmct.addonwindow import *
__settings__ = xbmcaddon.Addon(id='plugin.video.torrenter') __settings__ = xbmcaddon.Addon(id='plugin.video.torrenter')
@ -32,7 +32,7 @@ __version__ = __settings__.getAddonInfo('version')
__plugin__ = __settings__.getAddonInfo('name') + " v." + __version__ __plugin__ = __settings__.getAddonInfo('name') + " v." + __version__
__root__ = __settings__.getAddonInfo('path') __root__ = __settings__.getAddonInfo('path')
print 'SYS ARGV: ' + str(sys.argv) log('SYS ARGV: ' + str(sys.argv))
if len(sys.argv) > 1: if len(sys.argv) > 1:
params = getParameters(sys.argv[1]) params = getParameters(sys.argv[1])

View File

@ -21,6 +21,7 @@
import sys import sys
import gc import gc
import xbmcaddon import xbmcaddon
from functions import log
__settings__ = xbmcaddon.Addon(id='plugin.video.torrenter') __settings__ = xbmcaddon.Addon(id='plugin.video.torrenter')
@ -29,7 +30,7 @@ __plugin__ = __settings__.getAddonInfo('name') + " v." + __version__
__root__ = __settings__.getAddonInfo('path') __root__ = __settings__.getAddonInfo('path')
if (__name__ == "__main__" ): if (__name__ == "__main__" ):
print __plugin__ log(__plugin__)
import Core import Core
core = Core.Core() core = Core.Core()
@ -41,4 +42,4 @@ if (__name__ == "__main__" ):
del core del core
collected = gc.collect() collected = gc.collect()
print "Garbage collector: collected %d objects." % (collected) log("Garbage collector: collected %d objects." % (collected))

View File

@ -426,7 +426,6 @@ def cutFolder(contentList, tdir=None):
common = True common = True
for fileTitle, contentId in contentList: for fileTitle, contentId in contentList:
if common_folder not in fileTitle: if common_folder not in fileTitle:
print 'no common'
common = False common = False
break break
@ -1065,28 +1064,26 @@ class Searchers():
slist = self.list() slist = self.list()
if slist[searcher]['path'] not in sys.path: if slist[searcher]['path'] not in sys.path:
sys.path.insert(0, slist[searcher]['path']) sys.path.insert(0, slist[searcher]['path'])
print 'Added %s in sys.path' % (slist[searcher]['path']) log('Added %s in sys.path' % (slist[searcher]['path']))
try: try:
searcherObject = getattr(__import__(searcher), searcher) searcherObject = getattr(__import__(searcher), searcher)
filesList = searcherObject().search(keyword) filesList = searcherObject().search(keyword)
del searcherObject del searcherObject
except Exception, e: except Exception, e:
print 'Unable to use searcher: ' + searcher + ' at ' + __plugin__ + ' searchWithSearcher(). Exception: ' + str( log('Unable to use searcher: ' + searcher + ' at ' + __plugin__ + ' searchWithSearcher(). Exception: ' + str(e))
e) log(traceback.format_exc())
print(traceback.format_exc())
return filesList return filesList
def downloadWithSearcher(self, url, searcher): def downloadWithSearcher(self, url, searcher):
slist = Searchers().list() slist = Searchers().list()
if slist[searcher]['path'] not in sys.path: if slist[searcher]['path'] not in sys.path:
sys.path.insert(0, slist[searcher]['path']) sys.path.insert(0, slist[searcher]['path'])
print 'Added %s in sys.path' % (slist[searcher]['path']) log('Added %s in sys.path' % (slist[searcher]['path']))
try: try:
searcherObject = getattr(__import__(searcher), searcher)() searcherObject = getattr(__import__(searcher), searcher)()
url = searcherObject.getTorrentFile(url) url = searcherObject.getTorrentFile(url)
except Exception, e: except Exception, e:
print 'Unable to use searcher: ' + searcher + ' at ' + __plugin__ + ' downloadWithSearcher(). Exception: ' + str( log('Unable to use searcher: ' + searcher + ' at ' + __plugin__ + ' downloadWithSearcher(). Exception: ' + str(e))
e)
return url return url
def checkExist(self, searcher): def checkExist(self, searcher):
@ -1144,7 +1141,7 @@ def search(url, searchersList, isApi=None):
if searcherFile == CleanExit: if searcherFile == CleanExit:
return return
searcher=searcherFile.replace('.py','') searcher=searcherFile.replace('.py','')
print "Thread %s: Searching at %s" % (i, searcher) log("Thread %s: Searching at %s" % (i, searcher))
result[searcherFile]=Searchers().searchWithSearcher(url, searcher) result[searcherFile]=Searchers().searchWithSearcher(url, searcher)
left_searchers.remove(searcherFile) left_searchers.remove(searcherFile)
q.task_done() q.task_done()
@ -1161,16 +1158,16 @@ def search(url, searchersList, isApi=None):
for searcherFile in searchersList: for searcherFile in searchersList:
queue.put(searcherFile) queue.put(searcherFile)
print "Main Thread Waiting" log("Main Thread Waiting")
queue.join() queue.join()
for i in range(num_threads): for i in range(num_threads):
queue.put(CleanExit) queue.put(CleanExit)
print "Main Thread Waiting for Threads" log("Main Thread Waiting for Threads")
for w in workers: for w in workers:
w.join() w.join()
print "Done" log("Done")
if not isApi: if not isApi:
progressBar.update(0) progressBar.update(0)
@ -1309,7 +1306,7 @@ def fetchData(url, referer=None):
connection.close() connection.close()
return (result) return (result)
except (urllib2.HTTPError, urllib2.URLError) as e: except (urllib2.HTTPError, urllib2.URLError) as e:
print " fetchData(" + url + ") exception: " + str(e) log(" fetchData(" + url + ") exception: " + str(e))
return return
@ -1817,9 +1814,9 @@ def check_network_advancedsettings():
f.close() f.close()
dialog.ok(Localization.localize('Upgrade advancedsettings.xml'), dialog.ok(Localization.localize('Upgrade advancedsettings.xml'),
Localization.localize('Please, restart Kodi now!')) Localization.localize('Please, restart Kodi now!'))
print 'Restart Kodi' log('Restart Kodi')
else: else:
print 'UPDATE advancedsettings.xml disabled by user!' log('UPDATE advancedsettings.xml disabled by user!')
def get_download_dir(): def get_download_dir():
from platform_pulsar import get_platform from platform_pulsar import get_platform

View File

@ -2,6 +2,7 @@
# #
try: try:
import xbmcaddon import xbmcaddon
from functions import log, debug
__settings__ = xbmcaddon.Addon("plugin.video.torrenter") __settings__ = xbmcaddon.Addon("plugin.video.torrenter")
debug = __settings__.getSetting("debug") debug = __settings__.getSetting("debug")
@ -10,31 +11,19 @@ except:
def Log(msg, force=False): def Log(msg, force=False):
try: log(msg)
print "[torrenter log] " + msg
except UnicodeEncodeError:
print "[torrenter log] " + msg.encode("utf-8", "ignore")
def Debug(msg, force=False): def Debug(msg, force=False):
if debug == 'true' or force: if debug == 'true' or force:
try: debug(msg, True)
print "[torrenter] " + msg
except UnicodeEncodeError:
print "[torrenter] " + msg.encode("utf-8", "ignore")
def Info(msg, force=False): def Info(msg, force=False):
if debug == 'true' or force: if debug == 'true' or force:
try: debug(msg, True)
print "[torrenter] " + msg
except UnicodeEncodeError:
print "[torrenter] " + msg.encode("utf-8", "ignore")
def Warn(msg, force=False): def Warn(msg, force=False):
if debug == 'true' or force: if debug == 'true' or force:
try: debug(msg, True)
print "[torrenter] " + msg
except UnicodeEncodeError:
print "[torrenter] " + msg.encode("utf-8", "ignore")

View File

@ -4,6 +4,7 @@ import time
import urllib import urllib
from cache import Cache from cache import Cache
from functions import log
import tmdb import tmdb
@ -154,9 +155,9 @@ class TmDb:
movie_id = None movie_id = None
for name in search: for name in search:
movies = tmdb.Movies(title=name, year=year, limit=True).get_ordered_matches() movies = tmdb.Movies(title=name, year=year, limit=True).get_ordered_matches()
print '********************************************************' log('********************************************************')
try: try:
print str(isAsciiString(movies[1]['title'])) log(str(isAsciiString(movies[1]['title'])))
except: except:
pass pass
@ -320,7 +321,7 @@ def scoreMediaTitleMatch(mediaName, mediaAltTitle, mediaYear, title, original_ti
def get_best(Data, search, year): def get_best(Data, search, year):
print '****** Finding TMDB: ' + str(search) + '; year ' + str(year) log('****** Finding TMDB: ' + str(search) + '; year ' + str(year))
shows = [] shows = []
itemIndex = -1 itemIndex = -1
if len(search) == 2: if len(search) == 2:
@ -349,7 +350,7 @@ def get_best(Data, search, year):
release_date=str(show.get('release_date').split('-')[0]) release_date=str(show.get('release_date').split('-')[0])
else: else:
release_date='0' release_date='0'
print (' ... %d: id="%s", name="%s", year="%s", score="%d".' % log(' ... %d: id="%s", name="%s", year="%s", score="%d".' %
(i, str(show['id']), show.get('title').encode('utf-8'), release_date, (i, str(show['id']), show.get('title').encode('utf-8'), release_date,
s['rate'])) s['rate']))
if shows: if shows:

View File

@ -10,6 +10,7 @@ import zipfile
import xbmc import xbmc
from net import HTTP from net import HTTP
from cache import Cache from cache import Cache
from functions import log
class TvDb: class TvDb:
@ -82,7 +83,7 @@ class TvDb:
# print url # print url
response = self.http.fetch(url, headers=self.headers, download=os.path.join(dirname, 'movie.zip'), timeout=20) response = self.http.fetch(url, headers=self.headers, download=os.path.join(dirname, 'movie.zip'), timeout=20)
if response.error: if response.error:
print "ERRRRRROR! " + str(response.error) log("ERRRRRROR! " + str(response.error))
self._movie_clear(dirname) self._movie_clear(dirname)
return False, None return False, None
@ -411,7 +412,7 @@ def get_best(Data, search, year):
shows.append({'rate': rate, 'id': id}) shows.append({'rate': rate, 'id': id})
shows = sorted(shows, key=lambda x: x['rate'], reverse=True) shows = sorted(shows, key=lambda x: x['rate'], reverse=True)
print '********************** TheTVDB ******************************' log('********************** TheTVDB ******************************')
print str(shows) + str(mediaName.encode('utf-8')) log(str(shows) + str(mediaName.encode('utf-8')))
if shows: if shows:
return shows[0] return shows[0]

View File

@ -853,7 +853,7 @@ class Deluge:
if port: if port:
self.url += ':' + str(port) self.url += ':' + str(port)
self.url += url self.url += url
print str(self.url) log(str(self.url))
self.http = HTTP() self.http = HTTP()
def get_info(self): def get_info(self):