Merge branch 'master' of
https://github.com/DiMartinoXBMC/plugin.video.torrenter into DiMartinoXBMC-master # Conflicts: # resources/proxy/antizapret.py
This commit is contained in:
		
						commit
						ac3f8e4757
					
				@ -27,6 +27,7 @@ import zlib
 | 
				
			|||||||
import xbmc
 | 
					import xbmc
 | 
				
			||||||
import xbmcgui
 | 
					import xbmcgui
 | 
				
			||||||
import xbmcvfs
 | 
					import xbmcvfs
 | 
				
			||||||
 | 
					import xbmcaddon
 | 
				
			||||||
import Localization
 | 
					import Localization
 | 
				
			||||||
from functions import file_encode, isSubtitle, DownloadDB, log, debug, is_writable, unquote, file_url
 | 
					from functions import file_encode, isSubtitle, DownloadDB, log, debug, is_writable, unquote, file_url
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -42,9 +43,13 @@ from functions import foldername, showMessage, clearStorage, WatchedHistoryDB, g
 | 
				
			|||||||
if sys.modules["__main__"].__settings__.getSetting("torrent_player") == '2':
 | 
					if sys.modules["__main__"].__settings__.getSetting("torrent_player") == '2':
 | 
				
			||||||
    from torrent2http import State, Engine, MediaType
 | 
					    from torrent2http import State, Engine, MediaType
 | 
				
			||||||
    author = 'Anteo'
 | 
					    author = 'Anteo'
 | 
				
			||||||
 | 
					    __settings__ = xbmcaddon.Addon(id='script.module.torrent2http')
 | 
				
			||||||
 | 
					    __version__ = __settings__.getAddonInfo('version')
 | 
				
			||||||
elif sys.modules["__main__"].__settings__.getSetting("torrent_player") == '3':
 | 
					elif sys.modules["__main__"].__settings__.getSetting("torrent_player") == '3':
 | 
				
			||||||
    from pyrrent2http import State, Engine, MediaType
 | 
					    from pyrrent2http import State, Engine, MediaType
 | 
				
			||||||
    author = 'Inpos'
 | 
					    author = 'Inpos'
 | 
				
			||||||
 | 
					    __settings__ = xbmcaddon.Addon(id='script.module.pyrrent2http')
 | 
				
			||||||
 | 
					    __version__ = __settings__.getAddonInfo('version')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ROOT = sys.modules["__main__"].__root__
 | 
					ROOT = sys.modules["__main__"].__root__
 | 
				
			||||||
RESOURCES_PATH = os.path.join(ROOT, 'resources')
 | 
					RESOURCES_PATH = os.path.join(ROOT, 'resources')
 | 
				
			||||||
@ -278,7 +283,7 @@ class AnteoPlayer(xbmc.Player):
 | 
				
			|||||||
        self.userStorageDirectory = userStorageDirectory
 | 
					        self.userStorageDirectory = userStorageDirectory
 | 
				
			||||||
        self.torrentUrl = torrentUrl
 | 
					        self.torrentUrl = torrentUrl
 | 
				
			||||||
        xbmc.Player.__init__(self)
 | 
					        xbmc.Player.__init__(self)
 | 
				
			||||||
        log("[AnteoPlayer] Initalized")
 | 
					        log("["+author+"Player] Initalized v"+__version__)
 | 
				
			||||||
        self.params = params
 | 
					        self.params = params
 | 
				
			||||||
        self.get = self.params.get
 | 
					        self.get = self.params.get
 | 
				
			||||||
        self.contentId = int(self.get("url"))
 | 
					        self.contentId = int(self.get("url"))
 | 
				
			||||||
@ -397,7 +402,7 @@ class AnteoPlayer(xbmc.Player):
 | 
				
			|||||||
        #self.pre_buffer_bytes = 30*1024*1024 #30 MB
 | 
					        #self.pre_buffer_bytes = 30*1024*1024 #30 MB
 | 
				
			||||||
        ready = False
 | 
					        ready = False
 | 
				
			||||||
        progressBar = xbmcgui.DialogProgress()
 | 
					        progressBar = xbmcgui.DialogProgress()
 | 
				
			||||||
        progressBar.create(self.localize('Please Wait'),
 | 
					        progressBar.create('[%sPlayer v%s] ' % (author, __version__) + self.localize('Please Wait'),
 | 
				
			||||||
                           self.localize('Seeds searching.'))
 | 
					                           self.localize('Seeds searching.'))
 | 
				
			||||||
        #if self.subs_dl:
 | 
					        #if self.subs_dl:
 | 
				
			||||||
        #    subs = self.torrent.getSubsIds(os.path.basename(self.torrent.getFilePath(self.contentId)))
 | 
					        #    subs = self.torrent.getSubsIds(os.path.basename(self.torrent.getFilePath(self.contentId)))
 | 
				
			||||||
