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
baseurl = ''
def __del__(self):
print '!!!!!!!!!!!!!!!!!! DIED !!! '+self.__class__.__name__
#def __del__(self):
# print '!!!!!!!!!!!!!!!!!! DIED !!! '+self.__class__.__name__
def __init__(self):
print '!!!!!!!!!!!!!!!!!! BORN '+self.__class__.__name__
#def __init__(self):
# print '!!!!!!!!!!!!!!!!!! BORN '+self.__class__.__name__
def isTracker(self):
return 'Never seen'
@ -188,13 +188,13 @@ class Content:
response = opener.open(url, encodedData)
except urllib2.HTTPError as e:
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
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
else:
print '[makeRequest]: HTTP Error, e.code=' + str(e.code)
self.log('[makeRequest]: HTTP Error, e.code=' + str(e.code))
return
if response.info().get('Content-Encoding') == 'gzip':
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")))
scrapperDB_ver = {'en':'1.1', 'ru':'1.3'}
print 'SYS ARGV: ' + str(sys.argv)
log('SYS ARGV: ' + str(sys.argv))
def __init__(self):
print '!!!!!!!!!!!!!!!!!! BORN '+self.__class__.__name__
#print '!!!!!!!!!!!!!!!!!! BORN '+self.__class__.__name__
if len(self.userStorageDirectory) == 0:
download_dir = get_download_dir()
else:
@ -243,7 +243,7 @@ class Core:
if 0 != len(torrentUrl):
self.Downloader = Downloader.Torrent(self.userStorageDirectory, torrentUrl)
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:
# x=self.Downloader.getContentList()
# print str(x)
@ -578,7 +578,7 @@ class Core:
try:
self.contenterObject[contenter] = getattr(__import__(contenter), contenter)()
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 category and not provider:
@ -678,7 +678,7 @@ class Core:
try:
self.contenterObject[contenter] = getattr(__import__(contenter), contenter)()
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:
for cat in self.Contenters.get_activedic().keys():
@ -904,7 +904,7 @@ class Core:
try:
self.Content = getattr(__import__(contenter), contenter)()
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)
if movieInfo:
@ -1293,13 +1293,13 @@ class Core:
if 0 != len(torrentUrl):
self.Player = TorrentPlayer(userStorageDirectory=self.userStorageDirectory, torrentUrl=torrentUrl, params=params)
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':
from Anteoloader import AnteoPlayer
if 0 != len(torrentUrl):
self.Player = AnteoPlayer(userStorageDirectory=self.userStorageDirectory, torrentUrl=torrentUrl, params=params)
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':
__ASsettings__ = xbmcaddon.Addon(id='script.module.torrent.ts')
folder=__ASsettings__.getSetting("folder")
@ -1336,7 +1336,7 @@ class Core:
localFile.close()
return torrentFile
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
def playSTRM(self, params={}):

View File

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

View File

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

View File

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

View File

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

View File

@ -21,6 +21,7 @@
import sys
import gc
import xbmcaddon
from functions import log
__settings__ = xbmcaddon.Addon(id='plugin.video.torrenter')
@ -29,7 +30,7 @@ __plugin__ = __settings__.getAddonInfo('name') + " v." + __version__
__root__ = __settings__.getAddonInfo('path')
if (__name__ == "__main__" ):
print __plugin__
log(__plugin__)
import Core
core = Core.Core()
@ -41,4 +42,4 @@ if (__name__ == "__main__" ):
del core
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
for fileTitle, contentId in contentList:
if common_folder not in fileTitle:
print 'no common'
common = False
break
@ -1065,28 +1064,26 @@ class Searchers():
slist = self.list()
if slist[searcher]['path'] not in sys.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:
searcherObject = getattr(__import__(searcher), searcher)
filesList = searcherObject().search(keyword)
del searcherObject
except Exception, e:
print 'Unable to use searcher: ' + searcher + ' at ' + __plugin__ + ' searchWithSearcher(). Exception: ' + str(
e)
print(traceback.format_exc())
log('Unable to use searcher: ' + searcher + ' at ' + __plugin__ + ' searchWithSearcher(). Exception: ' + str(e))
log(traceback.format_exc())
return filesList
def downloadWithSearcher(self, url, searcher):
slist = Searchers().list()
if slist[searcher]['path'] not in sys.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:
searcherObject = getattr(__import__(searcher), searcher)()
url = searcherObject.getTorrentFile(url)
except Exception, e:
print 'Unable to use searcher: ' + searcher + ' at ' + __plugin__ + ' downloadWithSearcher(). Exception: ' + str(
e)
log('Unable to use searcher: ' + searcher + ' at ' + __plugin__ + ' downloadWithSearcher(). Exception: ' + str(e))
return url
def checkExist(self, searcher):
@ -1144,7 +1141,7 @@ def search(url, searchersList, isApi=None):
if searcherFile == CleanExit:
return
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)
left_searchers.remove(searcherFile)
q.task_done()
@ -1161,16 +1158,16 @@ def search(url, searchersList, isApi=None):
for searcherFile in searchersList:
queue.put(searcherFile)
print "Main Thread Waiting"
log("Main Thread Waiting")
queue.join()
for i in range(num_threads):
queue.put(CleanExit)
print "Main Thread Waiting for Threads"
log("Main Thread Waiting for Threads")
for w in workers:
w.join()
print "Done"
log("Done")
if not isApi:
progressBar.update(0)
@ -1309,7 +1306,7 @@ def fetchData(url, referer=None):
connection.close()
return (result)
except (urllib2.HTTPError, urllib2.URLError) as e:
print " fetchData(" + url + ") exception: " + str(e)
log(" fetchData(" + url + ") exception: " + str(e))
return
@ -1817,9 +1814,9 @@ def check_network_advancedsettings():
f.close()
dialog.ok(Localization.localize('Upgrade advancedsettings.xml'),
Localization.localize('Please, restart Kodi now!'))
print 'Restart Kodi'
log('Restart Kodi')
else:
print 'UPDATE advancedsettings.xml disabled by user!'
log('UPDATE advancedsettings.xml disabled by user!')
def get_download_dir():
from platform_pulsar import get_platform

View File

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

View File

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

View File

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

View File

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