@ -543,7 +548,7 @@ class AnteoPlayer(xbmc.Player):
 | 
				
			|||||||
                if isSubtitle(filename, i.name):
 | 
					                if isSubtitle(filename, i.name):
 | 
				
			||||||
                    subs.append(i)
 | 
					                    subs.append(i)
 | 
				
			||||||
            if subs:
 | 
					            if subs:
 | 
				
			||||||
                log("[AnteoPlayer][setup_subs]: Detected subtitles: %s" % str(subs))
 | 
					                log("["+author+"Player][setup_subs]: Detected subtitles: %s" % str(subs))
 | 
				
			||||||
                for sub in subs:
 | 
					                for sub in subs:
 | 
				
			||||||
                    xbmc.Player().setSubtitles(sub.url)
 | 
					                    xbmc.Player().setSubtitles(sub.url)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										14
									
								
								Core.py
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								Core.py
									
									
									
									
									
								
							@ -276,7 +276,19 @@ class Core:
 | 
				
			|||||||
        #    self.Downloader.__exit__()
 | 
					        #    self.Downloader.__exit__()
 | 
				
			||||||
        #self.Player = AnteoPlayer(userStorageDirectory=self.userStorageDirectory, torrentUrl=torrentUrl, params=params)
 | 
					        #self.Player = AnteoPlayer(userStorageDirectory=self.userStorageDirectory, torrentUrl=torrentUrl, params=params)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        xbmcgui.Dialog().ok('Dam Son!','Now send this shit to DiMartino')
 | 
					        #xbmcgui.Dialog().ok('Dam Son!','Now send this shit to DiMartino')
 | 
				
			||||||
 | 
					        from resources.proxy import antizapret
 | 
				
			||||||
 | 
					        filename = os.path.join(tempdir(),"antizapret.pac_config")
 | 
				
			||||||
 | 
					        import shelve
 | 
				
			||||||
 | 
					        from contextlib import contextmanager, closing
 | 
				
			||||||
 | 
					        with closing(shelve.open(filename, writeback=True)) as d:
 | 
				
			||||||
 | 
					            import time
 | 
				
			||||||
 | 
					            log(str(d))
 | 
				
			||||||
 | 
					            log(str(time.time()))
 | 
				
			||||||
 | 
					            log(str((time.time() - d["created_at"])))
 | 
				
			||||||
 | 
					            ttl = 24*3600
 | 
				
			||||||
 | 
					            if ttl > 0 and (time.time() - d["created_at"]) > ttl:
 | 
				
			||||||
 | 
					                log('xxx')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def DownloadStatus(self, params={}):
 | 
					    def DownloadStatus(self, params={}):
 | 
				
			||||||
        db = DownloadDB()
 | 
					        db = DownloadDB()
 | 
				
			||||||
 | 
				
			|||||||
@ -244,7 +244,7 @@ class TorrentPlayer(xbmc.Player):
 | 
				
			|||||||
    def buffer(self):
 | 
					    def buffer(self):
 | 
				
			||||||
        iterator = 0
 | 
					        iterator = 0
 | 
				
			||||||
        progressBar = xbmcgui.DialogProgress()
 | 
					        progressBar = xbmcgui.DialogProgress()
 | 
				
			||||||
        progressBar.create(self.localize('Please Wait') + str(' [%s]' % str(self.torrent.lt.version)),
 | 
					        progressBar.create('[python-libtorrent %s] - ' % str(self.torrent.lt.version) + self.localize('Please Wait'),
 | 
				
			||||||
                           self.localize('Seeds searching.'))
 | 
					                           self.localize('Seeds searching.'))
 | 
				
			||||||
        if self.subs_dl:
 | 
					        if self.subs_dl:
 | 
				
			||||||
            subs = self.torrent.getSubsIds(os.path.basename(self.path))
 | 
					            subs = self.torrent.getSubsIds(os.path.basename(self.path))
 | 
				
			||||||
 | 
				
			|||||||
@ -33,7 +33,7 @@ import sys
 | 
				
			|||||||
import xbmcgui
 | 
					import xbmcgui
 | 
				
			||||||
import xbmc
 | 
					import xbmc
 | 
				
			||||||
import Localization
 | 
					import Localization
 | 
				
			||||||
from functions import log, debug
 | 
					from functions import log, debug, showMessage
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class SearcherABC:
 | 
					class SearcherABC:
 | 
				
			||||||
@ -47,13 +47,6 @@ class SearcherABC:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    socket.setdefaulttimeout(10+(10*int(timeout_multi)))
 | 
					    socket.setdefaulttimeout(10+(10*int(timeout_multi)))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    #def __del__(self):
 | 
					 | 
				
			||||||
    #    print '!!!!!!!!!!!!!!!!!! DIED !!! '+self.__class__.__name__
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    #def __init__(self):
 | 
					 | 
				
			||||||
    #    print '!!!!!!!!!!!!!!!!!! BORN '+self.__class__.__name__
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    def search(self, keyword):
 | 
					    def search(self, keyword):
 | 
				
			||||||
        '''
 | 
					        '''
 | 
				
			||||||
        Retrieve keyword from the input and return a list of tuples:
 | 
					        Retrieve keyword from the input and return a list of tuples:
 | 
				
			||||||
@ -110,19 +103,24 @@ class SearcherABC:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    def makeRequest(self, url, data={}, headers={}):
 | 
					    def makeRequest(self, url, data={}, headers={}):
 | 
				
			||||||
        self.load_cookie()
 | 
					        self.load_cookie()
 | 
				
			||||||
 | 
					        opener = None
 | 
				
			||||||
        if self.proxy == 1:
 | 
					        if self.proxy == 1:
 | 
				
			||||||
 | 
					            try:
 | 
				
			||||||
                from resources.proxy import antizapret
 | 
					                from resources.proxy import antizapret
 | 
				
			||||||
                opener = urllib2.build_opener(antizapret.AntizapretProxyHandler(), urllib2.HTTPCookieProcessor(self.cookieJar))
 | 
					                opener = urllib2.build_opener(antizapret.AntizapretProxyHandler(), urllib2.HTTPCookieProcessor(self.cookieJar))
 | 
				
			||||||
                config = antizapret.config()
 | 
					                config = antizapret.config()
 | 
				
			||||||
                self.debug('[antizapret]: '+str(config["domains"]))
 | 
					                self.debug('[antizapret]: '+str(config["domains"]))
 | 
				
			||||||
                self.debug('[antizapret]: '+str(config["server"]))
 | 
					                self.debug('[antizapret]: '+str(config["server"]))
 | 
				
			||||||
        elif self.proxy == 2:
 | 
					            except:
 | 
				
			||||||
            from resources.proxy import immunicity
 | 
					                showMessage('AntiZapret', Localization.localize('Error'))
 | 
				
			||||||
            opener = urllib2.build_opener(immunicity.ImmunicityProxyHandler(), urllib2.HTTPCookieProcessor(self.cookieJar))
 | 
					                self.debug('[antizapret]: OFF!')
 | 
				
			||||||
            config = immunicity.config()
 | 
					        #elif self.proxy == 2:
 | 
				
			||||||
            self.debug('[immunicity]: '+str(config["domains"]))
 | 
					        #    from resources.proxy import immunicity
 | 
				
			||||||
            self.debug('[immunicity]: '+str(config["server"]))
 | 
					        #    opener = urllib2.build_opener(immunicity.ImmunicityProxyHandler(), urllib2.HTTPCookieProcessor(self.cookieJar))
 | 
				
			||||||
        else:
 | 
					        #    config = immunicity.config()
 | 
				
			||||||
 | 
					        #    self.debug('[immunicity]: '+str(config["domains"]))
 | 
				
			||||||
 | 
					        #    self.debug('[immunicity]: '+str(config["server"]))
 | 
				
			||||||
 | 
					        if not opener:
 | 
				
			||||||
            opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.cookieJar))
 | 
					            opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.cookieJar))
 | 
				
			||||||
        opener.addheaders = headers
 | 
					        opener.addheaders = headers
 | 
				
			||||||
        if 0 < len(data):
 | 
					        if 0 < len(data):
 | 
				
			||||||
 | 
				
			|||||||
@ -42,7 +42,7 @@ def config():
 | 
				
			|||||||
    global _config
 | 
					    global _config
 | 
				
			||||||
    if not _config:
 | 
					    if not _config:
 | 
				
			||||||
#        with shelf("antizapret.pac_config", ttl=CACHE) as pac_config:
 | 
					#        with shelf("antizapret.pac_config", ttl=CACHE) as pac_config:
 | 
				
			||||||
        d = shelf("antizapret.pac_config", ttl=CACHE)
 | 
					        d = shelf("antizapret.pac_config2", ttl=CACHE)
 | 
				
			||||||
        pac_config = d['data']
 | 
					        pac_config = d['data']
 | 
				
			||||||
        if not pac_config:
 | 
					        if not pac_config:
 | 
				
			||||||
            log("[antizapret]: Fetching Antizapret PAC file on %s" %PAC_URL)
 | 
					            log("[antizapret]: Fetching Antizapret PAC file on %s" %PAC_URL)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user